1fanwang opened a new pull request, #72421: URL: https://github.com/apache/airflow/pull/72421
## Related Issue(s) No issue. ## Why are the changes needed? `EcsRunTaskOperator(reattach=True)` recovers a task only while ECS reports it as `RUNNING`. If the ECS task succeeds before Airflow retries, the retry cannot find it and calls `run_task()` again. The same workload can run twice. AIP-103 task state records the exact ECS task ARN. A retry now describes that task, recognizes terminal success, or resumes waiting for it. Missing and failed tasks still resubmit. Existing reattach, deferrable, logging, cancellation, XCom, and no-wait behavior remain unchanged. ## What changes were proposed in this pull request? Use `ResumableJobMixin` for synchronous ECS task execution and persist the task ARN before polling. Recovery reuses the operator's existing terminal status validation, including failed startup, nonzero exits, and skip exit codes. ## How was this patch tested? | Scenario | Result | | --- | --- | | Retry after the stored ECS task already succeeded | Fails before the patch because `run_task()` is called once; passes after the patch without a new submission | | ECS operator unit suite | 107 passed | <details> <summary>Raw retry-path evidence</summary> Against unmodified `upstream/main` with the regression test applied: ```console $ uv run --project providers/amazon pytest providers/amazon/tests/unit/amazon/aws/operators/test_ecs.py::TestEcsRunTaskOperator::test_retry_after_remote_success_does_not_submit_duplicate -xvs collected 1 item providers/amazon/tests/unit/amazon/aws/operators/test_ecs.py::TestEcsRunTaskOperator::test_retry_after_remote_success_does_not_submit_duplicate FAILED E assert 1 == 0 E + where 1 = <SuccessfulEcsTaskClient>.run_task_calls ======================== 1 failed, 1 warning in 41.53s ========================= pytest_exit=1 ``` On this branch: ```console $ uv run --project providers/amazon pytest providers/amazon/tests/unit/amazon/aws/operators/test_ecs.py::TestEcsRunTaskOperator::test_retry_after_remote_success_does_not_submit_duplicate -xvs collected 1 item providers/amazon/tests/unit/amazon/aws/operators/test_ecs.py::TestEcsRunTaskOperator::test_retry_after_remote_success_does_not_submit_duplicate PASSED ======================== 1 passed, 1 warning in 33.61s ========================= pytest_exit=0 $ uv run --project providers/amazon pytest providers/amazon/tests/unit/amazon/aws/operators/test_ecs.py -xvs ======================= 107 passed, 1 warning ======================= ``` </details> Static validation passed with Ruff, direct provider mypy, pre-commit, manual checks, and selective checks. Breeze-backed provider mypy was not run because Docker was unavailable. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation only ## Checklist - [x] My code follows the [style guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst) of this project. - [x] I have conducted a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have made corresponding changes to the documentation. - [x] My changes generate no new warnings. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. - [x] Any dependent changes have been merged and published in downstream modules. - [x] I have checked my code and corrected any misspellings. - [x] I have added the appropriate labels and release notes, if applicable. ## Release note needed? No. ## Was generative AI tooling used to co-author this pull request? - [x] Yes - GitHub Copilot CLI (GPT-5.6 Sol) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
