Repository navigation
[v3-4-test] Allow loop gates to add human-readable decisions (#74806) - #74932
Merged
Merged
Conversation
Member
Author
|
Based on top of #74931, should be automatically repointed when that gets merged to v3-4-test |
As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does. * Show loop decision reasons in the UI A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels. A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full. (cherry picked from commit 4c4bab0)
ashb
force-pushed
the
backport-74806-v3-4-test
branch
from
October 17, 2026 20:14
ac5c178 to
ebee2b9
Compare
ashb
marked this pull request as ready for review
October 17, 2026 20:17
ashb
requested review from
XD-DENG,
amoghrajesh,
bbovenzi,
bugraoz93,
choo121600,
ephraimbuddy,
guan404ming,
henry3260,
jason810496,
kaxil,
pierrejeambrun,
rawwar,
ryanahamilton,
shubhamraj-git and
vatsrahul1001
as code owners
October 17, 2026 20:17
Contributor
|
Hi maintainer, this PR was merged without a milestone set.
|
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
…#74932) As it landed on main, a loop's gate only recorded a go/no-go decision for the next iteration, meaning the UI could show that a loop stopped after N iterations, but a user would have to go to the logs to find out why, exactly, the loop ended when it did. This adds a `LoopDecision` object that lets an `until` callable include human-readable text to show alongside its decision. As well as introducing this new type, it also changes how the decision makes it to the server. Prior to this change, the decision was shipped to the API server via a specially named XCom value, in a normal SetXCom request, which was then read when the gate's TISuccessState request arrived. That "worked", but was inherently fragile: a separate write with its own locking, validation and cleanup on every non-success path. The decision now travels on the gate's terminal state update. The server acts on it in the transaction that marks the gate finished, so the stop/continue signal never needs storing. A gate that fails because until stayed false at max_iterations sends its reason with the failure, which is when an explanation helps most. Only the reason is persisted, as an XCom on the gate's attempt that the server writes in that same transaction. Keying it to the attempt means each try keeps its own reason, and a cleared or retried gate starts with none, so no clear path has to remember to delete a stale one. Task state was considered instead, but it is keyed by the iteration rather than the attempt, so a reason outlived the clears and tries it described, and clear_on_success and retention could remove it. The server writes the XCom directly to the metadata DB (not to a configured backend, so the UI can always show it), and the reserved `_airflow_loop_` prefix stops users and tasks forging it. The XCom list endpoint leaves those keys out when asked, which the UI does. * Show loop decision reasons in the UI A finished loop's page shows the reason its final iteration gave, and every task instance in an iteration shows that iteration's reason. The iteration pickers are left alone because their rows are one-line labels. A reason can run to 512 bytes over several lines, which pushed the header stats around, so the headers cut it to one line and the tooltip shows it in full. (cherry picked from commit 4c4bab0)
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.
As it landed on main, a loop's gate only recorded a go/no-go decision for
the next iteration, meaning the UI could show that a loop stopped after N
iterations, but a user would have to go to the logs to find out why,
exactly, the loop ended when it did.
This adds a
LoopDecisionobject that lets anuntilcallable includehuman-readable text to show alongside its decision.
As well as introducing this new type, it also changes how the decision
makes it to the server. Prior to this change, the decision was shipped to
the API server via a specially named XCom value, in a normal SetXCom
request, which was then read when the gate's TISuccessState request
arrived. That "worked", but was inherently fragile: a separate write
with its own locking, validation and cleanup on every non-success path.
The decision now travels on the gate's terminal state update. The server
acts on it in the transaction that marks the gate finished, so the
stop/continue signal never needs storing. A gate that fails because until
stayed false at max_iterations sends its reason with the failure, which is
when an explanation helps most.
Only the reason is persisted, as an XCom on the gate's attempt that the
server writes in that same transaction. Keying it to the attempt means
each try keeps its own reason, and a cleared or retried gate starts with
none, so no clear path has to remember to delete a stale one. Task state
was considered instead, but it is keyed by the iteration rather than the
attempt, so a reason outlived the clears and tries it described, and
clear_on_success and retention could remove it. The server writes the
XCom directly to the metadata DB (not to a configured backend, so the UI
can always show it), and the reserved
_airflow_loop_prefix stops usersand tasks forging it. The XCom list endpoint leaves those keys out when
asked, which the UI does.
A finished loop's page shows the reason its final iteration gave, and every
task instance in an iteration shows that iteration's reason. The iteration
pickers are left alone because their rows are one-line labels.
A reason can run to 512 bytes over several lines, which pushed the header
stats around, so the headers cut it to one line and the tooltip shows it
in full.
(cherry picked from commit 4c4bab0)
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.