-
Notifications
You must be signed in to change notification settings - Fork 40k
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
[GarbageCollector] Add orphaning finalizer logic to GC #25599
Conversation
c6ca084
to
d90165a
Compare
@@ -395,7 +395,7 @@ func ValidateObjectMetaUpdate(newMeta, oldMeta *api.ObjectMeta, fldPath *field.P | |||
allErrs = append(allErrs, ValidateImmutableField(newMeta.Namespace, oldMeta.Namespace, fldPath.Child("namespace"))...) | |||
allErrs = append(allErrs, ValidateImmutableField(newMeta.UID, oldMeta.UID, fldPath.Child("uid"))...) | |||
allErrs = append(allErrs, ValidateImmutableField(newMeta.CreationTimestamp, oldMeta.CreationTimestamp, fldPath.Child("creationTimestamp"))...) | |||
allErrs = append(allErrs, ValidateImmutableField(newMeta.Finalizers, oldMeta.Finalizers, fldPath.Child("finalizers"))...) | |||
// allErrs = append(allErrs, ValidateImmutableField(newMeta.Finalizers, oldMeta.Finalizers, fldPath.Child("finalizers"))...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
d90165a
to
592eb83
Compare
fmt.Println("CHAO: e.oldObj=e.oldObj") | ||
} | ||
if e.oldObj == nil { | ||
if accessor.GetDeletionTimestamp() == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line handles the case where the DeletionTimestamp is set at the first time GC sees it
3e5a255
to
cfb2bdd
Compare
Still missing one piece of code: the API server's deletion handler needs to add the orphan finalizer if the deleteOption has Orphaning set. |
6452d0f
to
85c3284
Compare
One minor problem: the dynamic client cannot decode the v1.Status returned by the API server for Update call, so the gc always retries the maximum times to remove the orphan finalizer from owner's finalziers list. This is causes inefficiency, but doesn't affect the functionality. |
4bd021a
to
97ad501
Compare
All tests are passing locally. Some remaining work:
I think 2 is not required for 1.3. 1 may be required, but given that we don't automatically set OwnerReferences, and we gc is default turning off, it might not be that critical. @lavalamp what do you think? |
if delete { | ||
out := e.NewFunc() | ||
glog.V(6).Infof("going to delete %s from regitry, triggered by update", name) | ||
if err := e.Storage.Delete(ctx, key, out, preconditions); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does finalized delete interact with graceful delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The object is deleted here only if the update request empties the finalizers and the DeletionGracePeriods is already set to 0.
So if the request just empties the finalizers, and the DeletionGracePeriods is not 0, then it will be handled as a regular update. The object will be deleted until someone sends a deletion request with DeletionGracePeriod=0.
d45c8d8
to
4964dd3
Compare
@@ -255,10 +303,10 @@ func (e *Store) Update(ctx api.Context, name string, objInfo rest.UpdatedObjectI | |||
} | |||
|
|||
out := e.NewFunc() | |||
|
|||
var obj runtime.Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call this deletedObj
and only set it in the delete case to make it clear what should be using it outside the func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
e2e failure is a flake: #26131 |
utilruntime.HandleError(err) | ||
return false | ||
} | ||
return len(newMeta.Finalizers) == 0 && oldMeta.DeletionGracePeriodSeconds != nil && *oldMeta.DeletionGracePeriodSeconds == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we also check len(oldMeta.Finalizers) > 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that would make the apiserver non-idempotent. Here is the previous discussion: #25599 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... then this isn't really checking that this update is removing finalizers, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your statement is correct. My reasoning is: If oldMeta.DeletionGracePeriodSeconds==0, and the object still exists, it could only be that the finalizers were not empty, or the apiserver had crashed, either way we should delete the object now.
…dling DeleteOptions.OrphanDependents in the API server
4964dd3
to
1665546
Compare
@k8s-oncall. It seems the merge-bot stops checking the labels after rebase, it doesn't remove the |
@@ -72,6 +72,7 @@ kube-apiserver | |||
--cors-allowed-origins=[]: List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled. | |||
--delete-collection-workers=1: Number of workers spawned for DeleteCollection call. These are used to speed up namespace cleanup. | |||
--deserialization-cache-size=50000: Number of deserialized json objects to cache in memory. | |||
--enable-garbage-collector[=false]: Enables the generic garbage collector. MUST be synced with the corresponding flag of the kube-controller-manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to say something about this being an alpha feature and admins should be careful and understand the risks before setting this to true? :)
Because submit queue is blocked, I'm going to kick off re-tests of the top 5 PRs in the queue, then merge them if they pass. |
The node e2e error seems to be a flake:
|
@k8s-bot node e2e test this, issue #IGNORE |
GCE e2e build/test passed for commit 1665546. |
@alex-mohr all tests passed. Could you merge? Thanks. |
@caesarxuchao Does this PR require action by the user when upgrading from 1.2.x to 1.3.0? (Think about non-developer users.) If so, please edit your first comment to have a release-note block, like in #28132. If it is just an optional feature, please change the label to just release-note. If it is not a complete feature by itself, then apply "release-note-none" label instead. |
Design doc is at https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/garbage-collection.md
@lavalamp @gmarek @kubernetes/sig-api-machinery
This change is