fix(platform): make etcd v1alpha2 adoption (migration 50) robust in-cluster - #3258
Closed
Andrey Kolkov (androndo) wants to merge 1 commit into
Closed
Conversation
…luster Migration 50 (etcd.aenix.io -> etcd-operator.cozystack.io/v1alpha2 adoption) had two defects that blocked every in-cluster 1.5 -> 1.6 upgrade on a cluster with an existing etcd: 1. Cert-SAN wait treated transient kubectl failures as "SAN absent". ensure_wildcard_sans checked/awaited the wildcard SAN with `kubectl get ... 2>/dev/null | grep`, so any transient GET failure (API discovery refresh, apiserver blip, throttling) produced an empty string indistinguishable from a genuine absence -> false miss, and the 120s wait never recovered. Replace the two ad-hoc checks with a _san_present helper that retries on an empty read (a real Certificate/Secret never has empty dnsNames/alt-names) and accepts the native wildcard from EITHER the issued Secret's cert-manager.io/alt-names annotation OR the Certificate spec.dnsNames (the source of truth for what cert-manager will issue). 2. etcd-migrate had no kubeconfig in-cluster. etcd-migrate only reads a kubeconfig file (-k/--kubeconfig, default /root/.kube/config) and, unlike kubectl, does not fall back to the mounted in-cluster ServiceAccount. The hook Job set no KUBECONFIG and passed no --kubeconfig, so both the dry-run and --apply aborted with "error building kubeconfig: stat /root/.kube/config: no such file". Synthesize an in-cluster kubeconfig from the mounted ServiceAccount and pass --kubeconfig to both etcd-migrate invocations. Verified end-to-end on a 1.5.2 -> 1.6.0-rc.1 upgrade: the adoption now completes in-place (pods never restarted, data intact) and the cluster reaches readyMembers=3 / Available=True. Refs: cozystack#3243, cozystack#3255 Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Andrey Kolkov <androndo@gmail.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Fixes two defects in platform migration 50 (etcd
etcd.aenix.io→etcd-operator.cozystack.io/v1alpha2adoption, #2859) that block every in-cluster 1.5 → 1.6 upgrade on a cluster with an existing etcd:Cert-SAN wait treated transient kubectl failures as "SAN absent."
ensure_wildcard_sanschecked/awaited the wildcard SAN withkubectl get … 2>/dev/null | grep; any transient GET failure (API discovery refresh, apiserver blip, throttling) yields an empty string indistinguishable from a genuine absence → false miss, and the 120s wait never recovers. Replaced the two checks with a_san_presenthelper that retries on an empty read (a real Certificate/Secret never has emptydnsNames/alt-names) and accepts the native wildcard from either the issued Secret'scert-manager.io/alt-namesannotation or the Certificatespec.dnsNames. This is the deeper root cause behind etcd v1alpha2 adoption migration hard-fails 1.5→1.6 upgrade on clusters with an existing etcd #3243's "cert re-issue race (times out a few seconds too early)".etcd-migratehad no kubeconfig in-cluster (etcd v1alpha2 adoption (migration 50): etcd-migrate has no kubeconfig in-cluster → adoption aborts #3255).etcd-migrateonly reads a kubeconfig file (-k/--kubeconfig, default/root/.kube/config) and, unlikekubectl, does not fall back to the mounted in-cluster ServiceAccount. Neither the hook Job nor the script provided one, so both the dry-run and--applyaborted witherror building kubeconfig: stat /root/.kube/config: no such file. Now the script synthesizes an in-cluster kubeconfig from the mounted ServiceAccount and passes--kubeconfigto bothetcd-migratecalls.Scope is limited to
packages/core/platform/images/migrations/migrations/50(a shell script — nomake generateartifacts affected).Verification
Verified end-to-end on a real 1.5.2 → 1.6.0-rc.1 upgrade (3-node cluster): with these fixes the pre-upgrade hook passes the cert step reliably and
etcd-migrateruns, so the adoption completes in-place (etcd pods never restarted, data intact) and the adoptedEtcdClusterreachesreadyMembers=3 / Available=True.