You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "arorasachin9 (via GitHub)" <gi...@apache.org> on 2026/01/15 13:47:51 UTC

[PR] Handling the job cancel in case of timeouts [airflow]

arorasachin9 opened a new pull request, #60588:
URL: https://github.com/apache/airflow/pull/60588

   Resolves https://github.com/apache/airflow/issues/60517
   The timeouts for the deferred operators are not handled properly. This fixes the by implementing the cleanup method.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2698969749


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -159,3 +161,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
                 self.status_queries,
             )
             yield TriggerEvent({"status": "success", self.return_key: self.return_value})
+
+    async def cancel(self):

Review Comment:
   Should it be called `cleanup` then?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "arorasachin9 (via GitHub)" <gi...@apache.org>.
arorasachin9 commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2694868359


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -84,6 +84,7 @@ def __init__(
         region_name: str | None = None,
         verify: bool | str | None = None,
         botocore_config: dict | None = None,
+        cancel_waiter_names: list[str] | None = None,

Review Comment:
   I am waiting for the high level approval for the approach from @vincbeck . Once I get go ahead with the approach then I'll add UT's and the doc string also.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2694796007


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -84,6 +84,7 @@ def __init__(
         region_name: str | None = None,
         verify: bool | str | None = None,
         botocore_config: dict | None = None,
+        cancel_waiter_names: list[str] | None = None,

Review Comment:
   Can you add the corresponding docstring for this parameter?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #60588:
URL: https://github.com/apache/airflow/pull/60588#issuecomment-3987821720

   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "arorasachin9 (via GitHub)" <gi...@apache.org>.
arorasachin9 commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2699096491


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -159,3 +161,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
                 self.status_queries,
             )
             yield TriggerEvent({"status": "success", self.return_key: self.return_value})
+
+    async def cancel(self):

Review Comment:
   @vincbeck Changed it to cleanup. Let me know if approach wise this is correct then I can go ahead with a proper PR with docs and UT's for the same.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2699212239


##########
providers/amazon/src/airflow/providers/amazon/aws/waiters/emr-containers.json:
##########
@@ -25,6 +25,18 @@
                     "state": "failure"
                 }
             ]
+        },
+        "container_job_cancel": {
+            "operation": "CancelJobRun",

Review Comment:
   As far as I understand, this should not be a waiter. A waiter is usually a get method and you need to wait for that response to reach a given state. Here this is an operation, you do not need to call it multiple times



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "arorasachin9 (via GitHub)" <gi...@apache.org>.
arorasachin9 commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2696758697


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -159,3 +161,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
                 self.status_queries,
             )
             yield TriggerEvent({"status": "success", self.return_key: self.return_value})
+
+    async def cancel(self):

Review Comment:
   @vincbeck ,
   This function is the function defined in the baseTrigger class.
   ```
       async def cleanup(self) -> None:
           """
           Cleanup the trigger.
   
           Called when the trigger is no longer needed, and it's being removed
           from the active triggerer process.
   
           This method follows the async/await pattern to allow to run the cleanup
           in triggerer main event loop. Exceptions raised by the cleanup method
           are ignored, so if you would like to be able to debug them and be notified
           that cleanup method failed, you should wrap your code with try/except block
           and handle it appropriately (in async-compatible way).
           """
   ```
   And this cleanup function is called in the finally block of the runner function of trigerrer
   ```
   async def run_trigger(self, trigger_id: int, trigger: BaseTrigger, timeout_after: datetime | None = None):
           """Run a trigger (they are async generators) and push their events into our outbound event deque."""
           if not os.environ.get("AIRFLOW_DISABLE_GREENBACK_PORTAL", "").lower() == "true":
               import greenback
   
               await greenback.ensure_portal()
   
           bind_log_contextvars(trigger_id=trigger_id)
   
           name = self.triggers[trigger_id]["name"]
           self.log.info("trigger %s starting", name)
           try:
               async for event in trigger.run():
                   await self.log.ainfo(
                       "Trigger fired event", name=self.triggers[trigger_id]["name"], result=event
                   )
                   self.triggers[trigger_id]["events"] += 1
                   self.events.append((trigger_id, event))
           except asyncio.CancelledError:
               # We get cancelled by the scheduler changing the task state. But if we do lets give a nice error
               # message about it
               if timeout := timeout_after:
                   timeout = timeout.replace(tzinfo=timezone.utc) if not timeout.tzinfo else timeout
                   if timeout < timezone.utcnow():
                       await self.log.aerror("Trigger cancelled due to timeout")
               raise
           finally:
               # CancelledError will get injected when we're stopped - which is
               # fine, the cleanup process will understand that, but we want to
               # allow triggers a chance to cleanup, either in that case or if
               # they exit cleanly. Exception from cleanup methods are ignored.
               with suppress(Exception):
                   await trigger.cleanup()
   
               await self.log.ainfo("trigger completed", name=name)
   ```



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2694903269


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -159,3 +161,25 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
                 self.status_queries,
             )
             yield TriggerEvent({"status": "success", self.return_key: self.return_value})
+
+    async def cancel(self):

Review Comment:
   Where is it being called?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "arorasachin9 (via GitHub)" <gi...@apache.org>.
arorasachin9 commented on code in PR #60588:
URL: https://github.com/apache/airflow/pull/60588#discussion_r2694871613


##########
providers/amazon/src/airflow/providers/amazon/aws/triggers/base.py:
##########
@@ -84,6 +84,7 @@ def __init__(
         region_name: str | None = None,
         verify: bool | str | None = None,
         botocore_config: dict | None = None,
+        cancel_waiter_names: list[str] | None = None,

Review Comment:
   Sorry forgot to change the PR to draft



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Handling the job cancel in case of timeouts [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #60588: Handling the job cancel in case of timeouts
URL: https://github.com/apache/airflow/pull/60588


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org