Skip to content

Commit 70320e0

Browse files
fix(platform): stamp migrations 45/46 via the cozystack-version helper
Migrations 45 and 46 (added by #2931) stamp the cozystack-version ConfigMap with an inline `kubectl apply` heredoc instead of sourcing lib/cozystack-version.sh and calling stamp_cozystack_version, the way 42/43/44 do. The cozystack-version-stamp.bats guard forbids any migration >= 42 from bypassing the helper, so `make bats-unit-tests` fails on migration 45. This only surfaces in PR CI (make unit-tests); main-push CI does not run the bats suite, so #2931 landed red on this test and now blocks every PR that merges current main. Route both stamps through the helper. The helper renders a byte-identical labeled manifest (golden-pinned in the bats suite), so this is behaviour- preserving — it just restores the no-label-drift guarantee the heredoc form could silently lose. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent f4a000e commit 70320e0

2 files changed

Lines changed: 18 additions & 36 deletions

File tree

  • packages/core/platform/images/migrations/migrations

‎packages/core/platform/images/migrations/migrations/45‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939

4040
set -euo pipefail
4141

42+
# shellcheck source=lib/cozystack-version.sh
43+
. "$(dirname "$0")/lib/cozystack-version.sh"
44+
4245
DRY_RUN="${MIGRATION_DRY_RUN:-0}"
4346
FAILURES=0
4447
PATCHED=0
@@ -118,21 +121,9 @@ if [ "$FAILURES" -gt 0 ]; then
118121
exit 1
119122
fi
120123

121-
# Stamp version=46. Mirror migration 43's labeled heredoc — a label-less
122-
# apply by the same field manager (kubectl create cm | kubectl apply)
123-
# would strip the platform.cozystack.io/no-delete label migration 42
124-
# added, dropping cozystack-version out of the
125-
# cozystack-no-delete-guardrail ValidatingAdmissionPolicy.
126-
# templates/cozystack-version.yaml only re-renders the labeled ConfigMap
127-
# on first install, so the label must be carried inline here.
128-
kubectl apply --filename - <<EOF
129-
apiVersion: v1
130-
kind: ConfigMap
131-
metadata:
132-
name: cozystack-version
133-
namespace: cozy-system
134-
labels:
135-
platform.cozystack.io/no-delete: "true"
136-
data:
137-
version: "46"
138-
EOF
124+
# Stamp version=46. The labeled manifest lives in the shared helper so it
125+
# cannot drift back to a label-less apply that strips the
126+
# platform.cozystack.io/no-delete label migration 42 added (which would drop
127+
# cozystack-version out of the cozystack-no-delete-guardrail
128+
# ValidatingAdmissionPolicy).
129+
stamp_cozystack_version 46

‎packages/core/platform/images/migrations/migrations/46‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
set -euo pipefail
2323

24+
# shellcheck source=lib/cozystack-version.sh
25+
. "$(dirname "$0")/lib/cozystack-version.sh"
26+
2427
DRY_RUN="${MIGRATION_DRY_RUN:-0}"
2528
FAILURES=0
2629
PATCHED=0
@@ -107,21 +110,9 @@ fi
107110
kubectl annotate configmap --namespace cozy-system cozystack-version \
108111
"cozystack.io/migration-46-failed-tenants-" >/dev/null 2>&1 || true
109112

110-
# Stamp version=47. Mirror migration 43's labeled heredoc — a label-less
111-
# apply by the same field manager (kubectl create cm | kubectl apply)
112-
# would strip the platform.cozystack.io/no-delete label migration 42
113-
# added, dropping cozystack-version out of the
114-
# cozystack-no-delete-guardrail ValidatingAdmissionPolicy.
115-
# templates/cozystack-version.yaml only re-renders the labeled ConfigMap
116-
# on first install, so the label must be carried inline here.
117-
kubectl apply --filename - <<EOF
118-
apiVersion: v1
119-
kind: ConfigMap
120-
metadata:
121-
name: cozystack-version
122-
namespace: cozy-system
123-
labels:
124-
platform.cozystack.io/no-delete: "true"
125-
data:
126-
version: "47"
127-
EOF
113+
# Stamp version=47. The labeled manifest lives in the shared helper so it
114+
# cannot drift back to a label-less apply that strips the
115+
# platform.cozystack.io/no-delete label migration 42 added (which would drop
116+
# cozystack-version out of the cozystack-no-delete-guardrail
117+
# ValidatingAdmissionPolicy).
118+
stamp_cozystack_version 47

0 commit comments

Comments
 (0)