From 40e219c0b6f8893ba7baca6cb5d4abeabbaa475b Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Mon, 16 Nov 2026 13:24:56 +0300 Subject: [PATCH] fix(capi-providers-core): keep the upgrade Job until the next attempt With hook-succeeded the Job is removed after a successful run, and before-hook-creation already removes a failed one only when the next attempt starts. Keeping the Job after success as well leaves the last run's pod logs readable whichever way it ended; the next attempt still replaces it. The ConfigMap and RBAC objects keep both policies. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- hack/capi-upgrade-chart_test.bats | 5 +++++ .../system/capi-providers-core/templates/upgrade-hook.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hack/capi-upgrade-chart_test.bats b/hack/capi-upgrade-chart_test.bats index ac7b0c5c5..964561d7e 100644 --- a/hack/capi-upgrade-chart_test.bats +++ b/hack/capi-upgrade-chart_test.bats @@ -22,6 +22,11 @@ setup() { [ "$provider" = "$target-core" ] } +@test "the upgrade Job is kept until the next attempt, after a success too" { + [ "$(yq --no-doc 'select(.kind == "Job") | .metadata.annotations."helm.sh/hook-delete-policy"' "$RENDERED")" = before-hook-creation ] + [ "$(yq --no-doc 'select(.kind != "Job" and .metadata.annotations."helm.sh/hook" != null) | .metadata.annotations."helm.sh/hook-delete-policy"' "$RENDERED" | sort --unique)" = before-hook-creation,hook-succeeded ] +} + @test "the operator retains intermediate bundles independently of migration hooks" { local name bridge policy rendered="$BATS_TEST_TMPDIR/operator.yaml" bridge="$(< "$CORE/files/bridge-version")" diff --git a/packages/system/capi-providers-core/templates/upgrade-hook.yaml b/packages/system/capi-providers-core/templates/upgrade-hook.yaml index 3f09489ca..cb7e1dea8 100644 --- a/packages/system/capi-providers-core/templates/upgrade-hook.yaml +++ b/packages/system/capi-providers-core/templates/upgrade-hook.yaml @@ -86,7 +86,7 @@ metadata: annotations: helm.sh/hook: pre-install,pre-upgrade helm.sh/hook-weight: "0" - helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded + helm.sh/hook-delete-policy: before-hook-creation spec: backoffLimit: 0 activeDeadlineSeconds: {{ add $timeout 60 }}