-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Fix KubernetesPodOperator deferrable mode with env-defined connection (#41706)
#58841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
romsharon98
merged 6 commits into
apache:main
from
nailo2c:bug-41706-k8s-conn-id_defined_via_env_var_failed_when_defer
Dec 16, 2025
Merged
Fix KubernetesPodOperator deferrable mode with env-defined connection (#41706)
#58841
romsharon98
merged 6 commits into
apache:main
from
nailo2c:bug-41706-k8s-conn-id_defined_via_env_var_failed_when_defer
Dec 16, 2025
Conversation
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
Nataneljpwd
reviewed
Nov 30, 2025
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit picks, looks very good.
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py
Outdated
Show resolved
Hide resolved
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py
Outdated
Show resolved
Hide resolved
…bernetes hooks and operators
…ubernetesPodOperator
Contributor
Author
|
All the conflicts are resolved. If there is anything that can be improved, please don't hesitate to let me know :D |
romsharon98
approved these changes
Dec 16, 2025
FoxHelms
pushed a commit
to FoxHelms/airflow
that referenced
this pull request
Dec 17, 2025
…on (apache#41706) (apache#58841) * Fix AsyncKubernetesHook when Kubernetes connection is missing (apache#41706) * fix CI error * fix CI error apache#2 * Rename `conn_extras` to `connection_extras` for consistency across Kubernetes hooks and operators * Handle AirflowNotFoundException when resolving connection extras in KubernetesPodOperator
Lohith625
pushed a commit
to Lohith625/airflow
that referenced
this pull request
Dec 19, 2025
…on (apache#41706) (apache#58841) * Fix AsyncKubernetesHook when Kubernetes connection is missing (apache#41706) * fix CI error * fix CI error apache#2 * Rename `conn_extras` to `connection_extras` for consistency across Kubernetes hooks and operators * Handle AirflowNotFoundException when resolving connection extras in KubernetesPodOperator
TempestShaw
pushed a commit
to TempestShaw/airflow
that referenced
this pull request
Dec 24, 2025
…on (apache#41706) (apache#58841) * Fix AsyncKubernetesHook when Kubernetes connection is missing (apache#41706) * fix CI error * fix CI error apache#2 * Rename `conn_extras` to `connection_extras` for consistency across Kubernetes hooks and operators * Handle AirflowNotFoundException when resolving connection extras in KubernetesPodOperator
54 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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: #41706
Why
When users define
k8s-conn-idvia environment variables (e.g.,AIRFLOW_CONN_...) and setdeferrable=TrueinKubernetesPodOperator, the following exception occurs in the Triggerer:AirflowNotFoundException: The conn_id `k8s-conn-id` isn't definedThis happens because the environment variable defining the connection exists in the Worker (where the task starts) but is missing in the Triggerer service (where the task is deferred). The Triggerer attempts to look up the connection ID but fails to find it.
How
This PR resolves the issue by resolving the connection details in the Worker before deferral and passing them explicitly to the Triggerer.
KubernetesPodOperator, resolved the connection object in the execute phase (Worker) and extracted the connection extras.connection_extrasparameter toKubernetesPodTriggerto accept the resolved connection information.AsyncKubernetesHookto acceptconnection_extras. If provided, the hook uses these extras directly instead of attempting to look up the connection ID from the database or environment variables.What
I used the following DAG to reproduce the issue and verify the fix in the breeze k8s environment:
Before the fix, we can see the following error in the Airflow logs:
After the fix, we can see the new log we added in the Triggerer logs, and this error log no longer appears.