Skip to content

[v3-2-test] KPO: treat registry 5xx errors as transient during pod startup (#65490)#66170

Merged
potiuk merged 1 commit into
apache:v3-2-testfrom
potiuk:backport-938ccf3-v3-2-test
Apr 30, 2026
Merged

[v3-2-test] KPO: treat registry 5xx errors as transient during pod startup (#65490)#66170
potiuk merged 1 commit into
apache:v3-2-testfrom
potiuk:backport-938ccf3-v3-2-test

Conversation

@potiuk

@potiuk potiuk commented Apr 30, 2026

Copy link
Copy Markdown
Member

Backport of #65490 to v3-2-test.

The fix landed on main on April 19 but was never backported. It was
needed in the wild today: the v3-2-test K8s system-test job
K8S System:CeleryExecutor-3.10-v1.30.13-false
hit test_pod_affinity[backcompat] failing with exactly this class of
error — Docker Hub returned a 502 Bad Gateway pulling
docker.io/library/ubuntu:latest, and detect_pod_terminate_early_issues()
on v3-2-test doesn't yet recognise bad gateway as transient, so it
aborted the pod before kubelet's next retry.

Original commit message:

When a pod is starting, kubelet automatically retries failed image pulls
with exponential backoff. KubernetesPodOperator monitors the pod via
detect_pod_terminate_early_issues() and aborts early on what it deems
a fatal pull error — but the transient-error pattern list did not cover
registry 5xx / gateway outages. A short Docker Hub outage (502/503/504
from auth.docker.io or the registry) was being classified as fatal
and would abort the pod before kubelet's next retry, even though the
pull would have succeeded once upstream recovered.

Add `bad gateway`, `service unavailable`, `gateway timeout` to
`TRANSIENT_ERROR_PATTERNS` so these conditions let kubelet keep
retrying within the caller's `startup_timeout` budget.

Cherry-pick conflict was a single trivial import (_parse_log_level
doesn't exist on v3-2-test), resolved by keeping only the
detect_pod_terminate_early_issues import that the new tests need. All
11 affected unit tests pass locally, including the
[ErrImagePull-rpc error: 502 Bad Gateway from auth.docker.io] case
that mirrors the failing CI run.

(cherry picked from commit 938ccf3)


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

…e#65490)

When a pod is starting, kubelet automatically retries failed image pulls
with exponential backoff. `KubernetesPodOperator` monitors the pod via
`detect_pod_terminate_early_issues()` and aborts early on what it deems a
fatal pull error — but the transient-error pattern list did not cover
registry 5xx / gateway outages. A short Docker Hub outage (502/503/504
from `auth.docker.io` or the registry) was being classified as fatal and
would abort the pod before kubelet's next retry, even though the pull
would have succeeded once upstream recovered.

Add `bad gateway`, `service unavailable`, `gateway timeout` to
`TRANSIENT_ERROR_PATTERNS` so these conditions let kubelet keep retrying
within the caller's `startup_timeout` budget.

On kubelet >= 1.32 the `ImagePullBackOff` message is
`Back-off pulling image "X": <prev_error>`, so these patterns also match
during the backoff state. On older kubelets the bare message carries no
detail and we keep the existing fail-fast behaviour — matching
`back-off pulling` unconditionally would have caused a 120s wait for a
genuinely missing image instead of an immediate error (thanks Jens for
catching this).

`startup_timeout` still bounds the overall wait, and genuinely fatal pull
errors (`InvalidImageName`, `ErrImageNeverPull`, `manifest unknown`,
`unauthorized`, …) remain fatal.

(cherry picked from commit 938ccf3)
@boring-cyborg boring-cyborg Bot added area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues labels Apr 30, 2026
@potiuk
potiuk merged commit 53717ec into apache:v3-2-test Apr 30, 2026
7 checks passed
@potiuk
potiuk deleted the backport-938ccf3-v3-2-test branch April 30, 2026 18:32
@jscheffl

Copy link
Copy Markdown
Contributor

Interesting case that you back-proted provider code to maintenance branch for CI test - so maybe we need to progress on this and install latest released providers and drop the soruce tree in future in the maintenance branch?

@vatsrahul1001 vatsrahul1001 added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label May 18, 2026
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.2.2 milestone May 18, 2026
vatsrahul1001 pushed a commit that referenced this pull request May 20, 2026
… (#66170)

When a pod is starting, kubelet automatically retries failed image pulls
with exponential backoff. `KubernetesPodOperator` monitors the pod via
`detect_pod_terminate_early_issues()` and aborts early on what it deems a
fatal pull error — but the transient-error pattern list did not cover
registry 5xx / gateway outages. A short Docker Hub outage (502/503/504
from `auth.docker.io` or the registry) was being classified as fatal and
would abort the pod before kubelet's next retry, even though the pull
would have succeeded once upstream recovered.

Add `bad gateway`, `service unavailable`, `gateway timeout` to
`TRANSIENT_ERROR_PATTERNS` so these conditions let kubelet keep retrying
within the caller's `startup_timeout` budget.

On kubelet >= 1.32 the `ImagePullBackOff` message is
`Back-off pulling image "X": <prev_error>`, so these patterns also match
during the backoff state. On older kubelets the bare message carries no
detail and we keep the existing fail-fast behaviour — matching
`back-off pulling` unconditionally would have caused a 120s wait for a
genuinely missing image instead of an immediate error (thanks Jens for
catching this).

`startup_timeout` still bounds the overall wait, and genuinely fatal pull
errors (`InvalidImageName`, `ErrImageNeverPull`, `manifest unknown`,
`unauthorized`, …) remain fatal.

(cherry picked from commit 938ccf3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:cncf-kubernetes Kubernetes (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants