sjyangkevin commented on code in PR #74528:
URL: https://github.com/apache/airflow/pull/74528#discussion_r4504388427
##########
providers/standard/src/airflow/providers/standard/sensors/external_task.py:
##########
@@ -378,16 +392,34 @@ def _get_count(states: list[str]) -> int:
if self.failed_states:
count = _get_count(self.failed_states)
count_failed = self._calculate_count(count, dttm_filter)
+ if count_failed > 0:
+ self._push_external_run_ids(context, dttm_filter)
self._handle_failed_states(count_failed)
if self.skipped_states:
count = _get_count(self.skipped_states)
count_skipped = self._calculate_count(count, dttm_filter)
+ if count_skipped > 0:
+ self._push_external_run_ids(context, dttm_filter)
self._handle_skipped_states(count_skipped)
count = _get_count(self.allowed_states)
count_allowed = self._calculate_count(count, dttm_filter)
- return count_allowed == len(dttm_filter)
+ if count_allowed != len(dttm_filter):
+ return False
+ self._push_external_run_ids(context, dttm_filter)
+ return True
+
+ def _push_external_run_ids(self, context: Context, dttm_filter:
Sequence[datetime.datetime]) -> None:
Review Comment:
Thanks for catching it. Updated `_push_external_run_ids` to wrap the
`get_task_states` call and the XCom push in a try/catch block. So, failure
there won't impact the task's outcome. `get_link` then falls back to the
external Dag page. I added tests where `get_task_states` raises: in `poke()`
they check soft-fail still skips, skipped still skips and success still returns
`True`, and in `execute_complete` they cover each event status.
--
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]