Skip to content

Fix KubernetesPodOperator dry_run requiring live Kubernetes API client#70234

Open
Aaryan123456679 wants to merge 1 commit into
apache:mainfrom
Aaryan123456679:fix/kpo-dry-run-kube-client-45812
Open

Fix KubernetesPodOperator dry_run requiring live Kubernetes API client#70234
Aaryan123456679 wants to merge 1 commit into
apache:mainfrom
Aaryan123456679:fix/kpo-dry-run-kube-client-45812

Conversation

@Aaryan123456679

Copy link
Copy Markdown
Contributor

airflow dags test (and calling KubernetesPodOperator.dry_run() directly) failed outside a real cluster because build_pod_request_obj() unconditionally read hook.is_in_cluster to set the airflow_kpo_in_cluster label. That property instantiates a Kubernetes API client, which requires kube credentials/config to be available — something a dry run must not need.

This adds a keyword-only dry_run parameter to build_pod_request_obj() (default False, so existing callers are unaffected) and has dry_run() skip the is_in_cluster lookup when set.

closes: #45812

@Miretpl

Miretpl commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

There are couple of unrelated changes in the PR + conflics - could you resolve it?

@Aaryan123456679
Aaryan123456679 force-pushed the fix/kpo-dry-run-kube-client-45812 branch from e540c09 to e91dc6e Compare July 24, 2026 16:08
@Aaryan123456679

Copy link
Copy Markdown
Contributor Author

Thanks for flagging this. The branch had two extra commits that were unrelated to this fix (a check_provider_yaml_files.py namespaced-provider crash fix and a Jira provider.yaml conn-field fix) — those were already merged into main separately via #70224 and #70261, which is what caused the conflicts. I dropped both commits and rebased the actual KubernetesPodOperator dry_run fix cleanly onto latest main. The branch now only contains the two files relevant to this PR (pod.py and its test) and is mergeable.

airflow dags test and dry_run() failed outside a cluster because
build_pod_request_obj() unconditionally read hook.is_in_cluster to
set the airflow_kpo_in_cluster label, which instantiates a Kubernetes
API client and requires kube credentials/config to be available. A
dry run should not need cluster access at all.

closes: apache#45812
@Aaryan123456679
Aaryan123456679 force-pushed the fix/kpo-dry-run-kube-client-45812 branch from e91dc6e to 910515b Compare July 24, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KubernetesPodOperator dry_run failure

2 participants