Skip to content

Runbook: Helm upgrade stuck / failed

Symptômes : - helm upgrade akko ne rend pas la main après 15 min - Erreur cannot patch "X" with kind Y: ... forbidden - UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress - SSH CI client_loop: send disconnect: Broken pipe


Diagnostic

1. Release state

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

helm list -n akko
helm status akko -n akko
helm history akko -n akko | head -10

Statut possible : - deployed : OK, précédent upgrade terminé - pending-upgrade : upgrade en cours OU bloqué - failed : upgrade a échoué

2. Pods en attente

kubectl get pods -n akko | grep -vE 'Running|Completed'

3. Events récents

kubectl get events -n akko --sort-by='.lastTimestamp' | tail -30

Cas fréquents

Cas 1 : another operation ... is in progress

Un helm upgrade précédent est coincé dans pending-upgrade.

# Vérifier
helm status akko -n akko | head -5

# Si pending et le process ne tourne plus (SSH killed, etc.) :
# Retirer manuellement le lock
helm --kube-token=$(cat ~/.kube/token) upgrade --rollback akko -n akko
# Ou via secret
kubectl delete secret -n akko -l owner=helm,status=pending-upgrade

Cas 2 : cannot patch PVC ... forbidden: only dynamically provisioned pvc can be resized

Cause : local-path storageClass ne supporte pas le resize online (L09).

Fix pérenne : aligner les values sur le live.

# Voir taille actuelle
kubectl get pvc -n akko -o custom-columns=NAME:.metadata.name,SIZE:.spec.resources.requests.storage

# Éditer helm/examples/values-netcup.yaml pour matcher le live
# Exemple : si akko-grafana PVC = 1Gi mais values dit 5Gi, mettre 1Gi
# Commit + push → CI redeploy

Cas 3 : StatefulSet ... spec: Forbidden: updates to statefulset spec ... are forbidden

Cause : Helm essaie de modifier un champ immuable du StatefulSet (volumeClaimTemplates, selector).

Fix : aligner ou delete+recreate (avec perte de data si pas de backup).

# Backup avant
bash helm/scripts/demo/banking/seed.sh --backup  # ou similaire

# Delete StatefulSet (les PVCs restent)
kubectl delete sts akko-postgresql -n akko --cascade=orphan

# Relancer helm upgrade
# Le STS sera recreé avec la nouvelle spec, les PVCs réattachés

Cas 4 : SSH Broken Pipe pendant CI deploy

Cause : helm upgrade long (hooks OM OIDC + rollouts) → SSH idle killed.

Fix pérenne (déjà appliqué) : ServerAliveInterval=30 CountMax=120 dans .github/workflows/deploy-netcup.yml.

Si ça revient : augmenter encore le timeout.


Rollback

Si l'upgrade a mis le cluster dans un état incohérent :

# Voir les revisions disponibles
helm history akko -n akko

# Rollback à la dernière revision qui était "deployed"
helm rollback akko <rev-num> -n akko

# Attendre la réconciliation
kubectl rollout status deploy -n akko --timeout=5m

Fix pérenne (règle R02)

Si l'upgrade a échoué à cause d'une config dans les values, fix dans Git :

  1. Identifier le fichier values (helm/examples/values-*.yaml ou helm/akko/values.yaml)
  2. Appliquer le fix (avec commentaire explicatif)
  3. Commit + push
  4. CI redeploy auto

Jamais de kubectl patch ou helm upgrade ad hoc depuis le serveur.


Prévention

  • helm lint + helm template --debug en CI (workflow helm-lint.yml)
  • Dry-run avant apply : helm upgrade ... --dry-run
  • Backup auto avant chaque upgrade (via Velero ou CronJob)