Skip to content

Commit

Permalink
resource synch process for delete event
Browse files Browse the repository at this point in the history
Signed-off-by: huiwq1990 <[email protected]>
  • Loading branch information
huiwq1990 committed Nov 17, 2023
1 parent 41975c5 commit c4fcd8f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/synchromanager/clustersynchro/resource_synchro.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,18 @@ func (synchro *ResourceSynchro) OnDelete(obj interface{}) {
return
}

key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
return
if d, ok := obj.(cache.DeletedFinalStateUnknown); ok {
if obj, ok = d.Obj.(*unstructured.Unstructured); !ok {
namespace, name, err := cache.SplitMetaNamespaceKey(d.Key)
if err != nil {
return
}
obj = &metav1.PartialObjectMetadata{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}}
}
}
namespace, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
return
if o, ok := obj.(*unstructured.Unstructured); ok {
synchro.pruneObject(o)
}

// Since it is not necessary to save the complete deleted object to the queue,
// we convert the object to `PartialObjectMetadata`
obj = &metav1.PartialObjectMetadata{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}}
_ = synchro.queue.Delete(obj)
}

Expand Down

0 comments on commit c4fcd8f

Please sign in to comment.