Skip to content

Commit

Permalink
Merge pull request #592 from huiwq1990/bugfix-ondelete
Browse files Browse the repository at this point in the history
resource synch process for delete event
  • Loading branch information
Iceber committed Nov 17, 2023
2 parents 41975c5 + c4fcd8f commit 630cf19
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 630cf19

Please sign in to comment.