-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Description
What do you want to happen?
I wonder why in the cronjob example there is a condition to check if cronjob contains finalizer and if so add it. See:
if !controllerutil.ContainsFinalizer(cronJob, myFinalizerName) {
controllerutil.AddFinalizer(cronJob, myFinalizerName)
if !controllerutil.ContainsFinalizer(cronJob, myFinalizerName) { |
However ContainsFinalizer
seems to be overkill as AddFinalizer
function do the same check inside and it will not add the finalizer once it is already there:
func AddFinalizer(o client.Object, finalizer string) (finalizersUpdated bool) {
f := o.GetFinalizers()
for _, e := range f {
if e == finalizer {
return false
}
}
o.SetFinalizers(append(f, finalizer))
return true
}
I would like to remove ContainsFinalizer
as it is not needed and update documentation. Before doing so please comment if my reasoning is fine.
Extra Labels
No response
Metadata
Metadata
Assignees
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.