Skip to content

fix(postgres): run the collation repair outside the Helm hook - #5479

Draft
Andrey Kolkov (androndo) wants to merge 1 commit into
cozystack:mainfrom
androndo:fix/postgres-repair-after-rollout
Draft

Andrey Kolkov (androndo) wants to merge 1 commit into
cozystack:mainfrom
androndo:fix/postgres-repair-after-rollout

Conversation

@androndo

Copy link
Copy Markdown
Contributor

What this PR does

Refs #5459 (item 3: the repair waits for the rollout inside the Helm hook budget).

Work in progress, not ready for review. Verification on a dev cluster is still running, and the description will be completed with the results.

Today the init Job (a post-install/post-upgrade hook) runs the collation repair right after Helm patches the cnpg.io Cluster. It first waits until the primary runs the new image. With clients holding sessions, CNPG keeps every instance in smart shutdown for up to 180 s, so that wait alone can take 7–8 minutes and use up the hook budget. Upgrades then end in UpgradeFailed until Flux retries. On a dev cluster the first upgrade of every cluster whose image moves also failed with FATAL: the database system is shutting down.

The direction this PR takes:

  • The repair leaves the hook. It moves into its own Job, which a short post-upgrade hook creates through the API outside the release. The hook returns right away, so the upgrade no longer waits for the rollout or for the rebuild.
  • One repair per cluster. The repair Job has a fixed name and is owned by the Cluster, so two of them never run against one cluster and the Job goes away with it.
    • A repair Job still running on the image this release renders is left to finish.
    • Any other is deleted, and its pod is gone, before the new one is created. That also retries a repair that failed.
  • Deadline. The repair keeps an hour's deadline and bounds its lock waits by it.
  • Least privilege. The hook's Role reaches only the repair Job and the Cluster by name, except for create, which RBAC cannot narrow to a name. The Role is removed once the hooks succeed.

Release note

NONE

Work in progress: the repair moves into a Job the init hook starts through
the API, so it no longer waits for the rollout inside the hook budget.

Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files labels Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant