Skip to content
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

allow a deletestrategy to opt-out of GC #48354

Merged
merged 1 commit into from
Jul 3, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Jun 30, 2017

Not all resources should be GC-able and we implemented an ignore list to handle this, but at the storage layer they could still set finalizers, they just hung in a stuck state forever. This updates the strategy to allow a resource to indicate that they shouldn't be GCed.

@kubernetes/sig-api-machinery-misc

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 30, 2017
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed labels Jun 30, 2017
@@ -39,6 +39,7 @@ type GarbageCollectionPolicy string
const (
DeleteDependents GarbageCollectionPolicy = "DeleteDependents"
OrphanDependents GarbageCollectionPolicy = "OrphanDependents"
Unsupported GarbageCollectionPolicy = "Unsupported"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you expect the garbage collector to delete a resource that doesn't support garbage collection as part of a cascade?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you expect the garbage collector to delete a resource that doesn't support garbage collection as part of a cascade?

No. Not supporting GC means not supporting GC. The ownerrefs would not be respected and the GC chain is lost when getting to that node in the graph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment what Unsupported means.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Not supporting GC means not supporting GC.

With this implementation, the Unsupported resource won't break the background deletion chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this implementation, the Unsupported resource won't break the background deletion chain.

It does because the two sets of ignores match. I suppose if someone modified one and not the other they'd have a problem. We could expose GC-ability through discovery, but that feels separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems if someone deletes an "unsupported" resource with either "Orphan" or "foreground deletion", the object will be deleted immediately.

I don't think so. We enumerate the types here: https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/garbagecollector/graph_builder.go#L235-L253, so they are never observed in the graph as being in or out. They are just missing and never acted upon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. All "unsupported" resources should also be in the "ignored" list of GC. Could you say that explicitly in the comment of Unsupported? The system will behave strangely if the "two sets of ignores" don't match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. All "unsupported" resources should also be in the "ignored" list of GC. Could you say that explicitly in the comment of Unsupported? The system will behave strangely if the "two sets of ignores" don't match.

I can, but do you think this should be exposed via discovery? I think there's a good argument to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. It's no.2 in #26120 (comment). CRD should be able to opt-out GC as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. It's no.2 in #26120 (comment). CRD should be able to opt-out GC as well.

Let's work towards that instead.

@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Jul 3, 2017
@@ -637,6 +637,10 @@ func shouldUpdateFinalizerOrphanDependents(e *Store, accessor metav1.Object, opt
shouldOrphan = false
// Get default orphan policy from this REST object type
if gcStrategy, ok := e.DeleteStrategy.(rest.GarbageCollectionDeleteStrategy); ok {
if gcStrategy.DefaultGarbageCollectionPolicy() == rest.Unsupported {
// return true to force clear the GC policy if needed, and false to indicate that we should NOT orphan
return true, false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldUpdate not necessary.

Can't we drop this shouldUpdate value from both funcs and add some more clever logic to shouldUpdateFinalizers to detect changes in the finalizers? With you change this gets even more complicated.

@sttts
Copy link
Contributor

sttts commented Jul 3, 2017

The overall approach lgtm. Some nits and possible simplification.

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 3, 2017
@deads2k
Copy link
Contributor Author

deads2k commented Jul 3, 2017

@sttts simplified in another commit. See if you prefer it.

if !shouldUpdate1 && !shouldUpdate2 {
return false, oldFinalizers
}
// deletionFinalizers returns the deletion finalizers we should set on the object. The cost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better move the optimization comment down where we call updateForGracefulDeletionAndFinalizers.

@sttts
Copy link
Contributor

sttts commented Jul 3, 2017

@deads2k code-wise it's much better with the 2nd commit. Wondering what the performance consequences are: one etcd GET more per deletion of non-graceful objects?

@deads2k
Copy link
Contributor Author

deads2k commented Jul 3, 2017

@deads2k code-wise it's much better with the 2nd commit. Wondering what the performance consequences are: one etcd GET more per deletion of non-graceful objects?

Added back that bool. If some complains about garbage, we'll point them at the etcd get. Better?

@sttts
Copy link
Contributor

sttts commented Jul 3, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 3, 2017
@sttts
Copy link
Contributor

sttts commented Jul 3, 2017

/lgtm cancel

Maybe squash before.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 3, 2017
@sttts
Copy link
Contributor

sttts commented Jul 3, 2017

/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, sttts

Associated issue requirement bypassed by: sttts

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 3, 2017
@deads2k
Copy link
Contributor Author

deads2k commented Jul 3, 2017

squash, reapplying label.

@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 3, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 47784, 47793, 48334, 48435, 48354)

@k8s-github-robot k8s-github-robot merged commit 74bde7f into kubernetes:master Jul 3, 2017
@deads2k deads2k deleted the gc-01-deletenever branch August 3, 2017 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants