Lesson 09 of 10 · Delivery and operations
Failed upgrades and recovery
Recover when helm upgrade goes wrong: read the release state, roll back or unlock a stuck release, fix immutable-field and ownership errors, and set up pipelines so it happens less often.
Read the state first
$ helm history orders -n shop
REVISION STATUS DESCRIPTION
7 superseded Upgrade complete
8 deployed Upgrade complete
9 pending-upgrade Preparing upgrade
Then check what Kubernetes says: events, pod status, failing resources. Decide whether the application is down or only the release is marked failed. Those need different urgency.
If the school bus breaks down halfway through changing routes, first check where the children are (the app), then fix the timetable on the noticeboard (the release record). Don't repaint the board while children wait in the rain.
Common failures and fixes
| Symptom | Cause | Fix |
|---|---|---|
| "another operation is in progress" | An interrupted upgrade left pending-upgrade / pending-rollback |
helm rollback to the last deployed revision. Editing the release Secret's status is a documented last resort only |
spec.selector: field is immutable |
Changed Deployment selector labels | Revert the selector, or plan a replacement (new name, or delete and recreate with a short gap) |
| StatefulSet update forbidden | Changed volumeClaimTemplates (immutable) |
Revert; expand PVCs directly; plan a migration if templates must change |
| "invalid ownership metadata" | Object exists without Helm's ownership marks | Adopt it (label app.kubernetes.io/managed-by: Helm, annotations meta.helm.sh/release-name and meta.helm.sh/release-namespace) or delete it |
| Timeout waiting for readiness | New pods never become Ready (image, probe, config, quota) | Fix the cause; with --atomic the release already rolled back |
| Hook Job failed | Migration or test hook error | Read the Job's logs; fix and rerun; make hooks idempotent |
Make it rarer
- Use
upgrade --install --atomic --wait --timeoutin pipelines, so failures roll back automatically. - Never cancel a running upgrade casually; if a pipeline must stop, follow it with a rollback step.
- Run
helm diffor a server-side dry run before production upgrades; review immutable-field changes explicitly. - Prefer GitOps for production: Argo CD has no Helm release lock, and recovery is
git revert. - Test upgrades from the previous version in CI (chart-testing
--upgrade), not only fresh installs.
Try it
Install a chart, then start helm upgrade with a deliberately unready image and --wait --timeout 5m, and press Ctrl+C after a few seconds. Run helm history: the release is pending-upgrade, and the next upgrade fails. Recover with helm rollback to the last deployed revision. Then change a Deployment's selector labels and observe the immutable-field error.
Recap
- Read release history and cluster events; separate app impact from release state.
- Stuck releases: roll back to the last deployed revision. Immutable fields: revert or plan a replacement. Ownership errors: adopt or remove.
- Pipelines with
--atomic, diffs, upgrade tests and GitOps make failures rarer and recovery simpler.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.