Skip to content

Commit

Permalink
fix svcim cleanup logic
Browse files Browse the repository at this point in the history
Signed-off-by: Mridul Gain <[email protected]>
  • Loading branch information
mridulgain committed Jul 8, 2024
1 parent e5aa6f2 commit 9090a0f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/hub/controllers/serviceimport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (r *ServiceImportReconciler) handleSvcimDeletion(svcim *spokev1alpha1.Worke
if controllerutil.ContainsFinalizer(svcim, svcimFinalizer) {
log.Info("deleting serviceimport")
// our finalizer is present, so lets handle any external dependency
if err := r.DeleteServiceImportOnSpoke(ctx, svcim); err != nil && !errors.IsNotFound(err) {
if err := r.DeleteServiceImportOnSpoke(ctx, svcim); err != nil {
// if fail to delete the external dependency here, return with error
// so that it can be retried
log.Error(err, "unable to delete service import on spoke")
Expand All @@ -292,6 +292,7 @@ func (r *ServiceImportReconciler) handleSvcimDeletion(svcim *spokev1alpha1.Worke
return false, reconcile.Result{}, nil
}

// delete service import, if exists
func (r *ServiceImportReconciler) DeleteServiceImportOnSpoke(ctx context.Context, svcim *spokev1alpha1.WorkerServiceImport) error {
log := logger.FromContext(ctx)

Expand All @@ -303,7 +304,7 @@ func (r *ServiceImportReconciler) DeleteServiceImportOnSpoke(ctx context.Context
}

err := r.MeshClient.Delete(ctx, svcimOnSpoke)
if err != nil {
if err != nil && !errors.IsNotFound(err) {
return err
}

Expand Down

0 comments on commit 9090a0f

Please sign in to comment.