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
Volume
isAttached
, the user should be warned about the potential consequences of deleting theVolume
(namely that any applications currently using theVolume
will no longer have access to it and likely error out) before they can confirm the deletion or cancel it. - If the
Volume
is tied to aVolume
that 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 theVolume
is deleted. If theVolume
is tied to aPersistent Volume Claim
, the user should also be warned that there may beDeployments
orStateful Sets
that depend on thisVolume
that could no longer work should the user delete theVolume
(we cannot explicitly see this without having to monitor allDeployments
andStateful Sets
to 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
Volume
that 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-manager
will delete theKubernetes
resources associated with theVolume
. If theVolume
is additionally tied to aPersistent Volume Claim
, the user will also be warned about possible adverse effects for anyDeployments
orStateful Sets
that 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 theVolume
listing. - They can press
Confirm
to follow through with the operation. Thelonghorn-manager
will process deletion of theVolume
and automatically clean up any associatedPersistent Volume
orPersistent Volume Claim
.
- They can press
Deletion of an Attached Volume
- The user attempts to delete a
Volume
from thelonghorn-ui
that is currentlyAttached
. - The confirmation message will appear, telling the user that the
Volume
isAttached
and that deleting theVolume
can lead to errors in any applications using theVolume
.- If the
Volume
is also attached to aKubernetes
workload (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 theVolume
listing. - They can press
Confirm
to follow through with the operation. Thelonghorn-manager
will 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-ui
changes:- When a user attempts to delete a
Volume
:- If the
Volume
has an associatedPersistent Volume
and possiblyPersistent Volume Claim
, add an additional warning to the confirmation dialog regarding cleanup of these resources. - If the
Volume
isAttached
, 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-manager
changes:- In the
Volume Controller
, if aVolume
has aDeletion Timestamp
, check theKubernetes Status
of 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
Volume
and then create aPersistent Volume
andPersistent Volume Claim
. Wait for theKubernetes Status
to be populated. Attempt to delete theVolume
. Both thePersistent Volume
andPersistent Volume Claim
should be deleted as well. - Create a
Storage Class
forLonghorn
and use that to provision a newVolume
for aPersistent Volume Claim
. Attempt to delete theVolume
. Both thePersistent Volume
andPersistent Volume Claim
should 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 newVolume
and then create aPersistent Volume
for thatVolume
. Attempt to delete theVolume
. The dialog box should indicate the user that there will beKubernetes
resources that will be deleted as a result. - From the
longhorn-ui
, create a newVolume
and thenAttach
it. Attempt to delete theVolume
. The dialog box should indicate that theVolume
is in use and warn about potential errors. - Use
Kubernetes
to create aVolume
and use it in aPod
. Attempt to delete theVolume
from thelonghorn-ui
. Multiple warnings should show up in the dialog box, with one indicating removal of theKubernetes
resources and the other warning about theVolume
being 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-rancher
generates theGo
client that we use so thatDelete
requests against resources are able to take inputs. - In the case that a
Volume
is provisioned from aStorage Class
(and set to beDeleted
once thePersistent Volume Claim
utilizing thatVolume
has been deleted), theVolume
should still be deleted properly regardless of how the deletion was initiated. If theVolume
is deleted from the UI, the call that theVolume Controller
makes to delete thePersistent Volume
would only trigger one more deletion call from theCSI
server to delete theVolume
, which would return successfully and allow thePersistent Volume
to be deleted and theVolume
to be deleted as well. If theVolume
is deleted because of thePersistent Volume Claim
, theCSI
server would be able to successfully make aVolume
deletion call before deleting thePersistent Volume
. TheVolume Controller
would have no additional resources to delete and be able to finish deletion of theVolume
.