Skip to content

Wait for Job pods before failing KubernetesJobOperator discovery - #70636

Open
cipheraxat wants to merge 2 commits into
apache:mainfrom
cipheraxat:fix/70585-k8s-job-wait-for-pods
Open

Wait for Job pods before failing KubernetesJobOperator discovery#70636
cipheraxat wants to merge 2 commits into
apache:mainfrom
cipheraxat:fix/70585-k8s-job-wait-for-pods

Conversation

@cipheraxat

Copy link
Copy Markdown

KubernetesJobOperator.get_pods() used to hammer list_namespaced_pod a few times with no delay, then fail if the Job controller had not created pods yet. In practice that race marks the task failed while the Job still runs to success, and a retry can start a second Job.

This change waits up to schedule_timeout_seconds, polling every startup_check_interval_seconds (both already inherited from KubernetesPodOperator). The first probe stays immediate. Discovery also stops once len(pods) >= parallelism, and discover_pods_retry_number is deprecated as a no-op.

closes: #70585


Was generative AI tooling used to co-author this PR?
  • Yes — Cursor Grok 4.5

Generated-by: Cursor Grok 4.5 following the guidelines

@boring-cyborg boring-cyborg Bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Jul 28, 2026
Comment on lines +157 to +160
# Kept for backward compatibility with code that reads the attribute.
self.discover_pods_retry_number = (
discover_pods_retry_number if discover_pods_retry_number is not None else 3
)

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.

AFAICS there is no code that reads discover_pods_retry_number when this fix is applied.

@cipheraxat cipheraxat Jul 29, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed the unused self.discover_pods_retry_number assignment. The kwarg is still accepted and emits the deprecation warning; the test now only asserts that warning. Also rebased onto latest main.

The Job controller can take longer than a few immediate list calls to
create pods. Failing immediately marked tasks failed while the Job still
succeeded, and retries risked starting a second Job.
The parameter remains accepted with a deprecation warning, but nothing
reads the attribute after discovery switched to schedule_timeout polling.
@cipheraxat
cipheraxat force-pushed the fix/70585-k8s-job-wait-for-pods branch from 9c82952 to 3b2dc06 Compare July 29, 2026 08:32
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.

KubernetesJobOperator.get_pods() fails the task instead of waiting for the Job controller to create pods

2 participants