From 5b42721c0ca4db15f24407d0eedc6ca3ac2dc52a Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 12 Aug 2026 10:25:06 +0200 Subject: [PATCH 1/2] fix(test): Don't tear down AirflowClusters when --skip-delete is used --- .../ca-cert/90-cleanup-executor-pods.yaml | 24 ++++++++++++++++- .../90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../ldap/99-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../logging/90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../kuttl/oidc/90-cleanup-executor-pods.yaml | 24 ++++++++++++++++- .../kuttl/opa/90-cleanup-executor-pods.yaml | 24 ++++++++++++++++- .../overrides/90-cleanup-executor-pods.yaml | 24 ++++++++++++++++- .../90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../smoke/90-cleanup-executor-pods.yaml.j2 | 27 +++++++++++++++---- .../90-cleanup-executor-pods.yaml.j2 | 24 ++++++++++++++++- .../versioning/90-cleanup-executor-pods.yaml | 24 ++++++++++++++++- 13 files changed, 298 insertions(+), 17 deletions(-) diff --git a/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml index 5fc48224..4cdf47d7 100644 --- a/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml @@ -4,13 +4,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster --all -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml index 3bc075fd..35d86347 100644 --- a/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml @@ -4,13 +4,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml index 3bc075fd..35d86347 100644 --- a/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml @@ -4,13 +4,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml index 5fc48224..4cdf47d7 100644 --- a/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml @@ -4,13 +4,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster --all -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 index 72c281b9..700da545 100644 --- a/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 @@ -6,17 +6,34 @@ # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). # -# FIXME: This step also runs when kuttl is called with --skip-delete, so the -# AirflowCluster is torn down even though the namespace is kept for debugging. -# kuttl does not expose --skip-delete to test steps, so there is no clean way to -# guard against it from here. +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 index f2ad3209..700da545 100644 --- a/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 @@ -5,13 +5,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi diff --git a/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml index 3bc075fd..35d86347 100644 --- a/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml @@ -4,13 +4,35 @@ # sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking # namespace deletion past kuttl's timeout. # The proper fix is in operator-rs (making Vector PID 1 via exec). +# +# When kuttl runs with --skip-delete the namespace is kept for debugging, so this +# teardown must not run. kuttl does not expose the flag to test steps, so it is read +# from the command line of the kuttl process that invoked this step. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - script: | + # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl + # was started with --skip-delete. + pid=$PPID + while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') + done + kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - script: | + if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then exit 0 fi From ebb3239283c53dda0c782ccfba545b09ff0f0c0e Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 12 Aug 2026 10:57:26 +0200 Subject: [PATCH 2/2] refactor: Move into common shared script --- .../ca-cert/90-cleanup-executor-pods.yaml | 38 ++----------------- .../kuttl/commons/cleanup-executor-pods.sh | 32 ++++++++++++++++ .../90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../ldap/99-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../logging/90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../kuttl/oidc/90-cleanup-executor-pods.yaml | 38 ++----------------- .../kuttl/opa/90-cleanup-executor-pods.yaml | 38 ++----------------- .../overrides/90-cleanup-executor-pods.yaml | 38 ++----------------- .../90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../smoke/90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../90-cleanup-executor-pods.yaml.j2 | 38 ++----------------- .../versioning/90-cleanup-executor-pods.yaml | 38 ++----------------- 14 files changed, 71 insertions(+), 455 deletions(-) create mode 100644 tests/templates/kuttl/commons/cleanup-executor-pods.sh diff --git a/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml index 4cdf47d7..3c9c9e9d 100644 --- a/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/ca-cert/90-cleanup-executor-pods.yaml @@ -1,40 +1,8 @@ --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster --all -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh diff --git a/tests/templates/kuttl/commons/cleanup-executor-pods.sh b/tests/templates/kuttl/commons/cleanup-executor-pods.sh new file mode 100644 index 00000000..db364177 --- /dev/null +++ b/tests/templates/kuttl/commons/cleanup-executor-pods.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh +# Shared teardown for KubernetesExecutor tests: force-deletes leftover DAG task pods so +# that kuttl can delete the namespace within its timeout. Their Vector sidecar ignores +# SIGTERM (it is not PID 1) and would linger for the full 300s grace period. +# The proper fix is in operator-rs (making Vector PID 1 via exec). + +# With --skip-delete the namespace is kept for debugging, so this must not run. kuttl does +# not expose the flag to test steps, hence looking for it in the argv of the kuttl ancestor. +pid=$(ps -o ppid= -p "$$" 2>/dev/null | tr -d '[:space:]') +while [ "${pid:-0}" -ge 1 ]; do + args=$(ps -o args= -p "$pid" 2>/dev/null) + case "$args" in + *kuttl*) + case "$args" in + *--skip-delete*) + echo "kuttl was started with --skip-delete, keeping the AirflowCluster" + exit 0 + ;; + esac + ;; + esac + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') +done + +# shellcheck disable=SC2154 # NAMESPACE is set by kuttl for test-step commands +kubectl delete airflowcluster --all -n "$NAMESPACE" --wait=false 2>/dev/null || true + +if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n "$NAMESPACE" --timeout=120s 2>/dev/null; then + exit 0 +fi +kubectl delete pods -l app.kubernetes.io/name=airflow -n "$NAMESPACE" --grace-period=0 --force 2>/dev/null || true +kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n "$NAMESPACE" --timeout=300s diff --git a/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/external-access/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/ldap/99-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/logging/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/mount-dags-configmap/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/mount-dags-gitsync/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml index 35d86347..3c9c9e9d 100644 --- a/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/oidc/90-cleanup-executor-pods.yaml @@ -1,40 +1,8 @@ --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh diff --git a/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml index 35d86347..3c9c9e9d 100644 --- a/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/opa/90-cleanup-executor-pods.yaml @@ -1,40 +1,8 @@ --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh diff --git a/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml index 4cdf47d7..3c9c9e9d 100644 --- a/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/overrides/90-cleanup-executor-pods.yaml @@ -1,40 +1,8 @@ --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster --all -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh diff --git a/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/remote-logging/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/smoke/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 b/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 index 700da545..23b70785 100644 --- a/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 +++ b/tests/templates/kuttl/triggerer/90-cleanup-executor-pods.yaml.j2 @@ -1,42 +1,10 @@ {% if test_scenario['values']['executor'] == 'kubernetes' %} --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh {% endif %} diff --git a/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml b/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml index 35d86347..3c9c9e9d 100644 --- a/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml +++ b/tests/templates/kuttl/versioning/90-cleanup-executor-pods.yaml @@ -1,40 +1,8 @@ --- -# Force-delete KubernetesExecutor DAG task pods before kuttl deletes the namespace. -# Their Vector sidecar does not respond to SIGTERM (it is not PID 1), so these pods -# sit in Terminating for the full terminationGracePeriodSeconds (300s), blocking -# namespace deletion past kuttl's timeout. -# The proper fix is in operator-rs (making Vector PID 1 via exec). -# -# When kuttl runs with --skip-delete the namespace is kept for debugging, so this -# teardown must not run. kuttl does not expose the flag to test steps, so it is read -# from the command line of the kuttl process that invoked this step. +# Force-delete leftover KubernetesExecutor DAG task pods so that kuttl can delete the +# namespace within its timeout. See the script for the details. apiVersion: kuttl.dev/v1beta1 kind: TestStep timeout: 600 commands: - - script: | - # Walk up the process tree (this script is a child of kuttl) and bail out if kuttl - # was started with --skip-delete. - pid=$PPID - while [ "${pid:-0}" -ge 1 ]; do - args=$(ps -o args= -p "$pid" 2>/dev/null) - case "$args" in - *kuttl*) - case "$args" in - *--skip-delete*) - echo "kuttl was started with --skip-delete, keeping the AirflowCluster" - exit 0 - ;; - esac - ;; - esac - pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d '[:space:]') - done - - kubectl delete airflowcluster airflow -n $NAMESPACE --wait=false 2>/dev/null || true - - if kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=120s 2>/dev/null; then - exit 0 - fi - kubectl delete pods -l app.kubernetes.io/name=airflow -n $NAMESPACE --grace-period=0 --force 2>/dev/null || true - kubectl wait --for=delete pod -l app.kubernetes.io/name=airflow -n $NAMESPACE --timeout=300s + - script: sh ../../../../templates/kuttl/commons/cleanup-executor-pods.sh