From 1e555204edb3a1f6c2a2bc843599ce074bb98ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Pieszka?= Date: Mon, 23 Sep 2024 11:49:19 +0200 Subject: [PATCH] KIM Integration - return from delete resource step with success when resource already deleted (#1173) Return from step with success when resource already deleted --- .../deprovisioning/delete_runtime_resource_step.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/process/deprovisioning/delete_runtime_resource_step.go b/internal/process/deprovisioning/delete_runtime_resource_step.go index f08b339ad6..47e781ef58 100644 --- a/internal/process/deprovisioning/delete_runtime_resource_step.go +++ b/internal/process/deprovisioning/delete_runtime_resource_step.go @@ -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 @@ -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)