Skip to content

Commit

Permalink
KIM Integration - return from delete resource step with success when …
Browse files Browse the repository at this point in the history
…resource already deleted (#1173)

Return from step with success when resource already deleted
  • Loading branch information
jaroslaw-pieszka authored Sep 23, 2024
1 parent cdf1058 commit 1232cad
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/process/deprovisioning/delete_runtime_resource_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ func (step *DeleteRuntimeResourceStep) Run(operation internal.Operation, logger

var runtime = imv1.Runtime{}
err := step.kcpClient.Get(context.Background(), client.ObjectKey{Name: resourceName, Namespace: resourceNamespace}, &runtime)
if err != nil && !errors.IsNotFound(err) {
logger.Warnf("Unable to read runtime: %s", err)
return step.operationManager.RetryOperation(operation, err.Error(), err, 5*time.Second, 1*time.Minute, logger)
if err != nil {
if !errors.IsNotFound(err) {
logger.Warnf("Unable to read runtime: %s", err)
return step.operationManager.RetryOperation(operation, err.Error(), err, 5*time.Second, 1*time.Minute, logger)
} else {
logger.Info("Runtime resource already deleted")
return operation, 0, nil
}
}

controlledByKimOnly := !runtime.IsControlledByProvisioner()
operation, backoff, _ := step.operationManager.UpdateOperation(operation, func(operation *internal.Operation) {
operation.KimDeprovisionsOnly = controlledByKimOnly
Expand All @@ -79,7 +85,7 @@ func (step *DeleteRuntimeResourceStep) Run(operation internal.Operation, logger

// if the resource is not found, log it and return (it is not a problem)
if errors.IsNotFound(err) {
logger.Info("Runtime resource deleted")
logger.Info("Runtime resource already deleted")
return operation, 0, nil
} else {
logger.Warnf("unable to delete the Runtime resource %s/%s: %s", runtime.Name, runtime.Namespace, err)
Expand Down

0 comments on commit 1232cad

Please sign in to comment.