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>