-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow attaching to previously launched task in ECSOperator #16685
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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
FYI @feluelle @o-nikolas @markhopson as you were involved in other PRs for this ECSOperator |
This flag doesn't seem like a good idea. I agree with the underlying issue this is trying to solve. A more abrupt approach would be forcing every ECS task to take the name |
Yes that makes sense, I will update 'reattach' logic directly then, I was not sure if it had an other user case I hadn't thought about. Unfortunately we can't define the ECS task_id from our side, it is a unique ID generated by Amazon (and if we could there would be problems with retries and clearing tasks anyway). |
I just made the change to 'reattach' instead @darwinyip |
cc @subashcanapathy If anyone in your team can review this, it would be great as it affects AWS Hooks |
@o-nikolas @ferruzzi Tagging for review |
Looks fine to me. I'm surprised there aren't existing helpers for xcom get/put. |
Thanks a lot for the review @ferruzzi @o-nikolas , I made the small changes you mentioned |
Thanks! I reviewed the latest commit, and it looks like there's one remaining line where you should be using the new constants. Let me know if I'm mistaken. |
@o-nikolas thanks for spotting that! There were 2 lines not using the constants yet indeed. Fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for the contribution :)
Can you rebase on latest main please @pmalafosse |
done @kaxil it's the first time I do that so I'm not sure I did it right |
You did it right :) -- let's wait for the CI to pass. |
Sorry there were some conflicts after the rebase that I hadn't fixed completely, fixed now (I ran pytest locally and it passed) @kaxil . |
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease. |
Awesome work, congrats on your first merged pull request! |
FYI @darwinyip
This PR adds a parameter reattach_prev_task to ECSOperator.
Before:
Until now we could use 'reattach' which was reattaching a running ECS Task (if there was one running) of the same 'family' instead of creating a new one. The problem was that if we had workflows using the same ECS Task Definition in several tasks, it didn't know which one to reattach and we could only use
concurrency=1
in some pipelines for example (when we launch the same ECS task in parallel from Airflow with different configurations).Now:
Now with reattach_prev_task instead, when we launch a new ECS task, it will store temporarily the ECS Task ARN in XCOM. If there is an issue during the run (typically connection problem between Airflow and ECS for long-running tasks or Airflow worker restarting which was then still running those tasks in the background without Airflow being aware of it):
I didn't change the logic of 'reattach' to do that directly because I didn't know if it had been designed for other use cases
Update 2021-07-01:
After discussing with @darwinyip I made the change to 'reattach' directly instead of creating a new flag