Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
IvanHunters
e3c31d08cd fix(migrations): remove migration 37
Migration 37 attempted to backfill PostgreSQL version field, but this
approach is not needed. Removing to simplify the migration path.

Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-04-02 21:29:47 +03:00

View file

@ -1,43 +0,0 @@
#!/bin/sh
# Migration 37 --> 38
# Backfill spec.version on postgreses.apps.cozystack.io resources.
#
# Before this migration PostgreSQL had a default version field set to v18.
# This migration sets spec.version to "v17" for any postgres app resource that
# does not already have it set, to ensure compatibility with monitoring
# configurations that are hardcoded to PostgreSQL 17.
set -euo pipefail
DEFAULT_VERSION="v17"
# Skip if the CRD does not exist (postgres was never installed)
if ! kubectl api-resources --api-group=apps.cozystack.io -o name 2>/dev/null | grep -q '^postgreses\.'; then
echo "CRD postgreses.apps.cozystack.io not found, skipping migration"
kubectl create configmap -n cozy-system cozystack-version \
--from-literal=version=38 --dry-run=client -o yaml | kubectl apply -f-
exit 0
fi
POSTGRESES=$(kubectl get postgreses.apps.cozystack.io -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}')
for resource in $POSTGRESES; do
NS="${resource%%/*}"
APP_NAME="${resource##*/}"
# Skip if spec.version is already set
CURRENT_VER=$(kubectl get postgreses.apps.cozystack.io -n "$NS" "$APP_NAME" \
-o jsonpath='{.spec.version}')
if [ -n "$CURRENT_VER" ]; then
echo "SKIP $NS/$APP_NAME: spec.version already set to '$CURRENT_VER'"
continue
fi
echo "Patching postgres/$APP_NAME in $NS: setting version=$DEFAULT_VERSION"
kubectl patch postgreses.apps.cozystack.io -n "$NS" "$APP_NAME" --type=merge \
--patch "{\"spec\":{\"version\":\"${DEFAULT_VERSION}\"}}"
done
# Stamp version
kubectl create configmap -n cozy-system cozystack-version \
--from-literal=version=38 --dry-run=client -o yaml | kubectl apply -f-