Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource synch process for delete event #592

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading