kaxil commented on code in PR #76833:
URL: https://github.com/apache/airflow/pull/76833#discussion_r4647215751
##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -132,12 +151,31 @@ def execute_resumable(self, context: Context) -> Any:
decision = self.get_resume_decision(context)
if decision.action == "reconnect":
- return self.poll_until_complete(decision.external_id, context)
+ self._record_try(context, DurableDecision.RECONNECTED,
decision.external_id, status="running")
+ try:
+ result = self.poll_until_complete(decision.external_id,
context)
+ except Exception:
+ self._record_try(context, DurableDecision.RECONNECTED,
decision.external_id, status="failed")
Review Comment:
A wait timeout also lands here while the job is still running (ADF's
`wait_for_pipeline_run_status` raises once `timeout` passes), so the banner
says the job failed and the next try reconnects to that same job. Could this
check `get_job_status` and only record `failed` when the job is terminal and
not succeeded?
##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -132,12 +151,31 @@ def execute_resumable(self, context: Context) -> Any:
decision = self.get_resume_decision(context)
if decision.action == "reconnect":
- return self.poll_until_complete(decision.external_id, context)
+ self._record_try(context, DurableDecision.RECONNECTED,
decision.external_id, status="running")
Review Comment:
This `running` entry is only finalized by `except Exception` or after the
poll returns, so a poll that defers never updates it. PowerBI with the default
`wait_for_completion=True` always defers here and its `execute_complete`
doesn't touch the record, so once the task succeeds the banner still says it is
waiting on the running job; `AirflowTaskTimeout` and a killed worker leave it
the same way. Could the banner treat `running` as unknown once the viewed try
has ended, and the deferring operators record the outcome from
`execute_complete`?
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -3600,7 +3600,8 @@ state_store:
operators and the UI can inspect what the task wrote (e.g. submitted
job IDs,
advanced watermarks) after the run completes.
Consider setting to True if you do not need post-success visibility
and want automatic
- cleanup without waiting for the global retention period.
+ cleanup without waiting for the global retention period. This also
removes the durable
+ execution banner from the logs of succeeded tries.
Review Comment:
The clear on success wipes the whole task scope, so with this on every try
of that task instance loses its banner, not only the succeeded ones.
##########
devel-common/src/tests_common/test_utils/task_state.py:
##########
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from unittest import mock
+
+RESERVED_KEY_PREFIX = "__airflow_"
+
+
+def get_non_reserved_task_state_writes(task_state_store: mock.Mock) ->
list[mock._Call]:
+ """
+ Return the ``set`` calls an operator made on a mocked task state store.
+
+ From Airflow 3.3 the durable execution mixin also writes ``__airflow_``
keys for the logs banner,
Review Comment:
The mixin starts writing these keys in this PR, so this is Airflow 3.5 (Task
SDK 1.5) rather than 3.3.
##########
task-sdk/src/airflow/sdk/bases/resumablejobmixin.py:
##########
@@ -132,12 +151,31 @@ def execute_resumable(self, context: Context) -> Any:
decision = self.get_resume_decision(context)
if decision.action == "reconnect":
- return self.poll_until_complete(decision.external_id, context)
+ self._record_try(context, DurableDecision.RECONNECTED,
decision.external_id, status="running")
+ try:
+ result = self.poll_until_complete(decision.external_id,
context)
+ except Exception:
+ self._record_try(context, DurableDecision.RECONNECTED,
decision.external_id, status="failed")
+ raise
+ self._record_reconnect_outcome(context, decision.external_id)
+ return result
if decision.action == "already_succeeded":
+ self._record_try(
+ context, DurableDecision.ALREADY_SUCCEEDED,
decision.external_id, status="success"
Review Comment:
Nothing in `TestDurableRecord` checks the record an `already_succeeded` try
writes (its `success` status, and that it gets no `saved_seconds`). Can we add
one?
--
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]