-
Notifications
You must be signed in to change notification settings - Fork 336
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
PV Protection breaks deleting #195
Comments
kubernetes-sigs/sig-storage-lib-external-provisioner#6 has been merged so just waiting for a release to make a pr to update the library |
Thanks for finding this issue. Could you also look into adding an e2e test for this in k/k? This may be a good place: https://sourcegraph.com/github.com/kubernetes/kubernetes/-/blob/test/e2e/storage/csi_volumes.go Also, I think this is an issue for in-tree volumes too. Should we consider fixing in-tree behavior? cc @jsafrane @wongma7 |
update kubernetes-sigs/sig-storage-lib-external-provisioner to fix #195
@msau42 I will look into adding tests, I am not too familiar with the kubenretes e2e tests but I will try and figure it out! |
feel free to ping me if you need help. Try following this guide: https://github.com/kubernetes/community/blob/master/contributors/devel/e2e-tests.md |
Hi, looking back at this PR, I'm not sure if this is the right way to fix the issue. I think this issue also exists for in-tree volumes, so we should see if a fix is possible at the PV controller level. At the very least, we should make this behavior opt-in and maybe alpha flag gated at the CSI provisioner level while we investigate other solutions. |
I'll make it opt-in. I don't think the *exact same issue occurs but I agree this needs another look. The fix is a bit heavy-handed, it fixes behaviour for this specific issue so that it's the same for in-tree & out-of-tree, but also makes other behaviour different which I didn't follow up on... If a user deletes a PVC+PV while they are
I liked the idea of having a finalizer because it makes it clear that the provisioner is responsible for deleting the back-end volume and users can still delete the PV by removing the finalizer first. Why they want to delete the dynamically provisioned PV manually when the provisioner will do it automatically, IDK (it could be an honest mistake/accident, like @rmb938 kind of suggests in kubernetes-sigs/sig-storage-lib-external-provisioner#5), but I think in any case they expect the back-end volume to be deleted when they delete the PV because the ReclaimPolicy of the PV is Delete. We document that Anyway, all that said, I like consistency with in-tree more than I like the finalizer so I hope @jsafrane can help. |
Yea, this whole issue came about when I accidentally deleted the PV while the PVC was still around. Then when I went to go and delete the PVC the CSI never got called to clean up the backing volume for the PV. I actually never tested this issue on the in-tree provisioners so my expectations of this not happening with them could have been wrong. However if this issue also happens with in-tree provisioners I think we should have a discussion to change this behaviour so the backend volumes always get cleaned up when the ReclaimPolicy is Delete. I certainly do not want tons of leftover volumes lying around when someone accidentally deletes the PV resource first. |
I'm thinking about this possible race:
I'm thinking to properly fix this, we may need some new phase/condition/annotation after Released and keep the storage protection finalizer until the it reaches that deleted phase. I think that would be tricky to deal with version skew though. |
Another way to do it could be a finalizer right before step 3 "PV controller moves the PV to released phase," then the protection controller wouldn't have to change. No API change needed like phase/condition and cleaner than annotation. So basically there are 2 outcomes to the race and we prefer a) because we prefer to avoid dangling volumes. a) PV is reclaimed. happens if pv controller wins the race Are we 100% sure a) is the fix/correct behaviour?...basically the question IMO is: Should manually deleting a PV mean "ignore the ReclaimPolicy, delete the object without reclaiming the volume"? Because making a) standard means if the PV has a storage protection finalizer the ReclaimPolicy is not ignored and otherwise it is. That unpredictability is maybe worse than the accidental/mistaken dangling volumes issue we're trying to solve. |
Putting a phase/condition/annotation/finalizer will probably mean the out-of-tree has to become aware of it so yeah there could be some version skew issues to solve else the PV would stay around with that phase/condition/annotation/finalizer forever. Also my "PV has a storage protection finalizer the ReclaimPolicy is not ignored and otherwise it is" situation is pretty contrived, there's no way it's "worse." Worded differently, my issue is: if I delete a PV when it's Bound and remove the finalizer it's clear I don't want the ReclaimPolicy to kick in when the PVC is deleted, the PVC will become Lost first. But if I delete a PV when it's Bound without removing the finalizer then what should happen when the PVC is deleted? |
Yes, upgrades and downgrades get problematic if we introduce new finalizer / condition. IMO we should focus on the use case first. Why users delete PVs? They should delete PVCs, that's what we want to support. Reclaim policy was always tied to PVC deletion and never to PV deletion. It's just a coincidence that reclaim policy is applied once when both PV and PVC is deleted and PV finalizer kicks in. So, why users delete PVs again? |
If the PV is If it's an accident/mistake then the protection finalizer helps to ensure that new/restarted pods can still use it. But, IMO, the protection finalizer doesn't say anything about whether the reclaim policy applies. Like you say, it's a coincidence that it makes the reclaim policy apply once. A user will appreciate that, but IMO having the provisioner finalizer too will be even better because it's more explicit, it tells the user that the provisioner is the owner and still has unfinished work to do (reclaim). If they want to prevent new/restarted pods from using it then the object needs to be gone ASAP, so they will simply remove all finalizers from it. They probably don't want the reclaim policy to be applied, a provisioner finalizer will force them to consider that for a second. However, they could achieve the same thing by changing the PV's reclaim policy and deleting the PVC. If the PV is |
I'm not sure if it's worth having to give the provisioner an additional update PV permission to better handle a situation where the user makes a mistake or you don't want the finalizer anyway. |
I am very liberal about adding permissions and features, especially if a user reported/contributed it like in this case. There's evidence the mistake happens so mitigating it surely helps. The provisioner already has In the future when adding permissions for objects maybe they should be grouped together as R(get, list watch) and W(create, update, patch, delete) to avoid starting too granular and having to add later. But that could be an issue too with some permissions being unnecessary. |
Maybe health check should be tied to permissions so pod will fail immediately if it doesn't have everything. Plus in this case the finalizer thing is clearly optional so it would be good to have it fallback if permission is not present. (still working on making it off by default anyway) |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: 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. |
Aha. I had been looking for this, almost opened a new issue.
FYI, I tried this right up against the latest 1.3.1 version of the provisioner. I get that users perhaps should delete the Can we reopen this? |
Instead of reopening this issue, let's continue in #546 because it has a clearer description of what the issue is about. |
Avoid logging PV name,where PV created by other CSI
If a user deletes a PV while it has a PVC with a pv protection finalizer the CSI never gets alerted to delete the volume when the pvc is deleted.
The text was updated successfully, but these errors were encountered: