Decouple workload JWT token lifetime from task_queued_timeout - #72488
Open
Kunal8954 wants to merge 1 commit into
Open
Decouple workload JWT token lifetime from task_queued_timeout#72488Kunal8954 wants to merge 1 commit into
Kunal8954 wants to merge 1 commit into
Conversation
The workload token minted for a queued task (or callback) had its lifetime hardcoded to [scheduler] task_queued_timeout. This coupled two unrelated concerns: how long a task can authenticate to the Execution API while queued, and how long the scheduler waits before reaping a queued task as orphaned. Raising one to tolerate queue backlog silently weakened the other. Adds [execution_api] workload_token_expiration_time as an independent, optional setting. When unset it falls back to task_queued_timeout, preserving current behavior for existing deployments; operators who want to decouple the two can now set it explicitly. Fixes apache#72469 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh
Kunal8954
requested review from
XD-DENG,
ashb,
dheerajturaga,
hussein-awala,
o-nikolas and
pierrejeambrun
as code owners
September 3, 2026 14:58
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.
What
Adds a new, optional
[execution_api] workload_token_expiration_timeconfig option that controls how long a workload's JWT token (minted
when a task instance or callback is queued for an executor) stays
valid, independently of
[scheduler] task_queued_timeout.Why
Today,
BaseWorkloadSchema.generate_token()hardcodes the workloadtoken's lifetime to
[scheduler] task_queued_timeout. That value hasa second, unrelated job: it's also how long a task can sit in the
queuedstate before the scheduler's orphan-detection sweep reaps it.This forces operators into an uncomfortable tradeoff: raising
task_queued_timeoutto tolerate a longer queue backlog (e.g. underheavy load, or with a slow-starting KubernetesExecutor) also silently
extends how long a genuinely stuck task goes undetected - the exact
scenario in #72469, where a scheduler crash mid-dispatch left tasks
stuck in
queuedfor up to 10 hours before being reaped, becausetask_queued_timeouthad been raised for legitimate queue-waitreasons.
Design
[execution_api] workload_token_expiration_time(float, seconds, default unset).
_workload_token_valid_for()falls back to[scheduler] task_queued_timeout- existing deployments see nobehavior change unless they opt in.
task_queued_timeoutis no longerconsulted for token lifetime (only for its original orphan-detection
purpose).
hardcoded default (e.g.
600): if it defaulted to something shorterthan an operator's already-customized
task_queued_timeout, alegitimately-queued task's auth token could expire before the
scheduler's own orphan sweep fires, breaking task execution for
people who'd raised
task_queued_timeoutwithout knowing about thisnew option. Falling back preserves current behavior by construction.
Changes
airflow-core/src/airflow/executors/workloads/base.py: extracted_workload_token_valid_for()implementing the fallback logic usedby
generate_token()(inherited byExecuteTask,ExecuteCallback,and the connection-test workload).
airflow-core/src/airflow/config_templates/config.yml: added thenew option under
[execution_api], and cross-referenced it from[scheduler] task_queued_timeout's description.airflow-core/tests/unit/executors/test_workloads.pycovering both the fallback and the override path, plus an end-to-end
token-decoding test.
Fixes #72469
Gen-AI disclosure: used Claude Code (Anthropic) to investigate the
existing coupling, implement the change, write tests, and draft this
description.
🤖 Generated with Claude Code
https://claude.ai/code/session_015kAvbZ6SeKgp6jbGcvpXSh