Skip to content

Ensure Cleanup is called if Deploy creates resources but fails #6345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/skaffold/runner/v1/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func (r *SkaffoldRunner) applyResources(ctx context.Context, out io.Writer, arti
defer endTrace()
r.deployer.RegisterLocalImages(localImages)
err = r.deployer.Deploy(ctx, deployOut, artifacts)
r.hasDeployed = true // set even if deploy may have failed, because we want to cleanup any partially created resources
postDeployFn()
if err != nil {
event.DeployFailed(err)
endTrace(instrumentation.TraceEndError(err))
return err
}
r.hasDeployed = true
event.DeployComplete()
return nil
}
3 changes: 1 addition & 2 deletions pkg/skaffold/runner/v1/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ See https://skaffold.dev/docs/pipeline-stages/taggers/#how-tagging-works`)

r.deployer.RegisterLocalImages(localAndBuiltImages)
err = r.deployer.Deploy(ctx, deployOut, artifacts)
r.hasDeployed = true // set even if deploy may have failed, because we want to cleanup any partially created resources
postDeployFn()
if err != nil {
event.DeployFailed(err)
Expand All @@ -121,8 +122,6 @@ See https://skaffold.dev/docs/pipeline-stages/taggers/#how-tagging-works`)
return err
}

r.hasDeployed = true

statusCheckOut, postStatusCheckFn, err := deployutil.WithStatusCheckLogFile(time.Now().Format(deployutil.TimeFormat)+".log", out, r.runCtx.Muted())
defer postStatusCheckFn()
if err != nil {
Expand Down