mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
Migration 64 converts the existing Postgres releases. It first applies the CredentialTemplate CRD baked into its image, owned by the cozystack-controller release so that release's upgrade adopts it: on a live upgrade the tenant releases switched to the converted chart about 17 minutes before cozystack-controller upgraded, and every render in between failed on the unknown kind. It then runs credentials-migrate seed, which writes the account Secrets from <release>-credentials so clients keep logging in at every point of the upgrade. A release that grants createRole is left out and keeps its previous chart. The finish half runs from a Job the migration creates, not from the platform chart: a chart-rendered Job has a fixed name and an image that changes every release, so the next platform upgrade cannot patch its immutable pod template, and helm-controller would wait on a Job that runs up to 30 minutes and exits non-zero while any release is left out. The Job runs the image the hook runs as, read from its own pod, under a least-privilege ClusterRole rather than cluster-admin, and its ServiceAccount is owned by the Job so the garbage collector removes it. The identity carries the migration number like the Job, so a later conversion migration cannot delete the ServiceAccount a still-running earlier Job uses. The CredentialsMigrationIncomplete alert keys on the incomplete label of the state ConfigMap through kube-state-metrics, which allowlists only that one ConfigMap label, so a release whose plaintext was never retired stays visible after the Job's TTL. The bats suite pins the CRD apply, seed, image read, Job apply, ownership and stamp steps as fail-closed; its fake kubectl counts the Job's name inside the Job document only. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Co-authored-by: Andrei Kvapil <kvapss@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
23 lines
696 B
Bash
Executable File
23 lines
696 B
Bash
Executable File
#!/bin/sh
|
|
# Fake credentials-migrate for hack/migration-64-postgres-credentials.bats.
|
|
# Migration 64 runs `credentials-migrate seed` in the hook; the real binary is
|
|
# exercised by cmd/credentials-migrate's Go tests, so this fake only records the
|
|
# call and fails on demand to pin the hook's fail-closed behaviour.
|
|
#
|
|
# FAKE_CMDLOG file to append a one-line record of each call to
|
|
# FAKE_SEED_FAIL non-empty => `seed` exits 1 with this stderr
|
|
set -u
|
|
|
|
[ -n "${FAKE_CMDLOG:-}" ] && printf 'CREDMIGRATE %s\n' "$*" >> "$FAKE_CMDLOG"
|
|
|
|
case "${1:-}" in
|
|
seed)
|
|
if [ -n "${FAKE_SEED_FAIL:-}" ]; then
|
|
printf '%s\n' "$FAKE_SEED_FAIL" >&2
|
|
exit 1
|
|
fi
|
|
exit 0
|
|
;;
|
|
esac
|
|
exit 0
|