Fix AWS Batch Executor compatibility with Airflow 3 in try_adopt_task_instances#68027
Open
ambaena wants to merge 3 commits into
Open
Fix AWS Batch Executor compatibility with Airflow 3 in try_adopt_task_instances#68027ambaena wants to merge 3 commits into
try_adopt_task_instances#68027ambaena wants to merge 3 commits into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
Author
|
Fixed the test failure caused by Python 3.10 compatibility. |
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.
Related: #62192
The AWS Batch Executor still calls
TaskInstance.command_as_list()fromtry_adopt_task_instances(). That method is not available in Airflow 3 after the Task SDK changes.This is triggered when the scheduler restarts or fails over and tries to adopt orphaned task instances that still have an
external_executor_idpointing to an AWS Batch job. The scheduler callsadopt_or_reset_orphaned_tasks(), the Batch executor describes the existing Batch jobs, and then crashes while rebuilding the command for the adopted task instance:AttributeError: TaskInstance object has no attribute command_as_listThe normal submission path already handles Task SDK workloads. This change makes the adoption path use the same Task SDK command serialization on Airflow 3 while keeping the existing
command_as_list()behavior for Airflow 2.This mirrors the ECS executor fix from #62192 for the AWS Batch executor.
Testing:
prek run --files providers/amazon/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.pyuv run --project providers/amazon pytest providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor.py -k "try_adopt_task_instances or serialize_workload_to_command or build_task_command" -xvsDisclosure: I used an AI assistant to help investigate the failure mode and cross-check the proposed fix. I reviewed the final code and tests myself.