Skip to content

Commit

Permalink
fixed an issue for generic sync that deleted referenced objects
Browse files Browse the repository at this point in the history
  • Loading branch information
facchettos committed Sep 17, 2024
1 parent 6143e22 commit 1774632
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ func (r *SyncController) Reconcile(ctx context.Context, origReq ctrl.Request) (_
// make sure the object uid matches
pAnnotations := pObj.GetAnnotations()
if !r.options.DisableUIDDeletion && pAnnotations[translate.UIDAnnotation] != "" && pAnnotations[translate.UIDAnnotation] != string(vObj.GetUID()) {
// requeue if object is already being deleted
if pObj.GetDeletionTimestamp() != nil {
return ctrl.Result{RequeueAfter: time.Second}, nil
if pAnnotations[translate.KindAnnotation] == "" || pAnnotations[translate.KindAnnotation] == r.syncer.GroupVersionKind().String() {
// requeue if object is already being deleted
if pObj.GetDeletionTimestamp() != nil {
return ctrl.Result{RequeueAfter: time.Second}, nil
}

// delete physical object
return DeleteHostObject(syncContext, pObj, "virtual object uid is different")
}

// delete physical object
return DeleteHostObject(syncContext, pObj, "virtual object uid is different")
}

return r.genericSyncer.Sync(syncContext, &synccontext.SyncEvent[client.Object]{
Expand Down

0 comments on commit 1774632

Please sign in to comment.