mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Clarify finalizer function
This commit is contained in:
parent
ed5b5bb94e
commit
c845c444d5
@ -761,13 +761,15 @@ func shouldDeleteDependents(e *Store, accessor metav1.Object, options *metav1.De
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// deletionFinalizers returns the deletion finalizers we should set on the
|
// deletionFinalizersForGarbageCollection analyzes the object and delete options
|
||||||
// object and a bool indicate they did or did not change.
|
// to determine whether the object is in need of finalization by the garbage
|
||||||
|
// collector. If so, returns the set of deletion finalizers to apply and a bool
|
||||||
|
// indicating whether the finalizer list has changed and is in need of updating.
|
||||||
//
|
//
|
||||||
// Because the finalizers created here are only cleared by the garbage
|
// The finalizers returned are intended to be handled by the garbage collector.
|
||||||
// collector, deletionFinalizers always returns false when garbage collection is
|
// If garbage collection is disabled for the store, this function returns false
|
||||||
// disabled for the Store.
|
// to ensure finalizers aren't set which will never be cleared.
|
||||||
func deletionFinalizers(e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) {
|
func deletionFinalizersForGarbageCollection(e *Store, accessor metav1.Object, options *metav1.DeleteOptions) (bool, []string) {
|
||||||
if !e.EnableGarbageCollection {
|
if !e.EnableGarbageCollection {
|
||||||
return false, []string{}
|
return false, []string{}
|
||||||
}
|
}
|
||||||
@ -858,7 +860,7 @@ func (e *Store) updateForGracefulDeletionAndFinalizers(ctx genericapirequest.Con
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
needsUpdate, newFinalizers := deletionFinalizers(e, existingAccessor, options)
|
needsUpdate, newFinalizers := deletionFinalizersForGarbageCollection(e, existingAccessor, options)
|
||||||
if needsUpdate {
|
if needsUpdate {
|
||||||
existingAccessor.SetFinalizers(newFinalizers)
|
existingAccessor.SetFinalizers(newFinalizers)
|
||||||
}
|
}
|
||||||
@ -950,7 +952,7 @@ func (e *Store) Delete(ctx genericapirequest.Context, name string, options *meta
|
|||||||
|
|
||||||
// Handle combinations of graceful deletion and finalization by issuing
|
// Handle combinations of graceful deletion and finalization by issuing
|
||||||
// the correct updates.
|
// the correct updates.
|
||||||
shouldUpdateFinalizers, _ := deletionFinalizers(e, accessor, options)
|
shouldUpdateFinalizers, _ := deletionFinalizersForGarbageCollection(e, accessor, options)
|
||||||
// TODO: remove the check, because we support no-op updates now.
|
// TODO: remove the check, because we support no-op updates now.
|
||||||
if graceful || pendingFinalizers || shouldUpdateFinalizers {
|
if graceful || pendingFinalizers || shouldUpdateFinalizers {
|
||||||
err, ignoreNotFound, deleteImmediately, out, lastExisting = e.updateForGracefulDeletionAndFinalizers(ctx, name, key, options, preconditions, obj)
|
err, ignoreNotFound, deleteImmediately, out, lastExisting = e.updateForGracefulDeletionAndFinalizers(ctx, name, key, options, preconditions, obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user