operator: CrashLoopBackOff on startup from an SSA conflict on the platform PackageSource .spec.variants

Aperta
#5,351 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
67/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes

Direzione di ricerca

Start at the platform PackageSource apply in cmd/cozystack-operator/main.go near line 311, then trace how its server-side apply options are built. Reproduce the conflict using an object whose .spec.variants is owned by kubectl-client-side-apply. Done means the operator starts successfully with that stale field owner and reaches controller-manager startup.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

triage/needs-triage
What happens

After upgrading to v1.7.x, cozystack-operator enters CrashLoopBackOff. It exits during setup, before the controller manager starts:

INFO  setup  Creating platform PackageSource {"platformSourceName": "cozystack-platform"}
INFO  Applying platform PackageSource {"name": "cozystack.cozystack-platform"}
ERROR setup  failed to create platform PackageSource {"error": "failed to apply PackageSource cozystack.cozystack-platform: Apply failed with 1 conflict: conflict with \"kubectl-client-side-apply\" using cozystack.io/v1alpha1: .spec.variants"}
main.main
	/src/cmd/cozystack-operator/main.go:311
runtime.main
Root cause

The operator applies the platform PackageSource with a server-side apply (field manager cozystack-operator, operation Apply). On clusters where that object's .spec.variants is also owned by a kubectl-client-side-apply manager (operation Update), left over from a kubectl apply done client-side at install time or during an older release, the SSA conflicts. The operator does not set Force: true, so the apply fails and the process exits at cmd/cozystack-operator/main.go:311.

Because the operator never reaches its reconcile loop, no PackageSource is reconciled and no ArtifactGenerator is (re)generated. Already-running workloads keep serving from existing artifacts, but nothing new converges. In our case this surfaced downstream as bucket-*-system HelmReleases failing to render (no template "cozy-lib.ns-host-required", because the bucket-system ArtifactGenerator was never regenerated with the cozy-lib copy rule) and a stalled platform re-reconcile, which made it look like a bundling bug until the operator's own crash was found.

Impact

Any cluster upgrading to v1.7.x whose platform PackageSource.spec.variants was ever touched by a client-side kubectl apply gets a crashlooping operator and a frozen platform reconcile. Running workloads stay up, but nothing reconciles.

Workaround

Drop the stale kubectl-client-side-apply manager from the object, then restart the operator:

# find the index of the kubectl-client-side-apply manager
kubectl -n cozy-system get packagesources.cozystack.io cozystack.cozystack-platform --show-managed-fields -o json \
  | jq '.metadata.managedFields | to_entries[] | select(.value.manager=="kubectl-client-side-apply") | .key'
# remove that managedFields entry, then restart the operator
kubectl -n cozy-system patch packagesources.cozystack.io cozystack.cozystack-platform \
  --type=json -p='[{"op":"remove","path":"/metadata/managedFields/<index>"}]'
kubectl -n cozy-system rollout restart deploy/cozystack-operator
Suggested fix

Set Force: true on the operator's server-side apply of the platform PackageSource (it is the sole intended owner of that spec), or claim/migrate the kubectl-client-side-apply field manager on upgrade, so the apply cannot be blocked by a stale client-side-apply field owner.

Environment

Upgrade path to v1.7.1, Kube-OVN variant (isp-full), single management cluster.

Lingua principale
Go
Stelle
2.2k
Fork
209
Merge medio
4g 14h
PR unite (30g)
140

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cozystack/cozystack

Tutte le issue di cozystack/cozystack

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.