Skip to content
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

Fix to check all canary resources are deleted #484

Merged
merged 2 commits into from
Jul 20, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/app/piped/executor/kubernetes/baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (e *Executor) ensureBaselineClean(ctx context.Context) model.StageStatus {

resources := strings.Split(value, ",")
if err := e.removeBaselineResources(ctx, resources); err != nil {
e.LogPersister.AppendErrorf("Unable to remove baseline resources: %v", err)
return model.StageStatus_STAGE_FAILURE
}
return model.StageStatus_STAGE_SUCCESS
Expand Down
1 change: 1 addition & 0 deletions pkg/app/piped/executor/kubernetes/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (e *Executor) ensureCanaryClean(ctx context.Context) model.StageStatus {

resources := strings.Split(value, ",")
if err := e.removeCanaryResources(ctx, resources); err != nil {
e.LogPersister.AppendErrorf("Unable to remove canary resources: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this log for baseline too?

return model.StageStatus_STAGE_FAILURE
}
return model.StageStatus_STAGE_SUCCESS
Expand Down
9 changes: 5 additions & 4 deletions pkg/app/piped/executor/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ func (e *Executor) applyManifests(ctx context.Context, manifests []provider.Mani
}

func (e *Executor) deleteResources(ctx context.Context, resources []provider.ResourceKey) error {
if len(resources) == 0 {
resourcesLen := len(resources)
if resourcesLen == 0 {
e.LogPersister.AppendInfo("No resources to delete")
return nil
}
Expand All @@ -224,9 +225,9 @@ func (e *Executor) deleteResources(ctx context.Context, resources []provider.Res
e.LogPersister.AppendErrorf("- unable to delete resource: %s (%v)", k.ReadableString(), err)
}

if deletedCount > 0 {
e.LogPersister.AppendInfof("Deleted %d/%d resources", deletedCount, len(resources))
return fmt.Errorf("unable to delete %d resources", len(resources)-deletedCount)
if deletedCount < resourcesLen {
e.LogPersister.AppendInfof("Deleted %d/%d resources", deletedCount, resourcesLen)
return fmt.Errorf("unable to delete %d resources", resourcesLen-deletedCount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

}

e.LogPersister.AppendSuccessf("Successfully deleted %d resources", len(resources))
Expand Down