-
Notifications
You must be signed in to change notification settings - Fork 106
make delete volume idempotent when node is removed from cluster #413
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,7 @@ func ProvisionVolume(vol *apis.LVMVolume) (*apis.LVMVolume, error) { | |
| func DeleteVolume(volumeID string) (err error) { | ||
| err = volbuilder.NewKubeclient().WithNamespace(LvmNamespace).Delete(volumeID) | ||
| if err == nil { | ||
| klog.Infof("deprovisioned volume %s", volumeID) | ||
| klog.Infof("deprovisioning volume %s", volumeID) | ||
| } | ||
|
|
||
| return | ||
|
|
@@ -164,6 +164,23 @@ func WaitForLVMVolumeDestroy(ctx context.Context, volumeID string) error { | |
| } | ||
| } | ||
|
|
||
| // Verifies if lvmvolume CR got removed after removing finaliser. | ||
| func VerifyLVMVolumeDestroy(volumeID string) error { | ||
| for i := 0; i < 10; i++ { | ||
| _, err := GetLVMVolume(volumeID) | ||
| if err != nil { | ||
| if k8serror.IsNotFound(err) { | ||
| return nil | ||
| } | ||
| return status.Errorf(codes.Internal, | ||
| "lvmvolume: destroy wait failed, not able to get the volume %s %s", volumeID, err.Error()) | ||
| } | ||
| time.Sleep(time.Duration(100 * time.Millisecond)) | ||
| } | ||
| return status.Errorf(codes.FailedPrecondition, | ||
| "lvmvolume: %s not removed after removing finaliser", volumeID) | ||
| } | ||
|
|
||
| // GetLVMVolumeState returns LVMVolume OwnerNode and State for | ||
| // the given volume. CreateVolume request may call it again and | ||
| // again until volume is "Ready". | ||
|
|
@@ -219,6 +236,9 @@ func RemoveVolFinalizer(vol *apis.LVMVolume) error { | |
| vol.Finalizers = nil | ||
|
|
||
| _, err := volbuilder.NewKubeclient().WithNamespace(LvmNamespace).Update(vol) | ||
| if err != nil { | ||
| klog.Infof("Finalizer removed successfully for %s", vol.Name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this as info or is debug fine?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will not reach this code if node is present. Would be better to have it in log by default.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we already have the message from above where we call it if the node is not present?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, err != nil means we fail to remove finalizer, we return err. If not, we move on to check if lvmvolume CR is deleted. |
||
| } | ||
| return err | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the finalizer is already removed? Then we don't need to run this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finalizer is removed from the node-agent when
lvremovesucceeds. Here we will validate if node is not present. If not, finalizer will not be removed. so will remove finalizer from here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the lvm volume has additional finalisers (eg: added by user) but we've already removed ours, on a previous csi call, then we don't need to do this again
We only need to do this stage if our finaliser is present
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this removes all Finalizers. I am using the function which is called by node-agent once
lvremoveis done.https://github.com/openebs/lvm-localpv/blob/develop/pkg/lvm/volume.go#L217C1-L223C2
lvmvolumeCR is managed by localpv-lvm. Users may not add any finalizers onto it.