Skip to content

Fix remote logging connection caching in Task SDK#68379

Closed
anshuman0123 wants to merge 2 commits into
apache:mainfrom
anshuman0123:remote-logging-fix
Closed

Fix remote logging connection caching in Task SDK#68379
anshuman0123 wants to merge 2 commits into
apache:mainfrom
anshuman0123:remote-logging-fix

Conversation

@anshuman0123

Copy link
Copy Markdown

Summary

  • Fix remote logging connection caching in Task SDK to resolve regression in Airflow 3.2.2.
  • Prevent caching of None results for connection lookups in the supervisor.

Details

In the new two-token execution mechanism, a worker starts with a workload-scoped token which lacks permission to access connections. The connection preloading logic attempts to fetch connections, receives None, and was previously caching this empty result. Later, when the task runs and the worker's token is upgraded to an execution-scoped token (which has connection access), the system continued to use the cached None value, preventing hooks from finding the necessary credentials.

The fix modifies _fetch_remote_logging_conn in task-sdk/src/airflow/sdk/execution_time/supervisor.py to only cache truthy connection results. By not caching None, the worker is forced to re-attempt the connection lookup later (e.g., during log upload) when it has the correct token scope, allowing it to successfully retrieve the connection details.

Testing

  • Verified that _fetch_remote_logging_conn no longer caches None values when lookups fail.
  • Verified that subsequent lookups successfully re-attempt connection retrieval.

Fixes: #68366

The _fetch_remote_logging_conn function in the supervisor was caching
None results when a connection lookup failed. In the two-token
execution model, an initial lookup with a restricted token might fail,
and caching this None result prevented subsequent lookups with an
execution token from succeeding.

This change ensures that only successful connection lookups are cached,
allowing for retries when a better token becomes available.

Fixes: apache#68366

@ashb ashb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whoops, good catch!

@ashb ashb added this to the Airflow 3.3.0 milestone Jun 11, 2026
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Jun 11, 2026
@ashb

ashb commented Jun 11, 2026

Copy link
Copy Markdown
Member

Duplicate of #68370

@ashb ashb marked this as a duplicate of #68370 Jun 11, 2026
@ashb ashb closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote logging not working in Airflow 3.2.2

4 participants