9.7 KiB
Volume Deletion Flows
Summary
This enhancement modifies the flow a user would follow for handling deletion of Volumes that are Attached or otherwise have resources such as a Persistent Volume associated with them. Specifically, this adds warnings in the longhorn-ui when deleting a Volume in these specific cases and provides a means for the longhorn-manager to clean up any leftover resources in Kubernetes associated with a deleted Volume.
Related Issues
https://github.com/longhorn/longhorn/issues/520
Motivation
Goals
The goal of this enhancement is to either address or warn users about situations in which deleting a Volume could cause potential problems. In handling the case of cleaning up an associated Persistent Volume (and possibly Persistent Volume Claim), we can prevent there being leftover unusable Volume-related resources in Kubernetes. In warning about deletion when the Volume is attached, we can inform the user about possible consequences the deletion would have on existing workloads so the user can handle this accordingly.
Non-Goals
This enhancement is not intended on completely blocking a user from pursuing any dangerous operations. For example, if a user insists on deleting a currently attached Volume, they should not be forbidden from doing so in case the user is absolutely sure that they want to follow through.
Proposal
When a user wishes to delete a Volume from the Longhorn UI, the system should check to see if the Volume has a resource tied to it or is currently Attached:
- If the
VolumeisAttached, the user should be warned about the potential consequences of deleting theVolume(namely that any applications currently using theVolumewill no longer have access to it and likely error out) before they can confirm the deletion or cancel it. - If the
Volumeis tied to aVolumethat is tied to aPersistent Volume(and possibly aPersistent Volume Claim), the user should be informed of this information and the fact that we will clean up those resources if theVolumeis deleted. If theVolumeis tied to aPersistent Volume Claim, the user should also be warned that there may beDeploymentsorStateful Setsthat depend on thisVolumethat could no longer work should the user delete theVolume(we cannot explicitly see this without having to monitor allDeploymentsandStateful Setsto check if they use aLonghorn-backedPersistent Volume Claim). Afterwards, the user can confirm the deletion if they wish, which will lead to cleanup of the associated resources and deletion of theVolume.
User Stories
Deletion of Volumes with Associated Resources
Before, a user deleting a Volume through the longhorn-ui would only face the default confirmation message. The user would see the related Persistent Volume (and possibly Persistent Volume Claim) from the Volume listing, but this information would not be displayed in the confirmation message, and on deletion, these resources would still exist, which could raise problems if a user attempted to use these in a workload since they would refer to a nonexistent Volume.
After this enhancement, the user would be alerted about the existence of these resources and the fact that deletion of the Volume would lead to cleanup of these resources. The user can decide as normal whether to follow through with deletion of the Volume from the longhorn-ui or not.
Deletion of an Attached Volume
Before, a user deleting a Volume that was Attached would only face the default confirmation message in the longhorn-ui. The fact that the Volume was Attached would not be indicated in the confirmation message, and the user could potentially cause errors in applications using the Volume without any warnings.
After this enhancement, a user would be alerted about the Volume being Attached and would be able to decide on a course of action for Volume deletion and handling of any applications using the Volume accordingly.
User Experience In Detail
Deletion of Volumes with Associated Resources
- The user attempts to delete a
Volumethat has aPersistent Volume(and potentially aPersistent Volume Claim) associated with it. - The confirmation message will appear, asking the user to confirm the operation. Additionally, the message will tell the user that the
longhorn-managerwill delete theKubernetesresources associated with theVolume. If theVolumeis additionally tied to aPersistent Volume Claim, the user will also be warned about possible adverse effects for anyDeploymentsorStateful Setsthat may be using thatVolume. - The user can now follow through with one of two options:
- They can press
Cancel, which will do nothing and take them back to theVolumelisting. - They can press
Confirmto follow through with the operation. Thelonghorn-managerwill process deletion of theVolumeand automatically clean up any associatedPersistent VolumeorPersistent Volume Claim.
- They can press
Deletion of an Attached Volume
- The user attempts to delete a
Volumefrom thelonghorn-uithat is currentlyAttached. - The confirmation message will appear, telling the user that the
VolumeisAttachedand that deleting theVolumecan lead to errors in any applications using theVolume.- If the
Volumeis also attached to aKubernetesworkload (we can determine this from theKubernetes Status)
- If the
- The user can now follow through with one of two options:
- They can press
Cancel, which will do nothing and take them back to theVolumelisting. - They can press
Confirmto follow through with the operation. Thelonghorn-managerwill process deletion of theVolume. The user will be responsible for handling any errored applications that depend on the now-deletedVolume.
- They can press
API Changes
From an API perspective, the call made to delete the Volume should look the same. The logic for handling deletion of any Persistent Volume or Persistent Volume Claim should go into the Volume Controller.
Design
Implementation Overview
longhorn-uichanges:- When a user attempts to delete a
Volume:- If the
Volumehas an associatedPersistent Volumeand possiblyPersistent Volume Claim, add an additional warning to the confirmation dialog regarding cleanup of these resources. - If the
VolumeisAttached, add an additional warning to the confirmation dialog regarding possible errors that may occur that the user should account for.
- If the
- When a user attempts to delete a
longhorn-managerchanges:- In the
Volume Controller, if aVolumehas aDeletion Timestamp, check theKubernetes Statusof theVolume:- If there is a
Persistent Volume, delete it. - If there is a
Persistent Volume Claim, delete it.
- If there is a
- In the
Test Plan
A number of integration tests will need to be added for the longhorn-manager in order to test the changes in this proposal:
- From the API, create a
Volumeand then create aPersistent VolumeandPersistent Volume Claim. Wait for theKubernetes Statusto be populated. Attempt to delete theVolume. Both thePersistent VolumeandPersistent Volume Claimshould be deleted as well. - Create a
Storage ClassforLonghornand use that to provision a newVolumefor aPersistent Volume Claim. Attempt to delete theVolume. Both thePersistent VolumeandPersistent Volume Claimshould be deleted as well.
Additionally, some manual testing will need to be performed against the longhorn-ui changes for this proposal:
- From the
longhorn-ui, create a newVolumeand then create aPersistent Volumefor thatVolume. Attempt to delete theVolume. The dialog box should indicate the user that there will beKubernetesresources that will be deleted as a result. - From the
longhorn-ui, create a newVolumeand thenAttachit. Attempt to delete theVolume. The dialog box should indicate that theVolumeis in use and warn about potential errors. - Use
Kubernetesto create aVolumeand use it in aPod. Attempt to delete theVolumefrom thelonghorn-ui. Multiple warnings should show up in the dialog box, with one indicating removal of theKubernetesresources and the other warning about theVolumebeing in use.
Upgrade strategy
No special upgrade strategy is necessary. Once the user upgrades to the new version of Longhorn, these new capabilities will be accessible from the longhorn-ui without any special work.
Notes
- There is interest in allowing the user to decide on whether or not to retain the
Persistent Volume(and possiblyPersistent Volume Claim) for certain use cases such as restoring from aBackup. However, this would require changes to the waygo-ranchergenerates theGoclient that we use so thatDeleterequests against resources are able to take inputs. - In the case that a
Volumeis provisioned from aStorage Class(and set to beDeletedonce thePersistent Volume Claimutilizing thatVolumehas been deleted), theVolumeshould still be deleted properly regardless of how the deletion was initiated. If theVolumeis deleted from the UI, the call that theVolume Controllermakes to delete thePersistent Volumewould only trigger one more deletion call from theCSIserver to delete theVolume, which would return successfully and allow thePersistent Volumeto be deleted and theVolumeto be deleted as wekk. If theVolumeis deleted because of thePersistent Volume Claim, theCSIserver would be able to successfully make aVolumedeletion call before deleting thePersistent Volume. TheVolume Controllerwould have no additional resources to delete and be able to finish deletion of theVolume.