-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
federation: Support cascading deletion #33612
Comments
We have 2 options:
Garbage collector modelHow it works in kubernetesThere is a separate Garbage Collector controller whose job is to ensure that all dependent objects are deleted when the "owner" object is deleted. Work required to extend it for federation:
Pros:
Cons
Let each controller delete the corresponding dependent objectsHow will this workWhen a controller (for ex: the federation replica set controller) observes a new federated object (federated replicaset), it first adds a finalizer to it before creating any dependent objects (replicasets in underlying clusters). Pros:
Cons:
|
Based on discussion with @caesarxuchao and @lavalamp, the second model seems better. The second model is similar to how namespace deletion works in kubernetes. |
I think the second model is workable. The first model seems to have dependencies going the wrong way at first On Tue, Sep 27, 2016 at 5:12 PM, Nikhil Jindal notifications@github.com
|
Yes, agree. The second model seems much better/simpler/more reliable/less On Tue, Sep 27, 2016 at 5:34 PM, Daniel Smith notifications@github.com
|
Some notes from our offline discussion: the k8s garbage collector is designed to handle dependencies among arbitrary resources. In the current federation use cases, the dependency is between an federation object and its k8s counterpart, so a generic garbage collector is an overkill. The second model is much easier, and the deletion logic spread in each controller is manageable. |
Automatic merge from submit-queue Adding cascading deletion support to federated namespaces Ref #33612 With this change, whenever a federated namespace is deleted with `DeleteOptions.OrphanDependents = false`, then federation namespace controller first deletes the corresponding namespaces from all underlying clusters before deleting the federated namespace. cc @kubernetes/sig-cluster-federation @caesarxuchao ```release-note Adding support for DeleteOptions.OrphanDependents for federated namespaces. Setting it to false while deleting a federated namespace also deletes the corresponding namespace from all registered clusters. ```
Code for cascading deletion is now merged for namespaces. And now that we have the generic DeletionHelper class it should be relatively easy to extend it for all other federation resources which is what I am going to do next. Cascading deletion for clusters (second problem in the original description of this issue) is a bit different. This involves deleting all resources from a kube cluster that were created by federation controllers when the cluster is removed from federation. Its different because now we are deleting different kind of resources than the one that was deleted by the user. The way I am planning to implement this is by cluster controller adding a finalizer to the cluster whenever it sees a new cluster. When user deletes a cluster, apiserver sets the deletion timestamp and adds the OrphanFinalizer depending on DeleteOptions. Cluster controller can then do the following for all clusters that have deletion timespace set:
To track all resources created by federation controllers, I will update federation controllers to add a specific annotation when they create resources in underlying clusters. Cluster controller can use this annotation to list and delete these resources. |
Documenting discussion with @quinton-hoole
The API documentation for that field is "Should the dependent objects be orphaned" without defining "dependents". For kubernetes its all resources with OwnerReferece pointing to this resource and for federation it is all resources of the same type and name in underlying clusters. This can clearly cause user confusion.
None of our resources have a dependent in federation control plane today. But good to keep in mind for future. |
Automatic merge from submit-queue Adding more e2e tests for federated namespace cascading deletion and fixing bugs Ref #33612 Adding more e2e tests for testing cascading deletion of federated namespace. New tests are now verifying that cascading deletion happen when DeletionOptions.OrphanDependents=false and it does not happen when DeleteOptions.OrphanDependents=true. Also updated deletion helper to always add OrphanFinalizer. generic registry will remove it if DeleteOptions.OrphanDependents=false. Also updated namespace registry to do the same. We need to add the orphan finalizer to keep the orphan by default behavior. We assume that its dependents are going to be orphaned and hence add that finalizer. If user does not want the orphan behavior, he can do so using DeleteOptions and then the registry will remove that finalizer. cc @kubernetes/sig-cluster-federation @caesarxuchao @derekwaynecarr
Automatic merge from submit-queue Adding cadcading deletion support for federated secrets Ref #33612 Adding cascading deletion support for federated secrets. The code is same as that for namespaces. Just ensuring that DeletionHelper functions are called at right places in secret_controller. Also added e2e tests. cc @kubernetes/sig-cluster-federation @caesarxuchao ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated secrets. Setting it to false while deleting a federated secret also deletes the corresponding secrets from all registered clusters. ```
Automatic merge from submit-queue Adding cascading deletion support to more federation controllers Ref #33612 Adding cascading deletion support for federated daemonsets and ingress. The code is same as that for namespaces. Just ensuring that DeletionHelper functions are called at right places in these controllers. e2e tests coming up in another PR. cc @kubernetes/sig-cluster-federation @caesarxuchao @madhusudancs @mwielgus ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated daemonsets and ingresses. Setting it to false while deleting a federated daemonset or ingress also deletes the corresponding resource from all registered clusters. ```
Automatic merge from submit-queue Adding cascading deletion support to federation replicaset and deployments Forked from #36330 Ref #33612 Adding cascading deletion support for federated replicasets and deployments. ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated replicasets and deployments. Setting it to false while deleting a federated replicaset or deployment also deletes the corresponding resource from all registered clusters. ```
Automatic merge from submit-queue Adding e2e tests for validating cascading deletion of federation resources Ref #33612 Adding e2e tests for code in #36330 and #36476. Adding test cases to ensure that cascading deletion happens as expected. Also adding code to ensure that all resources are cleaned up in AfterEach. cc @kubernetes/sig-cluster-federation @caesarxuchao @madhusudancs
Status update for 1.5: Next step is to support it in these 2 resources as well. |
We also need to ensure that cascading deletion for federation resources works consistently with kubectl. Filed #38897 for that |
Automatic merge from submit-queue (batch tested with PRs 38212, 38792, 39641, 36390, 39005) Updating federated service controller to support cascading deletion Ref #33612 Service controller is special than other federation controllers because it does not use federatedinformer and updater to sync services (it was written before we had those frameworks). Updating service controller code to instantiate these frameworks and then use deletion helper to perform cascading deletion. Note that, I havent changed the queuing logic in this PR so we still dont use federated informer to manage the queue. Will do that in the next PR. cc @kubernetes/sig-federation-misc @mwielgus @quinton-hoole ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated services. Setting it to false while deleting a federated service also deletes the corresponding services from all registered clusters. ```
@nikhiljindal I see that cascade deletion was implemented for services. I'm working on #40989, and as part of that work can enable cascade deletion for config maps. |
Ok, I won't work on refactoring the configmap controller until that merges. |
Automatic merge from submit-queue federation: Refactoring namespaced resources deletion code from kube ns controller and sharing it with fed ns controller Ref #33612 Refactoring code in kube namespace controller to delete all resources in a namespace when the namespace is deleted. Refactored this code into a separate NamespacedResourcesDeleter class and calling it from federation namespace controller. This is required for enabling cascading deletion of namespaced resources in federation apiserver. Before this PR, we were directly deleting the namespaced resources and assuming that they go away immediately. With cascading deletion, we will have to wait for the corresponding controllers to first delete the resources from underlying clusters and then delete the resource from federation control plane. NamespacedResourcesDeleter has this waiting logic. cc @kubernetes/sig-federation-misc @caesarxuchao @derekwaynecarr @mwielgus
Automatic merge from submit-queue Adding cascading deletion support to federated namespaces Ref kubernetes/kubernetes#33612 With this change, whenever a federated namespace is deleted with `DeleteOptions.OrphanDependents = false`, then federation namespace controller first deletes the corresponding namespaces from all underlying clusters before deleting the federated namespace. cc @kubernetes/sig-cluster-federation @caesarxuchao ```release-note Adding support for DeleteOptions.OrphanDependents for federated namespaces. Setting it to false while deleting a federated namespace also deletes the corresponding namespace from all registered clusters. ```
Automatic merge from submit-queue Adding more e2e tests for federated namespace cascading deletion and fixing bugs Ref kubernetes/kubernetes#33612 Adding more e2e tests for testing cascading deletion of federated namespace. New tests are now verifying that cascading deletion happen when DeletionOptions.OrphanDependents=false and it does not happen when DeleteOptions.OrphanDependents=true. Also updated deletion helper to always add OrphanFinalizer. generic registry will remove it if DeleteOptions.OrphanDependents=false. Also updated namespace registry to do the same. We need to add the orphan finalizer to keep the orphan by default behavior. We assume that its dependents are going to be orphaned and hence add that finalizer. If user does not want the orphan behavior, he can do so using DeleteOptions and then the registry will remove that finalizer. cc @kubernetes/sig-cluster-federation @caesarxuchao @derekwaynecarr
Automatic merge from submit-queue Adding cadcading deletion support for federated secrets Ref kubernetes/kubernetes#33612 Adding cascading deletion support for federated secrets. The code is same as that for namespaces. Just ensuring that DeletionHelper functions are called at right places in secret_controller. Also added e2e tests. cc @kubernetes/sig-cluster-federation @caesarxuchao ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated secrets. Setting it to false while deleting a federated secret also deletes the corresponding secrets from all registered clusters. ```
Automatic merge from submit-queue (batch tested with PRs 38212, 38792, 39641, 36390, 39005) Updating federated service controller to support cascading deletion Ref kubernetes/kubernetes#33612 Service controller is special than other federation controllers because it does not use federatedinformer and updater to sync services (it was written before we had those frameworks). Updating service controller code to instantiate these frameworks and then use deletion helper to perform cascading deletion. Note that, I havent changed the queuing logic in this PR so we still dont use federated informer to manage the queue. Will do that in the next PR. cc @kubernetes/sig-federation-misc @mwielgus @quinton-hoole ```release-note federation: Adding support for DeleteOptions.OrphanDependents for federated services. Setting it to false while deleting a federated service also deletes the corresponding services from all registered clusters. ```
@nikhiljindal it doesn't look like we've addressed the second part of this issue, namely what happens when clusters are removed from the federation. Can you confirm? Are you still working on this? If not, could you provide current status, and unassign yourself, so that we can find someone else to finish the required work please. Thanks. |
Required for GA of federation. |
This issue was labelled only for sig/multicluster and is thus moved over to kubernetes-retired/federation#75. |
Problem: There are 2 related problems:
Now that we have cascading deletion in kubernetes, we should support cascading deletion in federation as well. As in kubernetes, we will give users the option to disable it.
cc @kubernetes/sig-cluster-federation
The text was updated successfully, but these errors were encountered: