Skip to content

Run the upgrade preflight from a chart pre-upgrade hook - #98

Open
recharte wants to merge 3 commits into
mainfrom
feat/upgrade-preflight-hook
Open

Run the upgrade preflight from a chart pre-upgrade hook#98
recharte wants to merge 3 commits into
mainfrom
feat/upgrade-preflight-hook

Conversation

@recharte

@recharte recharte commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

Completes Part 1 of the provider upgrades feature for PSMDB (spec 009 §6.3): the compatibility/upgrade-path preflight now actually gates helm upgrade.

  • --preflight-spec mode in the provider binary: runs provider-runtime/preflight.Run against the target Provider spec and exits non-zero on any blocking issue (openeverest#3069).
  • templates/preflight-hook.yaml: pre-upgrade hook resources — a ConfigMap carrying the target catalog (rendered from the same generated/provider-spec.yaml this release applies, so the catalog has one source of truth), ephemeral read-only RBAC (providers/instances + psmdb CRs for provider-specific checks), and a Job running the new provider image in preflight mode. A non-zero exit aborts the upgrade before any resource is applied; the hook never runs on install.
  • The Job exposes TARGET_OPERATOR_VERSION (the bundled operator subchart version, resolved from .Chart.Dependencies) for provider-specific upgrade checks — consumed by the skew-window check in the follow-up PR.
  • Regenerated provider-spec.yaml with the current provider-sdk (generate: emit spec.release and pass through catalog deprecation flags provider-sdk#40): the spec now carries release.version: 0.1.0 from the chart appVersion, which the preflight uses for upgrade-path reporting. No minUpgradableFrom floor yet — nothing older than this release exists to step from.

Verification

go build/go test pass; helm template renders the hook with the mounted spec, args, and TARGET_OPERATOR_VERSION: "1.22.0". End-to-end hook behavior (blocked vs passing upgrade) is exercised once this and the skew-check PR land together — the §9 walkthrough validation pass.

Wire the provider-runtime preflight into the chart: a pre-upgrade hook
Job runs the new provider image with --preflight-spec against the target
catalog (a ConfigMap rendered from the same generated provider-spec.yaml
the release applies) and the live Instances, aborting the upgrade before
anything is applied when a blocking issue is found. Hook resources are
ephemeral with read-only RBAC; the hook never runs on install.

The Job also exposes TARGET_OPERATOR_VERSION (the bundled operator
subchart version) for provider-specific upgrade checks.

Regenerating with the current provider-sdk adds release.version (from
the chart appVersion) to the generated provider spec, which the
preflight uses to report the upgrade path.

Signed-off-by: Diogo Recharte <diogo.recharte@solanica.io>
The hook pod now honors imagePullSecrets (it is by design the first
pull of the new image), podSecurityContext/securityContext and
resources (PSS-restricted and quota'd namespaces), and
nodeSelector/affinity/tolerations (tainted clusters), mirroring the
main deployment. activeDeadlineSeconds bounds unschedulable pods to a
deterministic failure instead of the Helm timeout. The operator-version
env is derived from the same subchart value as the deployment, and the
hook ConfigMap carries the Service's selector labels. Preflight infra
errors now reach the preserved pod log via stderr (the
controller-runtime logger is not initialized on that path), and CI
asserts the rendered hook contract.

Signed-off-by: Diogo Recharte <diogo.recharte@solanica.io>
@recharte
recharte force-pushed the feat/upgrade-preflight-hook branch from d9d0adf to 8356b00 Compare September 3, 2026 15:44
helm dependency build resolves the psmdb-operator subchart from
percona.github.io, which the runner has no repo definition for.

Signed-off-by: Diogo Recharte <diogo.recharte@solanica.io>
@recharte
recharte marked this pull request as ready for review September 3, 2026 22:26
@recharte
recharte requested a review from chilagrow September 3, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants