mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
garbage collector controller propagates DeletePropagationForeground
policy if the object doesn't already have finalizers.
This commit is contained in:
parent
31d0869f83
commit
229ae59e73
@ -364,7 +364,7 @@ func (gc *GarbageCollector) attemptToDeleteItem(item *node) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("at least one owner of object %s has FinalizerDeletingDependents, and the object itself has dependents, so it is going to be deleted with Foreground", item.identity)
|
glog.V(2).Infof("at least one owner of object %s has FinalizerDeletingDependents, and the object itself has dependents, so it is going to be deleted in Foreground", item.identity)
|
||||||
// the deletion event will be observed by the graphBuilder, so the item
|
// the deletion event will be observed by the graphBuilder, so the item
|
||||||
// will be processed again in processDeletingDependentsItem. If it
|
// will be processed again in processDeletingDependentsItem. If it
|
||||||
// doesn't have dependents, the function will remove the
|
// doesn't have dependents, the function will remove the
|
||||||
@ -375,9 +375,21 @@ func (gc *GarbageCollector) attemptToDeleteItem(item *node) error {
|
|||||||
default:
|
default:
|
||||||
// item doesn't have any solid owner, so it needs to be garbage
|
// item doesn't have any solid owner, so it needs to be garbage
|
||||||
// collected. Also, none of item's owners is waiting for the deletion of
|
// collected. Also, none of item's owners is waiting for the deletion of
|
||||||
// the dependents, so GC deletes item with Default.
|
// the dependents, so set propagationPolicy based on existing finalizers.
|
||||||
glog.V(2).Infof("delete object %s with Default", item.identity)
|
var policy metav1.DeletionPropagation
|
||||||
return gc.deleteObject(item.identity, nil)
|
switch {
|
||||||
|
case hasOrphanFinalizer(latest):
|
||||||
|
// if an existing orphan finalizer is already on the object, honor it.
|
||||||
|
policy = metav1.DeletePropagationOrphan
|
||||||
|
case hasDeleteDependentsFinalizer(latest):
|
||||||
|
// if an existing foreground finalizer is already on the object, honor it.
|
||||||
|
policy = metav1.DeletePropagationForeground
|
||||||
|
default:
|
||||||
|
// otherwise, default to background.
|
||||||
|
policy = metav1.DeletePropagationBackground
|
||||||
|
}
|
||||||
|
glog.V(2).Infof("delete object %s with propagation policy %s", item.identity, policy)
|
||||||
|
return gc.deleteObject(item.identity, &policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user