This is an automated email from the ASF dual-hosted git repository.
Miretpl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new f468dfe6e2f Check Airflow pod health after applying kustomize overlays
(#73591)
f468dfe6e2f is described below
commit f468dfe6e2feba211c2121fd0540add06d4809e8
Author: ucaeon <[email protected]>
AuthorDate: Fri Nov 27 04:59:39 2026 +0900
Check Airflow pod health after applying kustomize overlays (#73591)
* Check Airflow pod health after applying kustomize overlays
* Regenerate the breeze k8s command hash after rebasing
Generated-by: Claude Opus 5
* Avoid false failures in overlay pod health checks
---------
Co-authored-by: Jarek Potiuk <[email protected]>
---
.github/workflows/kustomize-overlays-tests.yml | 20 +-
chart/kustomize-overlays/CONTRIBUTING.rst | 28 ++-
dev/breeze/doc/05_test_commands.rst | 21 ++
dev/breeze/doc/images/output_k8s.svg | 2 +-
dev/breeze/doc/images/output_k8s.txt | 2 +-
.../doc/images/output_k8s_smoke-test-overlay.svg | 12 +-
.../doc/images/output_k8s_smoke-test-overlay.txt | 2 +-
.../commands/kubernetes_kustomize_commands.py | 103 +++++++-
.../tests/test_kubernetes_kustomize_commands.py | 258 ++++++++++++++++++++-
9 files changed, 418 insertions(+), 30 deletions(-)
diff --git a/.github/workflows/kustomize-overlays-tests.yml
b/.github/workflows/kustomize-overlays-tests.yml
index 6814b44f9ce..465edcfc24d 100644
--- a/.github/workflows/kustomize-overlays-tests.yml
+++ b/.github/workflows/kustomize-overlays-tests.yml
@@ -118,15 +118,17 @@ jobs:
# can resolve the chart's image reference
# without hitting ghcr (which is private).
# 6. deploy-airflow
- # 7. smoke-test-overlay -> renders the overlay, auto-preloads the
- # overlay's own images into the kind
- # node (no per-overlay images list
- # needed - discovery walks the rendered
- # manifest), applies, walks the
- # STATUS.yaml verify: block with
- # fail-fast on ImagePullBackOff /
- # CrashLoopBackOff, runs the optional
- # per-overlay pytest module, cleans up.
+ # 7. smoke-test-overlay -> renders and applies the overlay.
+ # Discovers images from the rendered
+ # manifest and preloads them before apply.
+ # Checks the STATUS.yaml verify: block
+ # then pod health across the Helm release.
+ # ImagePullBackOff and CrashLoopBackOff
+ # fail the checks immediately.
+ # Each resource check and the pod-health
+ # check get a separate timeout.
+ # Runs the optional per-overlay pytest
+ # module then cleans up.
# 8. delete-cluster -> always(), even on failure.
- name: "Setup k8s/helm environment"
run: breeze k8s setup-env
diff --git a/chart/kustomize-overlays/CONTRIBUTING.rst
b/chart/kustomize-overlays/CONTRIBUTING.rst
index c964b3053ff..72414eceaf6 100644
--- a/chart/kustomize-overlays/CONTRIBUTING.rst
+++ b/chart/kustomize-overlays/CONTRIBUTING.rst
@@ -251,7 +251,24 @@ under ``chart/kustomize-overlays/`` with a ``verify:``
block:
any of those appears the runner aborts with the offending reason and
a ``kubectl describe`` dump, rather than waiting out the full
``timeout_seconds``.
-5. **Run the optional per-overlay pytest module.** If
+5. **Check the Airflow deployment's pod health.** Pods in the target namespace
+ with the chart's ``release=<release-name>`` label must be ``Running``
+ and ``Ready`` or ``Succeeded`` for completed work such as Helm hook Jobs.
+ Failed Job attempts and evicted pods are ignored unless they are
terminating.
+ At least one pod must be ``Running`` and ``Ready`` without a deletion
timestamp.
+ Completed or ignored pods alone do not establish a healthy deployment.
+ The runner retries failed or empty pod queries and rechecks the pod
+ list while pods start or terminate. It waits up to
``verify.timeout_seconds``
+ (default 300). It dumps pod status and descriptions on timeout.
+ Container waiting reasons listed in step 4 also fail this check immediately.
+ The pod-health check is skipped during ``--dry-run``.
+ This baseline runs even with ``--no-pytest``. It checks pod readiness.
+ It does not test application behaviour or end-to-end Dag execution.
+ It checks the whole release rather than only workloads changed by the
overlay.
+ A problem that existed before the run can fail this check and block
+ ``--promote-status``. A failed check does not establish that the overlay
+ caused the problem.
+6. **Run the optional per-overlay pytest module.** If
``chart/tests/overlay_tests/test_<name>.py``
exists and ``--no-pytest`` was not passed, it is executed with
``OVERLAY_UNDER_TEST``, ``OVERLAY_NAMESPACE``, and
@@ -259,10 +276,17 @@ under ``chart/kustomize-overlays/`` with a ``verify:``
block:
up an ad-hoc client pod (for example to exercise the overlay's data
plane) should prefer reusing an image already declared by the
overlay so they inherit the auto-preload for free.
-6. **Clean up.** The same substituted manifest is fed to
+7. **Clean up.** The same substituted manifest is fed to
``kubectl delete -f -`` (with ``--ignore-not-found``) unless
``--skip-cleanup`` was passed.
+``verify.timeout_seconds`` applies to each resource check in step 4.
+Step 5 gets a separate timeout of the same length.
+These checks run in sequence. They do not share a deadline.
+With two resources and a timeout of 300 seconds the checks have a combined
+waiting budget of 900 seconds. This is not a limit on the whole smoke test.
+Command execution and the other steps can add time.
+
Rules for images and per-overlay tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/dev/breeze/doc/05_test_commands.rst
b/dev/breeze/doc/05_test_commands.rst
index 2cd36482c39..72b86e5e26e 100644
--- a/dev/breeze/doc/05_test_commands.rst
+++ b/dev/breeze/doc/05_test_commands.rst
@@ -712,9 +712,30 @@ The runner is overlay-agnostic. For every overlay it:
(``ImagePullBackOff``, ``ErrImagePull``, ``CrashLoopBackOff``,
``CreateContainerConfigError``, …) rather than waiting out the full
``timeout_seconds``,
+* checks pods in the target namespace with the Helm chart's
+ ``release=<release-name>`` label. Each pod must be ``Running`` with
+ its ``Ready`` condition true or have completed successfully
+ (``Succeeded``). Terminating pods are retried until they disappear.
+ Failed Job attempts and evicted pods are ignored unless terminating.
+ At least one pod must be ``Running`` and ``Ready`` without a deletion
timestamp.
+ Failed or empty pod queries are retried. Container waiting reasons listed
+ above fail immediately. The pod-health check is skipped during ``--dry-run``.
+ The check uses the overlay's ``verify.timeout_seconds`` (default 300)
+ and prints pod diagnostics on timeout. It also runs with ``--no-pytest``,
* runs the optional per-overlay pytest module,
* deletes the overlay (skip with ``--skip-cleanup``).
+``verify.timeout_seconds`` applies to each resource check.
+The pod-health check gets a separate timeout of the same length.
+The checks run in sequence without a shared deadline.
+Two resources with a timeout of 300 seconds have a combined waiting budget
+of 900 seconds including the pod-health check. Other steps add time.
+
+The pod-health check covers the whole release rather than only workloads
+changed by the overlay. Problems that existed before the run can fail the
+check and block ``--promote-status``. A failure does not establish that the
+overlay caused the problem.
+
See ``chart/kustomize-overlays/CONTRIBUTING.rst`` for the full
lifecycle and how an overlay's ``STATUS`` advances from ``not-tested``
to ``tested``.
diff --git a/dev/breeze/doc/images/output_k8s.svg
b/dev/breeze/doc/images/output_k8s.svg
index 6ba5d750acf..f00617fd600 100644
--- a/dev/breeze/doc/images/output_k8s.svg
+++ b/dev/breeze/doc/images/output_k8s.svg
@@ -206,7 +206,7 @@
</text><text class="breeze-k8s-r5" x="0" y="654.4" textLength="24.4"
clip-path="url(#breeze-k8s-line-26)">╭─</text><text class="breeze-k8s-r5"
x="24.4" y="654.4" textLength="268.4"
clip-path="url(#breeze-k8s-line-26)"> K8S testing commands </text><text
class="breeze-k8s-r5" x="292.8" y="654.4" textLength="1146.8"
clip-path="url(#breeze-k8s-line-26)">──────────────────────────────────────────────────────────────────────────────────────────────</text><text
class="breeze [...]
</text><text class="breeze-k8s-r5" x="0" y="678.8" textLength="12.2"
clip-path="url(#breeze-k8s-line-27)">│</text><text class="breeze-k8s-r4"
x="24.4" y="678.8" textLength="231.8"
clip-path="url(#breeze-k8s-line-27)">tests              </text><text
class="breeze-k8s-r1" x="280.6" y="678.8" textLength="1159"
clip-path="url(#breeze-k8s-line-27)">Run tests against the current KinD cluster
[...]
</text><text class="breeze-k8s-r5" x="0" y="703.2" textLength="12.2"
clip-path="url(#breeze-k8s-line-28)">│</text><text class="breeze-k8s-r4"
x="24.4" y="703.2" textLength="231.8"
clip-path="url(#breeze-k8s-line-28)">smoke-test-overlay </text><text
class="breeze-k8s-r1" x="280.6" y="703.2" textLength="1159"
clip-path="url(#breeze-k8s-line-28)">Apply a kustomize overlay to the current KinD cluster, wait for its STATUS.yaml&#
[...]
-</text><text class="breeze-k8s-r5" x="0" y="727.6" textLength="12.2"
clip-path="url(#breeze-k8s-line-29)">│</text><text class="breeze-k8s-r1"
x="280.6" y="727.6" textLength="1159"
clip-path="url(#breeze-k8s-line-29)">resources, and run the optional per-overlay pytest module.                              &#
[...]
+</text><text class="breeze-k8s-r5" x="0" y="727.6" textLength="12.2"
clip-path="url(#breeze-k8s-line-29)">│</text><text class="breeze-k8s-r1"
x="280.6" y="727.6" textLength="1159"
clip-path="url(#breeze-k8s-line-29)">resources, check Airflow pod health, and run the optional per-overlay pytest module.           </text><text
class="breeze-k8s-r5" x="1451.8" y="727.6" textLength="12 [...]
</text><text class="breeze-k8s-r5" x="0" y="752" textLength="12.2"
clip-path="url(#breeze-k8s-line-30)">│</text><text class="breeze-k8s-r4"
x="24.4" y="752" textLength="231.8"
clip-path="url(#breeze-k8s-line-30)">run-complete-tests </text><text
class="breeze-k8s-r1" x="280.6" y="752" textLength="1159"
clip-path="url(#breeze-k8s-line-30)">Run complete k8s tests consisting of: creating cluster, building and uploading image, d
[...]
</text><text class="breeze-k8s-r5" x="0" y="776.4" textLength="12.2"
clip-path="url(#breeze-k8s-line-31)">│</text><text class="breeze-k8s-r1"
x="280.6" y="776.4" textLength="1159"
clip-path="url(#breeze-k8s-line-31)">airflow, running tests and deleting clusters (optionally for all clusters in parallel).        </text><text
class="breeze-k8s-r5" x="1451.8" y="776.4" textLength="12.2" clip-path=" [...]
</text><text class="breeze-k8s-r5" x="0" y="800.8" textLength="12.2"
clip-path="url(#breeze-k8s-line-32)">│</text><text class="breeze-k8s-r4"
x="24.4" y="800.8" textLength="231.8"
clip-path="url(#breeze-k8s-line-32)">setup-lang-sdk-test</text><text
class="breeze-k8s-r1" x="280.6" y="800.8" textLength="1159"
clip-path="url(#breeze-k8s-line-32)">Provision the lang-SDK (Go + Java + TypeScript) coordinator system tests on an al
[...]
diff --git a/dev/breeze/doc/images/output_k8s.txt
b/dev/breeze/doc/images/output_k8s.txt
index f48d1250bcd..5668377c43d 100644
--- a/dev/breeze/doc/images/output_k8s.txt
+++ b/dev/breeze/doc/images/output_k8s.txt
@@ -1 +1 @@
-e9520ded47d3061a2ee5357531b97d3e
+f09eb9f827d7991e5a3b195dae1f0361
diff --git a/dev/breeze/doc/images/output_k8s_smoke-test-overlay.svg
b/dev/breeze/doc/images/output_k8s_smoke-test-overlay.svg
index 83070d6f223..eef54247f4c 100644
--- a/dev/breeze/doc/images/output_k8s_smoke-test-overlay.svg
+++ b/dev/breeze/doc/images/output_k8s_smoke-test-overlay.svg
@@ -141,8 +141,8 @@
<text class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="20"
textLength="12.2" clip-path="url(#breeze-k8s-smoke-test-overlay-line-0)">
</text><text class="breeze-k8s-smoke-test-overlay-r2" x="12.2" y="44.4"
textLength="73.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-1)">Usage:</text><text
class="breeze-k8s-smoke-test-overlay-r3" x="97.6" y="44.4" textLength="353.8"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-1)">breeze k8s smoke-test-overlay</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="463.6" y="44.4" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-1)">[</text><t [...]
</text><text class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="68.8"
textLength="12.2" clip-path="url(#breeze-k8s-smoke-test-overlay-line-2)">
-</text><text class="breeze-k8s-smoke-test-overlay-r1" x="12.2" y="93.2"
textLength="1378.6"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-3)">Apply a kustomize overlay to the current KinD cluster, wait for its STATUS.yaml `verify:` resources, and run the </text><text
class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="93.2" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-3)">
-</text><text class="breeze-k8s-smoke-test-overlay-r1" x="12.2" y="117.6"
textLength="427"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-4)">optional per-overlay pytest module.</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="117.6" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-4)">
+</text><text class="breeze-k8s-smoke-test-overlay-r1" x="12.2" y="93.2"
textLength="1439.6"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-3)">Apply a kustomize overlay to the current KinD cluster, wait for its STATUS.yaml `verify:` resources, check Airflow pod</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="93.2" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-3)">
+</text><text class="breeze-k8s-smoke-test-overlay-r1" x="12.2" y="117.6"
textLength="671"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-4)">health, and run the optional per-overlay pytest module.</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="117.6" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-4)">
</text><text class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="142"
textLength="12.2" clip-path="url(#breeze-k8s-smoke-test-overlay-line-5)">
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="166.4"
textLength="24.4"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-6)">╭─</text><text
class="breeze-k8s-smoke-test-overlay-r5" x="24.4" y="166.4" textLength="317.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-6)"> Overlay smoke-test flags </text><text
class="breeze-k8s-smoke-test-overlay-r5" x="341.6" y="166.4" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-6)">─────── [...]
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="190.8"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-7)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="190.8" textLength="244"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-7)">--python            </text><text
class="breeze-k8s-smoke-test-overlay-r6" x="292.8" y="190.8" textLength="24.4"
clip-path="url(#breeze-k8s-smok [...]
@@ -156,10 +156,10 @@
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="386"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-15)">│</text><text
class="breeze-k8s-smoke-test-overlay-r7" x="341.6" y="386" textLength="73.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-15)">(TEXT)</text><text
class="breeze-k8s-smoke-test-overlay-r5" x="1451.8" y="386" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-15)">│</text><text
class="breeze-k8s-smoke-test-overlay [...]
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="410.4"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-16)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="410.4" textLength="244"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-16)">--skip-cleanup      </text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="410.4"
textLength="768.6" clip-path="url(#breeze-k8s-smoke-test-overlay-line-16)">Le
[...]
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="434.8"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-17)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="434.8" textLength="244"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-17)">--no-pytest         </text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="434.8"
textLength="646.6" clip-path="url(#breeze-k8s-smoke-test-overl [...]
-</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="459.2"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="459.2" textLength="244"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">--promote-status    </text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="459.2" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">If the&# [...]
-</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="483.6"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-19)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="483.6" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-19)">STATUS.yaml in place to `status: tested` with chart-version from chart/Chart.yaml and     </text><text
class="breeze-k8s-smo [...]
-</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="508"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-20)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="508" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-20)">today's date as last-verified. Opt-in because it modifies a checked-in file; review with  </text><text
class="breeze-k8s-smoke-t [...]
-</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="532.4"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-21)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="532.4" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-21)">`git diff` and commit. Refused when CI=true.                     
[...]
+</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="459.2"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="459.2" textLength="244"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">--promote-status    </text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="459.2" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-18)">Set STAT [...]
+</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="483.6"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-19)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="483.6" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-19)">pass. The per-overlay pytest module must also pass unless skipped or absent. Set          
[...]
+</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="508"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-20)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="508" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-20)">chart-version from chart/Chart.yaml and last-verified to today's date. Review the file    </text><text
class="breeze-k8s-smoke-t [...]
+</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="532.4"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-21)">│</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="341.6" y="532.4" textLength="1098"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-21)">with `git diff` before committing. Refused when CI=true.                  
[...]
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="556.8"
textLength="1464"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-22)">╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯</text><text
class="breeze-k8s-smoke-test-overlay-r1" x="1464" y="556.8" textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-22)">
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="581.2"
textLength="24.4"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-23)">╭─</text><text
class="breeze-k8s-smoke-test-overlay-r5" x="24.4" y="581.2" textLength="195.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-23)"> Common options </text><text
class="breeze-k8s-smoke-test-overlay-r5" x="219.6" y="581.2" textLength="1220"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-23)">───────────────────
[...]
</text><text class="breeze-k8s-smoke-test-overlay-r5" x="0" y="605.6"
textLength="12.2"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-24)">│</text><text
class="breeze-k8s-smoke-test-overlay-r4" x="24.4" y="605.6" textLength="109.8"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-24)">--verbose</text><text
class="breeze-k8s-smoke-test-overlay-r6" x="158.6" y="605.6" textLength="24.4"
clip-path="url(#breeze-k8s-smoke-test-overlay-line-24)">-v</text><text
class="breeze-k8s-smoke-tes [...]
diff --git a/dev/breeze/doc/images/output_k8s_smoke-test-overlay.txt
b/dev/breeze/doc/images/output_k8s_smoke-test-overlay.txt
index 781145af164..e6f082dd501 100644
--- a/dev/breeze/doc/images/output_k8s_smoke-test-overlay.txt
+++ b/dev/breeze/doc/images/output_k8s_smoke-test-overlay.txt
@@ -1 +1 @@
-2b1c82b3c236f3a7a69963b484fec3b6
+71d2f6516ad802abcd3ed1c3c4e48d61
diff --git
a/dev/breeze/src/airflow_breeze/commands/kubernetes_kustomize_commands.py
b/dev/breeze/src/airflow_breeze/commands/kubernetes_kustomize_commands.py
index fe1da3f0689..402917697a0 100644
--- a/dev/breeze/src/airflow_breeze/commands/kubernetes_kustomize_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/kubernetes_kustomize_commands.py
@@ -24,6 +24,7 @@ subcommands.
from __future__ import annotations
+import json
import os
import sys
import time
@@ -56,6 +57,7 @@ from airflow_breeze.utils.kubernetes_utils import (
)
from airflow_breeze.utils.path_utils import AIRFLOW_ROOT_PATH
from airflow_breeze.utils.run_utils import run_command
+from airflow_breeze.utils.shared_options import get_dry_run
# Allow-list of third-party container images that kustomize overlays under
# chart/kustomize-overlays/ may declare. `breeze k8s smoke-test-overlay`
@@ -279,6 +281,93 @@ def _wait_for_verify_resource(
return 1
+def _get_pod_health_problems(pods: list[dict[str, Any]]) -> list[str]:
+ problems = []
+ for pod in pods:
+ name = pod["metadata"]["name"]
+ status = pod.get("status", {})
+ phase = status.get("phase", "Unknown")
+ if pod["metadata"].get("deletionTimestamp"):
+ problems.append(f"{name}: terminating")
+ elif phase == "Succeeded":
+ continue
+ elif phase == "Failed" and (
+ status.get("reason") == "Evicted"
+ or any(owner.get("kind") == "Job" for owner in
pod["metadata"].get("ownerReferences", []))
+ ):
+ # Failed Job attempts and evicted pods can remain after their
replacements are healthy.
+ continue
+ elif phase != "Running":
+ problems.append(f"{name}: {phase}")
+ elif not any(
+ condition["type"] == "Ready" and condition["status"] == "True"
+ for condition in status.get("conditions", [])
+ ):
+ problems.append(f"{name}: not Ready")
+ return problems
+
+
+def _wait_for_airflow_pods(
+ namespace: str, release_name: str, timeout_seconds: int, env: dict[str,
str]
+) -> int:
+ """Wait for the Helm release's pods to be Running/Ready or successfully
completed."""
+ kubectl = str(KUBECTL_BIN_PATH)
+ scope = ["-n", namespace, "-l", f"release={release_name}"]
+ console_print(f"[info]Checking Airflow pod health for release
{release_name} in {namespace}...")
+ if get_dry_run():
+ return 0
+ deadline = time.monotonic() + timeout_seconds
+ problems = ["No healthy Airflow pods observed"]
+ while time.monotonic() < deadline:
+ result = run_command(
+ [kubectl, "get", "pods", *scope, "-o", "json",
"--request-timeout=10s"],
+ env=env,
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+ if result.returncode != 0:
+ problems = [f"Could not list pods: {(result.stderr or
'').strip()}"]
+ time.sleep(min(5, max(0, deadline - time.monotonic())))
+ continue
+ if not result.stdout.strip():
+ problems = ["Pod query returned empty output"]
+ time.sleep(min(5, max(0, deadline - time.monotonic())))
+ continue
+ pods = json.loads(result.stdout)["items"]
+ problems = _get_pod_health_problems(pods)
+ unrecoverable = [
+ f"{pod['metadata']['name']}: {reason}"
+ for pod in pods
+ if not pod["metadata"].get("deletionTimestamp")
+ and pod.get("status", {}).get("phase") not in ("Failed",
"Succeeded")
+ for container in [
+ *pod.get("status", {}).get("containerStatuses", []),
+ *pod.get("status", {}).get("initContainerStatuses", []),
+ ]
+ if (reason := container.get("state", {}).get("waiting",
{}).get("reason"))
+ in _TERMINAL_POD_WAITING_REASONS
+ ]
+ if unrecoverable:
+ console_print(f"[error]Airflow pods failed health check: {';
'.join(unrecoverable)}")
+ run_command([kubectl, "describe", "pods", *scope], env=env,
check=False)
+ return 1
+ # Ignored failures and completed Jobs cannot establish a healthy
deployment.
+ if not any(
+ pod.get("status", {}).get("phase") == "Running" and not
pod["metadata"].get("deletionTimestamp")
+ for pod in pods
+ ):
+ problems.append("No active Airflow pods found")
+ if not problems:
+ console_print("[success]Airflow pods are healthy after applying
the overlay.")
+ return 0
+ time.sleep(min(5, max(0, deadline - time.monotonic())))
+ console_print(f"[error]Airflow pod health timed out after
{timeout_seconds}s: {'; '.join(problems)}")
+ run_command([kubectl, "get", "pods", *scope, "-o", "wide"], env=env,
check=False)
+ run_command([kubectl, "describe", "pods", *scope], env=env, check=False)
+ return 1
+
+
def _render_overlay(
overlay_dir: Path,
release_name: str,
@@ -481,7 +570,7 @@ def _run_overlay_pytest(
if not test_file.exists():
console_print(
f"[info]No behavioural test module at
{test_file.relative_to(AIRFLOW_ROOT_PATH)} — "
- "verify-block checks are the only assertions for this overlay."
+ "Only verify-block and Airflow pod-health checks will run for this
overlay."
)
return 0
env = get_k8s_env(python=python, kubernetes_version=kubernetes_version,
executor=executor)
@@ -539,6 +628,8 @@ def _smoke_test_overlay_impl(
console_print("[error]verify block failed.")
return 1
console_print("\n[success]verify block passed.")
+ if _wait_for_airflow_pods(namespace, release_name, timeout, env) != 0:
+ return 1
if not no_pytest:
rc = _run_overlay_pytest(
overlay_name=overlay_name,
@@ -563,7 +654,7 @@ def _smoke_test_overlay_impl(
@kubernetes_group.command(
name="smoke-test-overlay",
help="Apply a kustomize overlay to the current KinD cluster, wait for its
STATUS.yaml "
- "`verify:` resources, and run the optional per-overlay pytest module.",
+ "`verify:` resources, check Airflow pod health, and run the optional
per-overlay pytest module.",
)
@click.argument("overlay_name", type=str)
@option_python
@@ -595,10 +686,10 @@ def _smoke_test_overlay_impl(
"--promote-status",
is_flag=True,
help=(
- "If the run is green (verify block + per-overlay pytest both pass),
rewrite the "
- "overlay's STATUS.yaml in place to `status: tested` with chart-version
from "
- "chart/Chart.yaml and today's date as last-verified. Opt-in because it
modifies "
- "a checked-in file; review with `git diff` and commit. Refused when
CI=true."
+ "Set STATUS.yaml to `status: tested` after the verify block and
Airflow pod-health check pass. "
+ "The per-overlay pytest module must also pass unless skipped or
absent. "
+ "Set chart-version from chart/Chart.yaml and last-verified to today's
date. "
+ "Review the file with `git diff` before committing. Refused when
CI=true."
),
)
@option_verbose
diff --git a/dev/breeze/tests/test_kubernetes_kustomize_commands.py
b/dev/breeze/tests/test_kubernetes_kustomize_commands.py
index e58ac56b1fb..1e87ebd865f 100644
--- a/dev/breeze/tests/test_kubernetes_kustomize_commands.py
+++ b/dev/breeze/tests/test_kubernetes_kustomize_commands.py
@@ -16,15 +16,20 @@
# under the License.
from __future__ import annotations
+import json
+from subprocess import CompletedProcess
from unittest import mock
import pytest
-from airflow_breeze.commands import kubernetes_kustomize_commands
+from airflow_breeze.commands import kubernetes_kustomize_commands as
overlay_commands
from airflow_breeze.commands.kubernetes_kustomize_commands import (
ALLOWED_OVERLAY_IMAGES,
_discover_overlay_images,
_find_disallowed_overlay_images,
+ _get_pod_health_problems,
+ _smoke_test_overlay_impl,
+ _wait_for_airflow_pods,
)
@@ -81,12 +86,12 @@ class TestFindDisallowedOverlayImages:
assert _find_disallowed_overlay_images(images) == expected
[email protected](kubernetes_kustomize_commands, "run_command", autospec=True)
[email protected](kubernetes_kustomize_commands, "get_k8s_env",
autospec=True, return_value={})
[email protected](overlay_commands, "run_command", autospec=True)
[email protected](overlay_commands, "get_k8s_env", autospec=True,
return_value={})
def test_run_overlay_pytest_does_not_relock(mock_get_k8s_env,
mock_run_command):
mock_run_command.return_value = mock.Mock(returncode=0)
- kubernetes_kustomize_commands._run_overlay_pytest(
+ overlay_commands._run_overlay_pytest(
overlay_name="kerberos",
namespace="airflow",
release_name="airflow",
@@ -96,3 +101,248 @@ def
test_run_overlay_pytest_does_not_relock(mock_get_k8s_env, mock_run_command):
)
assert mock_run_command.call_args.args[0][:4] == ["uv", "run", "--frozen",
"pytest"]
+
+
+def build_pod(name="scheduler", phase="Running", ready="True",
terminating=False, reason=None, owner=None):
+ metadata = {"name": name}
+ if terminating:
+ metadata["deletionTimestamp"] = "2026-01-01T00:00:00Z"
+ if owner:
+ metadata["ownerReferences"] = [{"kind": owner}]
+ return {
+ "metadata": metadata,
+ "status": {"phase": phase, "reason": reason, "conditions": [{"type":
"Ready", "status": ready}]},
+ }
+
+
[email protected](
+ ("pod", "expected"),
+ [
+ (build_pod(), []),
+ (build_pod(phase="Succeeded", ready="False"), []),
+ (build_pod(phase="Pending", ready="False"), ["scheduler: Pending"]),
+ (build_pod(phase="Failed", ready="False"), ["scheduler: Failed"]),
+ (build_pod(phase="Failed", reason="Evicted"), []),
+ (build_pod(phase="Failed", owner="Job"), []),
+ (build_pod(phase="Failed", owner="ReplicaSet"), ["scheduler: Failed"]),
+ (build_pod(phase="Failed", owner="Job", terminating=True),
["scheduler: terminating"]),
+ (build_pod(ready="False"), ["scheduler: not Ready"]),
+ (build_pod(ready="Unknown"), ["scheduler: not Ready"]),
+ (build_pod(terminating=True), ["scheduler: terminating"]),
+ ({"metadata": {"name": "scheduler"}}, ["scheduler: Unknown"]),
+ (
+ {"metadata": {"name": "scheduler"}, "status": {"phase":
"Running"}},
+ ["scheduler: not Ready"],
+ ),
+ ],
+)
+def test_get_pod_health_problems(pod, expected):
+ assert _get_pod_health_problems([pod]) == expected
+
+
+class TestWaitForAirflowPods:
+ @pytest.mark.parametrize(
+ "failed_pod", [build_pod(phase="Failed", reason="Evicted"),
build_pod(phase="Failed", owner="Job")]
+ )
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_ignores_old_failures_with_healthy_pod(self, run_command,
failed_pod):
+ failed_pod["status"]["containerStatuses"] = [{"state": {"waiting":
{"reason": "CrashLoopBackOff"}}}]
+ run_command.return_value = CompletedProcess(
+ [], 0, stdout=json.dumps({"items": [failed_pod, build_pod()]})
+ )
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 0
+
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_checks_release_in_namespace_and_allows_completed_jobs(self,
run_command):
+ run_command.return_value = CompletedProcess(
+ [], 0, stdout=json.dumps({"items": [build_pod(),
build_pod("migrate", "Succeeded", "False")]})
+ )
+ env = {"KUBECONFIG": "/test/kubeconfig"}
+
+ assert _wait_for_airflow_pods("custom-namespace", "custom-release",
30, env) == 0
+
+ run_command.assert_called_once_with(
+ [
+ str(overlay_commands.KUBECTL_BIN_PATH),
+ "get",
+ "pods",
+ "-n",
+ "custom-namespace",
+ "-l",
+ "release=custom-release",
+ "-o",
+ "json",
+ "--request-timeout=10s",
+ ],
+ env=env,
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+
+ @pytest.mark.parametrize(
+ "initial_pods",
+ [[], [build_pod(phase="Pending")], [build_pod(ready="False")],
[build_pod(terminating=True)]],
+ )
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_waits_for_current_pods_to_be_ready(self, run_command, sleep,
initial_pods):
+ run_command.side_effect = [
+ CompletedProcess([], 0, stdout=json.dumps({"items":
initial_pods})),
+ CompletedProcess([], 0, stdout=json.dumps({"items":
[build_pod("replacement-scheduler")]})),
+ ]
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 0
+ assert run_command.call_count == 2
+ sleep.assert_called_once()
+
+ @pytest.mark.parametrize(
+ "pods",
+ [
+ [],
+ [build_pod("migrate", "Succeeded", "False")],
+ [build_pod(phase="Failed")],
+ [build_pod(phase="Failed", reason="Evicted")],
+ [build_pod(phase="Failed", owner="Job")],
+ [build_pod(phase="Succeeded"), build_pod(phase="Failed",
owner="Job")],
+ [build_pod(ready="False")],
+ [build_pod(), build_pod("worker", ready="False")],
+ ],
+ )
+ @mock.patch.object(overlay_commands.time, "monotonic", autospec=True,
side_effect=[0, 0, 1, 1])
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_timeout_fails_and_dumps_scoped_diagnostics(self, run_command,
sleep, monotonic, pods):
+ run_command.return_value = CompletedProcess([], 0,
stdout=json.dumps({"items": pods}))
+
+ assert _wait_for_airflow_pods("test-ns", "test-release", 1, {}) == 1
+
+ kubectl = str(overlay_commands.KUBECTL_BIN_PATH)
+ scope = ["-n", "test-ns", "-l", "release=test-release"]
+ assert run_command.call_args_list[1:] == [
+ mock.call([kubectl, "get", "pods", *scope, "-o", "wide"], env={},
check=False),
+ mock.call([kubectl, "describe", "pods", *scope], env={},
check=False),
+ ]
+
+ @pytest.mark.parametrize(
+ "query_result",
+ [CompletedProcess([], 1, stdout="", stderr="Unavailable"),
CompletedProcess([], 0, stdout=" \n")],
+ )
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_retries_query_until_recovery(self, run_command, sleep,
query_result):
+ run_command.side_effect = [
+ query_result,
+ CompletedProcess([], 0, stdout=json.dumps({"items":
[build_pod()]})),
+ ]
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 0
+ assert run_command.call_count == 2
+ sleep.assert_called_once()
+
+ @pytest.mark.parametrize(
+ "query_result",
+ [CompletedProcess([], 1, stdout="", stderr="Forbidden"),
CompletedProcess([], 0, stdout="")],
+ )
+ @mock.patch.object(overlay_commands.time, "monotonic", autospec=True,
side_effect=[0, 0, 0, 0, 1, 1])
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_query_failure_retries_until_timeout(self, run_command, sleep,
monotonic, query_result):
+ run_command.return_value = query_result
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 1, {}) == 1
+ assert run_command.call_count == 4
+ assert sleep.call_count == 2
+ assert run_command.call_args.args[0][1:3] == ["describe", "pods"]
+
+ @mock.patch.object(overlay_commands, "get_dry_run", autospec=True,
return_value=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_dry_run_skips_health_check(self, run_command, get_dry_run):
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 0
+ run_command.assert_not_called()
+
+ @pytest.mark.parametrize("reason",
sorted(overlay_commands._TERMINAL_POD_WAITING_REASONS))
+ @pytest.mark.parametrize("container_key", ["containerStatuses",
"initContainerStatuses"])
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_terminal_waiting_reason_fails_immediately(self, run_command,
sleep, reason, container_key):
+ pod = build_pod(ready="False")
+ pod["status"][container_key] = [{"state": {"waiting": {"reason":
reason}}}]
+ run_command.return_value = CompletedProcess([], 0,
stdout=json.dumps({"items": [pod]}))
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 1
+ sleep.assert_not_called()
+ assert run_command.call_count == 2
+ assert run_command.call_args.args[0][1:3] == ["describe", "pods"]
+
+ @pytest.mark.parametrize(
+ ("reason", "terminating"), [("ContainerCreating", False),
("CrashLoopBackOff", True)]
+ )
+ @mock.patch.object(overlay_commands.time, "sleep", autospec=True)
+ @mock.patch.object(overlay_commands, "run_command", autospec=True)
+ def test_waits_for_recoverable_or_terminating_pods(self, run_command,
sleep, reason, terminating):
+ pod = build_pod(ready="False", terminating=terminating)
+ pod["status"]["containerStatuses"] = [{"state": {"waiting": {"reason":
reason}}}]
+ run_command.side_effect = [
+ CompletedProcess([], 0, stdout=json.dumps({"items": [pod]})),
+ CompletedProcess([], 0, stdout=json.dumps({"items":
[build_pod()]})),
+ ]
+
+ assert _wait_for_airflow_pods("airflow", "airflow", 30, {}) == 0
+ assert run_command.call_count == 2
+ sleep.assert_called_once()
+
+
[email protected]("health_result", [0, 1])
[email protected]("no_pytest", [False, True])
[email protected]("skip_cleanup", [False, True])
[email protected](overlay_commands, "get_k8s_env", autospec=True,
return_value={})
[email protected](overlay_commands, "_render_overlay", autospec=True,
return_value="manifest")
[email protected](overlay_commands, "_preload_overlay_images", autospec=True,
return_value=0)
[email protected](overlay_commands, "_apply_or_delete_overlay",
autospec=True, return_value=0)
[email protected](overlay_commands, "_wait_for_verify_resource",
autospec=True, return_value=0)
[email protected](overlay_commands, "_wait_for_airflow_pods", autospec=True)
[email protected](overlay_commands, "_run_overlay_pytest", autospec=True,
return_value=0)
+def test_smoke_test_requires_healthy_airflow(
+ run_pytest,
+ wait_for_airflow,
+ wait_for_resource,
+ apply_or_delete,
+ preload,
+ render,
+ get_env,
+ skip_cleanup,
+ no_pytest,
+ health_result,
+ tmp_path,
+):
+ wait_for_airflow.return_value = health_result
+ calls = mock.Mock(spec=["verify", "health", "apply_or_delete", "pytest"])
+ calls.attach_mock(wait_for_resource, "verify")
+ calls.attach_mock(wait_for_airflow, "health")
+ calls.attach_mock(apply_or_delete, "apply_or_delete")
+ calls.attach_mock(run_pytest, "pytest")
+
+ result = _smoke_test_overlay_impl(
+ overlay_name="kerberos",
+ overlay_dir=tmp_path,
+ verify={"timeout_seconds": 30, "resources": [{"kind": "Secret",
"name": "keytab"}]},
+ python="3.10",
+ kubernetes_version="1.35.0",
+ executor="CeleryExecutor",
+ release_name="test-release",
+ namespace="test-ns",
+ skip_cleanup=skip_cleanup,
+ no_pytest=no_pytest,
+ )
+
+ assert result == health_result
+ wait_for_airflow.assert_called_once_with("test-ns", "test-release", 30, {})
+ expected_order = ["apply_or_delete", "verify", "health"]
+ if health_result == 0 and not no_pytest:
+ expected_order.append("pytest")
+ if not skip_cleanup:
+ expected_order.append("apply_or_delete")
+ assert apply_or_delete.call_args == mock.call("delete", "manifest",
"test-ns", {})
+ assert [call[0] for call in calls.mock_calls] == expected_order