Skip to content

Fix EcsRunTaskOperator deferred logs read from the wrong region - #70474

Merged
shahar1 merged 1 commit into
apache:mainfrom
ColtenOuO:fix-ecs-trigger-awslogs-region
Jul 27, 2026
Merged

Fix EcsRunTaskOperator deferred logs read from the wrong region#70474
shahar1 merged 1 commit into
apache:mainfrom
ColtenOuO:fix-ecs-trigger-awslogs-region

Conversation

@ColtenOuO

Copy link
Copy Markdown
Contributor

When EcsRunTaskOperator runs with deferrable=True and the task definition ships its container logs to a different region than the one the task runs in (awslogs_region != region_name), no logs are forwarded during deferral -- the trigger just repeats "Tried to get logs from stream ... but it didn't exist (yet)" for the whole task duration.

TaskDoneTrigger was given a single region_name and used it for two different clients: the ECS waiter (correct) and the CloudWatch get_log_events client (wrong -- the log group lives in the other region).

The operator never passed the logs region to the trigger, so the trigger had no way to tell them apart.

This adds a log_region_name parameter to TaskDoneTrigger, used only for the AwsLogsHook, and has the operator pass resolve_awslogs_region() when deferring. The EcsHook keeps using region_name.

The parameter defaults to None and falls back to region_name, so triggers that were already serialized before this change deserialize without the key and keep their current behaviour.

This is the remaining half of the log-region resolution: #70464 fixed the post-deferral fetch in execute_complete, and the non-deferrable path already used resolve_awslogs_region() via _get_task_log_fetcher().

closes: #70465


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5) for writing Tests

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I just have one comment but its minor.

Comment thread providers/amazon/src/airflow/providers/amazon/aws/triggers/ecs.py Outdated
TaskDoneTrigger received a single region_name and used it to build both the
ECS waiter client and the CloudWatch client, so a task definition shipping
its logs to a different region got no logs forwarded while the task was
deferred -- only repeated "didn't exist (yet)" messages for the whole run.
The non-deferrable path and the post-deferral fetch already resolve
awslogs_region; this brings the in-deferral forwarding in line with them.

closes: apache#70465
@ColtenOuO
ColtenOuO force-pushed the fix-ecs-trigger-awslogs-region branch from 0aa13df to 92ff382 Compare July 27, 2026 01:08
@eladkal
eladkal requested review from ferruzzi and vincbeck July 27, 2026 08:15
@shahar1
shahar1 merged commit 0f2827e into apache:main Jul 27, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EcsRunTaskOperator deferrable mode fetches CloudWatch logs from wrong region when awslogs_region differs from region_name

3 participants