Skip to content

Prune orphan resources during Kubernetes rollback#6805

Open
kubeboiii wants to merge 2 commits into
pipe-cd:masterfrom
kubeboiii:fix/k8s-rollback-prune-1972
Open

Prune orphan resources during Kubernetes rollback#6805
kubeboiii wants to merge 2 commits into
pipe-cd:masterfrom
kubeboiii:fix/k8s-rollback-prune-1972

Conversation

@kubeboiii
Copy link
Copy Markdown

What this PR does:

When a Kubernetes deployment fails and rollback runs, piped v0 now removes live resources that exist in the cluster but are not defined in the running commit. It reuses the same findRemoveResources and deleteResources helpers that the sync stage already uses.

Why we need it:

Rollback already re-applies manifests from RunningCommitHash and cleans up canary/baseline variants. It did not clean up new primary resources added in the failed commit. If commit B adds a Service and the pipeline fails after applying it, rollback would restore the old Deployment but leave that Service behind.

Which issue(s) this PR fixes:

Fixes #1972

Does this PR introduce a user-facing change?:

  • How are users affected by this change: Rollback after a failed deploy should leave the cluster closer to the last successful commit, including removing resources that only existed in the failed deploy.
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Test plan

  • go test ./pkg/app/piped/executor/kubernetes/... -run TestRollbackExecutor_pruneResourcesNotInRunningCommit -count=1
  • go test ./pkg/app/piped/executor/kubernetes/... -count=1 -skip TestExecutor_ensureSync

After rolling back manifests to the running commit, delete live
resources that were added in the failed deployment but are not defined
in that commit. Mirrors sync-stage pruning behavior.

Fixes pipe-cd#1972

Signed-off-by: Himanshu <himanshuwankhadeh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rollback stage for K8s app is not removing the newly added resources in the new commit

1 participant