Skip to content

feat(chartreuse): post-deployment Job restoring Deployments stranded at 0 replicas#885

Merged
arthlr merged 1 commit into
mainfrom
chartreuse-restore
Jul 8, 2026
Merged

feat(chartreuse): post-deployment Job restoring Deployments stranded at 0 replicas#885
arthlr merged 1 commit into
mainfrom
chartreuse-restore

Conversation

@arthlr

@arthlr arthlr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Problem

With upgradeBeforeDeployment, the chartreuse migration Job skips start_pods() and relies on the deployment that follows to restore replicas. HPA-managed Deployments omit spec.replicas in their chart, so nothing ever restores them, and an HPA whose target is at 0 replicas with minReplicas >= 1 is ScalingDisabled forever: they stay stranded at 0 after every migration (hit pythie-cayzn-staging-demo on 2026-07-07).

Fix

  • New chartreuse-restore Job rendered as an ArgoCD PostSync hook (argocd mode only, gated by the new restorePods value + stopPods + upgradeBeforeDeployment): runs once the new pod template is applied, so it only ever starts new-version pods. It re-enables HPAs and scales back up the Deployments that the migration stopped — tracked via the wiremind.io/stopped-by annotation, so deliberately-stopped Deployments are left alone.
  • Role: add patch on deployments (needed for the annotation).
  • In Helm mode the pre-upgrade -ephemeral resource set is deleted right after the migration hook, so the restore Job is not rendered there (documented in the template header); Helm-mode behavior is unchanged.

Version coupling

appVersion bumped to 7.0.0: the restore entrypoint ships in chartreuse 7.0.0 (wiremind/chartreuse#55). App images must be rebuilt with it before picking up this chart version — ensure_safe_run aborts on a major.minor mismatch, and the restore Job's entrypoint doesn't exist in older images.

Companion PR: wiremind/chartreuse#55

🤖 Generated with Claude Code

…at 0 replicas

With upgradeBeforeDeployment, the migration Job intentionally skips start_pods()
and relies on the deployment that follows to restore replicas. That works for
Deployments whose chart sets spec.replicas, but HPA-managed ones omit it and an
HPA whose target is at 0 replicas with minReplicas >= 1 is ScalingDisabled: they
stayed stranded at 0 after every migration.

Render a chartreuse-restore Job as an ArgoCD PostSync hook (argocd mode only,
gated by the new restorePods value) that re-enables HPAs and scales the stopped
Deployments back up once the new pod template is applied. Grant patch on
deployments so chartreuse can track the Deployments it stopped via an annotation.

Requires a chartreuse image >= 7.0 (appVersion bumped accordingly).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@arthlr arthlr self-assigned this Jul 8, 2026
@arthlr
arthlr merged commit 7b8a2de into main Jul 8, 2026
2 checks passed
@arthlr
arthlr deleted the chartreuse-restore branch July 8, 2026 15:49
@arthlr

arthlr commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Canary validated on pythie-cayzn-staging-demo: the job-restore.yaml PostSync hook rendered by this chart ran after a real upgradeBeforeDeployment migration and restored the HPA-managed workers that the migration had stopped (annotations cleared, HPAs re-armed, minReplicas enforced). Companion package PR: wiremind/chartreuse#55 (validated together).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant