Skip to content

Commit

Permalink
fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Despire committed Sep 26, 2023
1 parent 80ae48d commit 5f33c93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions services/builder/domain/usecases/workflow_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ func (u *Usecases) saveWorkflowDescription(ctx *utils.BuilderContext, descriptio

// deleteConfig calls destroy config to remove all traces of infrastructure from given config.
func (u *Usecases) deleteConfig(config *pb.Config, clusterView *cutils.ClusterView, cboxClient pb.ContextBoxServiceClient) error {
log := cutils.CreateLoggerWithProjectName(config.Name)

var err error
// Try maxDeleteRetry to delete the config.
for i := 0; i < maxDeleteRetry; i++ {
if err = u.destroyConfig(config, clusterView, cboxClient); err == nil {
// Deletion successful, break here.
break
}
log.Err(err).Msg("failed to destroy config")
}
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (k *KubeEleven) DestroyCluster() error {
}

if err := kubeone.Reset(clusterID); err != nil {
return fmt.Errorf("error while running \"kubeone reset\" in %s: %w", k.outputDirectory, err)
log.Warn().Msgf("failed to destroy cluster and remove binaries: %s, assuming they were deleted", err)
}

if err := os.RemoveAll(k.outputDirectory); err != nil {
Expand Down

0 comments on commit 5f33c93

Please sign in to comment.