-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[0.1] Deleting Cluster does not delete #985
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
Comments
/assign |
Just finished an extended debugging session with @ncdc. Some background: There are three deletion techniques the kubernetes apiserver supports: During a The latter is what is required for Cluster API, because usually a cluster can't be cleaned up until it's empty (for example, CAPA can't delete the VPC and subnets associated with a cluster unless the machines inside it have already been removed). Unfortunately, there's currently no way to trigger a For now, the best workaround is to manually delete clusters using
|
@liztio: If you delete bottom-up, does that mean that you delete the Machines before the MachineSets Might the Machines potentially be recreated by the MachineSets? Apologies if this is a stupid question--I don't know all the details of how cluster deletion works. |
Thanks for the explanation. i am running into a similar issue where if I deletes a machine deployment using this client
If I delete the machine deployment, it doesn't delete the machine deployment object nor the machineset object. However, I can see that my cloud provider VM is getting deleted and recreated constantly. I am not entirely sure if it necessarily related for my case. I will add the "ForgroundDeletion" policy to delete machine deployment. My understanding is that, this should trigger the deletion of machine set first, then delete the machine deployment. |
Hi Liz, I am not using kubect and I am using the ClusterV1alpha1Client to delete machine deployment. Even with the DeletePropogationForeground set, the machine deployment is not deleted properly. It seems to run into some race condition and there is contention between machineset and machine deploytment. One is trying to remove the vm and one is trying to create the vm. After 10-20 minutes, all nodes will eventually be deleted. This looks like a bug in CAPA and I can provide more detail if needed. |
Shouldn't we be using finalizers here and controller triggering deletion of dependent objects? Coupled with |
The machine controller shouldn't be trying to create machines for machinesets the are deleting (deletiontimestamp is set). |
@Lokicity please open a new issue for your machine deployment issue - thanks! |
FYI, once we break apart the
|
That means that |
@Lokicity Passing in |
@jimmidyson I would also expect the |
Like I said above, finalizers and controller managed deletion would do it, analagous to namespace finalizer. |
@jimmidyson I wanted to avoid completely reimplementing the wheel w.r.t. finalizers. the GC already has the behaviour we want - delete all dependents before deleting the owner object. Why should we have to do that ourselves? |
@AlainRoy the machines are deleted before the machinesets, but the machinesets are marked as being deleted (by the deletedAt timestamp). This way they know not to create new deployments. |
@liztio Can you force that behaviour? I don't think you can (but would love to know if it is possible!), and as you've said above, the default is to do a background deletion. As far as I'm aware, if we want to consistently only delete clusters after all their dependents have been deleted, that has to happen through finalizers. |
I'm grumpy rn that apiserver removes the foregroundDeletion finalizer I added in. There has to be a better way than "reimplement the GC from scratch." I've seen the GC code, it's really complicated and there's a lot of edge cases, I don't trust us to get it right first try. |
We first need to decide if we want the cluster to stick around "Terminating" while its various resources are being cleaned up. If no, this problem should go away with alpha2. If yes, then we probably need to have conversations with the apimachinery & kubectl folks about how to handle this... or we could add logic to the MachineDeployment, MachineSet, and Machine controllers to watch Clusters, and if a Cluster has a nonzero deletion timestamp, issue deletes for the MD/MS/Machines. |
@ncdc I'm partial to say yes the |
I agree with @detiber. |
Ok, then I think we need to deal with the fact that kubectl defaults to background deletion and doesn't allow you to specify foreground, which results in the apiserver/garbage collection ignoring the foreground deletion finalizer. Unfortunately I think the only way to guarantee that we don't end up with a cluster stuck deleting is to implement the dependent deletion logic that we get for free with foreground deletion. I'd say this is necessary because even if kubectl supported foreground deletion, kubectl isn't the only way to issue a delete request, and someone somewhere would likely try to delete a cluster in the background and run into this issue again. |
I talked with @ncdc about this in #cluster-api slack yesterday (thanks for answering all my questions!), and I wanted to add a summary of that here: For a cascading delete, the apiserver decides which strategy to use by looking for the strategy finalizer (e.g. As a kubectl user, it seems like the important question is "Am I willing to wait for cascading deletes?" If Yes, then use foreground strategy. Otherwise, use background strategy. This is not a question kubectl asks today. Note that the "Am I willing to wait for deletes?" question is already asked by the However, the choice of strategy impacts correctness of the deletes for CAPA. If you use the background strategy to delete the cluster, the delete will never succeed because of AWS dependency issues that require machine objects to be deleted prior to the cluster object. If the wrong choice can lead to incorrect behavior, the user experience will be terrible. So either CAPA needs to work around upstream cascading delete behavior (see the comment just above), or that behavior needs to change. |
@ncdc: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@dlipovetsky yes, it does implement server-side cascading delete. I assume we would revert this if we didn't have the strategy issue. I'm not sure about an issue - we need correct behavior, 100% of the time, and we can't rely on users (or tooling) correctly setting foreground deletion. Do you think there's an alternative approach? |
I'm commenting to add an anecdote; I am implementing a controller/CRD for something unrelated and came across this same issue. I was hoping for a server-side implementation of #1180, it seems to be the better option from a framework point of view. @dlipovetsky if you create an issue against sig-apimachinery can you please post the link here. |
/kind bug
What steps did you take and what happened:
kubectl delete
the clusterWhat did you expect to happen:
The Machines, then MachineDeployments should be marked to be deleted, then the cluster deleted once their resources have been completely removed
Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]
Environment:
kubectl version
): 1.13/etc/os-release
): Ubuntu BionicThe text was updated successfully, but these errors were encountered: