fix(platform): preserve no-delete label when migration 43 stamps version

Address review feedback from lexfrei on migrations/43: the version stamp
did a label-less `kubectl create configmap | kubectl apply` under the same
field manager migration 42 used, stripping the platform.cozystack.io/no-delete
label and dropping cozystack-version out of the deletion-protection guardrail on
every upgrade through this migration. Replace it with a labeled heredoc manifest
mirroring migration 42 so the label survives the stamp.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
Myasnikov Daniil committed 2026-06-01 18:47:07 +05:00
1 parent fd59dea234
commit 797284ab4f
1 file changed
+18 -3
@@ -27,6 +27,21 @@ for ns in $(kubectl get cluster.postgresql.cnpg.io -A \
fi
done
# Stamp version
kubectl create configmap -n cozy-system cozystack-version \
--from-literal=version=44 --dry-run=client -o yaml | kubectl apply -f-
# Stamp version.
# Mirror migration 42's labeled manifest. A label-less apply by the same field
# manager (kubectl create | kubectl apply) would strip the
# platform.cozystack.io/no-delete label migration 42 added, dropping
# cozystack-version out of the cozystack-no-delete-guardrail
# ValidatingAdmissionPolicy. templates/cozystack-version.yaml only re-renders the
# labeled ConfigMap on first install, so the label must be carried inline here.
kubectl apply --filename - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: cozystack-version
namespace: cozy-system
labels:
platform.cozystack.io/no-delete: "true"
data:
version: "44"
EOF