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

Ouverte
#5,351 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
67/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
go, kubernetes

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Go
Étoiles
2.2k
Forks
209
Merge moyen
4 j 14 h
PR mergées (30 j)
140

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de cozystack/cozystack

Toutes les issues de cozystack/cozystack

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.