Repository navigation
Conversation
EMR Serverless rejects StopApplication while any of the application's sessions is still active, and the provider had no way to terminate a session. EmrServerlessStopApplicationOperator cannot cover the gap: its force_stop argument only calls cancel_running_jobs, which cancels job runs and leaves sessions untouched. As a result example_emr_serverless_session could never finish. Its teardown went straight from start_session to stop_app, so the session was still IDLE and AWS failed the call: ValidationException: Application ... cannot be STOPPED. All sessions for the Application need to be in one of the following states: [TERMINATED, FAILED] This adds the counterpart to EmrServerlessStartSessionOperator. The terminated waiter accepts both TERMINATED and FAILED, since either state lets the application stop, and the session APIs stay gated on botocore at runtime so users who do not touch sessions keep the provider's lower floor. The system test now terminates the session before stopping the application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
EMR Serverless rejects
StopApplicationwhile any of the application's sessions is still active, and the provider has no way to terminate a session.EmrServerlessStopApplicationOperatorcannot cover the gap — itsforce_stopargument only callscancel_running_jobs, which cancels job runs and leaves sessions untouched.As a result
example_emr_serverless_session, added in #70763, can never finish. Its teardown goes straight fromstart_sessiontostop_app, so the session is stillIDLEand AWS fails the call:stop_appfails,delete_appfails with it, and the application is left running and billing.What
Adds
EmrServerlessTerminateSessionOperator, the counterpart toEmrServerlessStartSessionOperator:EmrServerlessHook.terminate_session()wrapping theTerminateSessionAPI, gated on botocore at runtime by the existing_check_interactive_session_support()so users who do not touch sessions keep the provider's lower botocore floor.serverless_session_terminatedwaiter. It accepts bothTERMINATEDandFAILEDas success, because either state is enough for the application to stop — that is exactly the conditionStopApplicationenforces.EmrServerlessTerminateSessionTriggerfor deferrable mode.force_stopdoes not cover sessions, so dag authors know they need this operator.force_stopis deliberately left alone: it is documented as being about job runs, and making it terminate sessions as well would change the behaviour of the existing operator. Happy to extend it in a follow-up if maintainers prefer that instead.Testing
providers/amazon/tests/unit/amazon/aws/{operators/test_emr_serverless_session,hooks/test_emr_serverless,triggers/test_emr}.py— 51 passed, covering the sync wait,wait_for_completion=False, the deferrable path,execute_completesuccess/failure, the hook call and its botocore gate, and trigger serialization.stop_appfailed with theValidationExceptionabove,delete_appfailed, application leftSTARTED.DagRun ... state=success, and the application was deleted by the dag's own teardown (list_applicationsshows nosession-systestleft behind).