Repository navigation
Show a deferred task's trigger logs from CloudWatch, OSS and HDFS after it finishes - #76631
Open
seanghaeli wants to merge 1 commit into
Open
seanghaeli wants to merge 1 commit into
seanghaeli wants to merge 1 commit into
Conversation
seanghaeli
force-pushed
the
ghaeli/to8-cloudwatch-trigger-log-streams
branch
2 times, most recently
from
November 12, 2026 22:48
d437819 to
3bfd939
Compare
seanghaeli
force-pushed
the
ghaeli/to8-cloudwatch-trigger-log-streams
branch
2 times, most recently
from
November 18, 2026 01:12
608abef to
12322d6
Compare
1 task done
seanghaeli
force-pushed
the
ghaeli/to8-cloudwatch-trigger-log-streams
branch
from
November 20, 2026 23:56
12322d6 to
32109b7
Compare
seanghaeli
marked this pull request as ready for review
November 21, 2026 06:14
…er it finishes A deferred task's triggerer stores its log beside the task log, as <task log>.trigger.<triggerer job id>.log, but the CloudWatch, OSS and HDFS readers read only the task log itself. Once the task left DEFERRED (no more live read from the triggerer), its trigger lines vanished from the UI, even though they were stored. Read every stream, object or file the path is a prefix of, as the S3, GCS and WASB readers already do. The same read shows an asset watcher's history on CloudWatch, which keeps one stream per triggerer that ran it. CloudWatch: while the task is deferred, skip the current triggerer's stream, which the task log reader reads live. A path ending in "/" with no stream under it has no logs, rather than a "No log stream found" notice as its one line, and one that can't be listed raises, as the S3 reader does. Listing needs logs:DescribeLogStreams, which the docs now say; without it a task log falls back to its exact stream. OSS and HDFS: if listing fails, read the task log alone, as before. OSS gets OSSHook.list_keys; listing needs oss:ListObjects, which the docs now say. CloudWatch also reads a stream from its end when asked for its last lines (stream(..., tail_lines=N)), so the trigger logs endpoint no longer reads a long-running watcher's stream from its head. A trigger_log_group_arn in remote_task_handler_kwargs sends a trigger's own logs, under triggers/trigger_id=<id>/, to their own log group. CloudWatch no longer drops lines while it opens a stream. watchtower creates a stream only once a put to it fails, and meanwhile its handler, which serves every stream of a process, drops every thread's lines. A new stream is now created before its first put, backing off on throttling, so a triggerer opening many streams at once no longer loses batches either. An upload flushes only its own stream, so it no longer waits on streams still being created, nor fails with "dictionary changed size during iteration" when another thread opens a stream. HDFS also reads the files under a matching directory, such as the rotated/ parts of an asset watcher's log, instead of failing on the directory. closes: apache#70317
seanghaeli
force-pushed
the
ghaeli/to8-cloudwatch-trigger-log-streams
branch
from
November 21, 2026 06:23
32109b7 to
c3e6bdd
Compare
o-nikolas
reviewed
Nov 24, 2026
o-nikolas
left a comment
Contributor
There was a problem hiding this comment.
@amoghrajesh Maybe you want to look at this one too?
| The trigger of a deferred task writes to its own log stream, and Airflow finds it by listing the streams that | ||
| start with the task's log name. Without the permission, Airflow reads the task's own stream alone. | ||
|
|
||
| On Airflow versions that write asset watcher logs, a watcher's logs go under ``triggers/trigger_id=<id>/``. |
Contributor
There was a problem hiding this comment.
nit: "On Airflow versions that write asset watcher logs" is hard to act on for a reader. Could this name the version, e.g. "From Airflow 3.5.0" (assuming #76527 ships there)?
| if not self.shutting_down: | ||
| self._send_queued(list(self.queues.items()), self.FLUSH) | ||
|
|
||
| def close(self) -> None: |
Contributor
There was a problem hiding this comment.
nit: watchtower's own close() warns "Timed out while delivering logs" when a queue still holds records after the wait. This override drops that, and it now skips streams still being created on purpose, so lines lost at shutdown go unreported. Could we keep a warning for queues that aren't empty here?
This branch has not been deployed
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.
closes: #70317
This PR makes CloudWatch, OSS and HDFS remote logging work for trigger logs:
<task log>.trigger.<triggerer job id>.log), and these readers only fetched the task log itself, meaning the trigger lines disappeared from the UI once the task finished. They now read every file starting with its name.trigger_log_group_arnin[logging] remote_task_handler_kwargssends asset watchers' own logs to a separate CloudWatch log group.Reading needs
logs:DescribeLogStreamson CloudWatch andoss:ListObjectson OSS, now in the docs. Without them, each reads the task log alone, as before.Tested on Breeze with CloudWatch: after a deferred task finished, main showed none of its trigger lines and this PR shows all of them, including across a triggerer restart, with no duplicates.
This picks up the read-side approach from #70635 by @bujjibabukatta, which closed as stale.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines