From 78317edb8b8e0b0ec32442554fef31f3c2e0703a Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 8 Oct 2020 00:15:42 -0400 Subject: [PATCH] Short-circuit attemptToDelete loop for virtual nodes that are removed or observed Virtual nodes are added to the attemptToDelete queue, and continue getting requeued until they are successfully verified absent or are observed via informer. In the meantime, if the real object associated with that UID is observed via informer, or is observed to be deleted via informer, the graph node for that UID can be removed or marked as observed. In that case, we should stop retrying to get the virtual node coordinates. --- .../garbagecollector/garbagecollector.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/controller/garbagecollector/garbagecollector.go b/pkg/controller/garbagecollector/garbagecollector.go index 44840c399f8..537913ed7fd 100644 --- a/pkg/controller/garbagecollector/garbagecollector.go +++ b/pkg/controller/garbagecollector/garbagecollector.go @@ -310,6 +310,23 @@ func (gc *GarbageCollector) attemptToDeleteWorker() bool { utilruntime.HandleError(fmt.Errorf("expect *node, got %#v", item)) return true } + + if !n.isObserved() { + nodeFromGraph, existsInGraph := gc.dependencyGraphBuilder.uidToNode.Read(n.identity.UID) + if !existsInGraph { + // this can happen if attemptToDelete loops on a requeued virtual node because attemptToDeleteItem returned an error, + // and in the meantime a deletion of the real object associated with that uid was observed + klog.V(5).Infof("item %s no longer in the graph, skipping attemptToDeleteItem", n) + return true + } + if nodeFromGraph.isObserved() { + // this can happen if attemptToDelete loops on a requeued virtual node because attemptToDeleteItem returned an error, + // and in the meantime the real object associated with that uid was observed + klog.V(5).Infof("item %s no longer virtual in the graph, skipping attemptToDeleteItem on virtual node", n) + return true + } + } + err := gc.attemptToDeleteItem(n) if err == enqueuedVirtualDeleteEventErr { // a virtual event was produced and will be handled by processGraphChanges, no need to requeue this node