-
Notifications
You must be signed in to change notification settings - Fork 560
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
Remove child clone volume reference from the parent volume #425
Conversation
don't merge this PR till I add snapshot e2e for the current code |
@Madhu-1 quick review comments from me, PTAL. |
pkg/rbd/controllerserver.go
Outdated
} | ||
|
||
// remove the reference from volume and snapshot | ||
// this will occuer if flatten image failed during volume clone |
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.
typo ..
pkg/rbd/rbd_util.go
Outdated
@@ -550,6 +550,25 @@ func createSnapshot(pOpts *rbdSnapshot, adminID string, credentials map[string]s | |||
return nil | |||
} | |||
|
|||
// flattenImage remove the reference from the child clone to the parent snapshot |
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.
@Madhu-1 its also good to refer the documentation here in the source code comment.
pkg/rbd/controllerserver.go
Outdated
@@ -210,6 +211,12 @@ func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol * | |||
if err != nil { | |||
return status.Error(codes.Internal, err.Error()) | |||
} | |||
|
|||
err = flattenImage(rbdSnap.Pool, rbdSnap.RbdImageName, rbdVol.Monitors, rbdVol.AdminID, req.GetSecrets()) |
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.
@Madhu-1 flattenImage can take rbdSnap struct to make better argument handling. Isnt it ?
when a Cloned images retain a reference to the parent snapshot then we cannot delete the volume. flattening will remove the reference so that volume can be deleted even if it is cloned from a snapshot Added a check in delete volume, if the volume contains any snapshot we are not allowing the volume deletion, prior to volume delete all its associated snapshots should be deleted first. Signed-off-by: Madhu Rajanna <[email protected]>
@humblec Thanks for the quick review. addressed review comments PTAL |
|
||
output, err = execCommand("rbd", args) | ||
|
||
if err != nil { |
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.
This should be expected to fail if the image doesn't have a parent. Additionally, if the image has snapshots and does not have the 'deep-flatten' feature enabled, the snapshots themselves will still be linked to the parent image.
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.
@dillaman Thanks for the review,
do I need to explicitly enable deep-flatten
feature during clone
and create
or is it enabled by default
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.
You cannot enable it on existing images, it needs to have been enabled when the image was created. Support for this in krbd wasn't added until v5.1.
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.
@dillaman don't we need to enable this feature during clone
(cloned image can be used later to snapshot and clone a PVC from it)
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.
@Madhu-1 negative -- deep-flatten
isn't required for cloning, layering
is the required feature.
Thinking holistically, we added the "rbd trash mv" tool to support cases where you cannot delete a parent image due to linked clones. In the Nautilus release, this is even automated for you via the rbd_move_parent_to_trash_on_remove
config option (requires Mimic-or-later cluster). We are also adding automated background operation handling [1].
From an operator's point-of-view, we should never really expose the RBD implementation details for how snapshots and volume from snapshots (RBD clones) work on the backend. If you attempt to delete an image that has linked clones, move it to the trash for later cleanup. If you attempt to delete a snapshot with a linked clone, w/ clone v2 it just works. To support clone v1 (and v2), perhaps k8s snapshots could create a new RBD cloned image (and then it follows the previous rule about 'move-to-trash' upon delete).
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.
@dillaman can you confirm below-listed steps are correct to clone an image with a different version of ceph steps to create rbd clone
@humblec @j-griffith @ShyamsundarR let me know your thoughts on below query
based on the answer I will update this patch (this patch will help to finish smart cloning work) |
@dillaman @humblec @ShyamsundarR @j-griffith can I get an answer to the above questions? |
@Madhu-1 The issue w/ Since One important note is that if the |
I don't have enough visibility in to the field to know the best answer here. My thought was that we would not have a limitation on ceph version in terms of csi support, but provide different capabilities based on version. Keeping in mind that cloning is an option capability.
Or don't support cloning in the capabilities when the version is < Mimic? I don't know the implications of this in terms of customers in production with Kube; but given that cloning is alpha in 1.15 it's pretty "new" so setting a cut off doesn't seem heavy handed to me.
Same note as above, it's up to you though if you want to have two implementations and select based on ceph version that's great; so long as the implementations are clean and easily separated. I would hate to see too much overhead or maintenance cost by trying to support both. It seems like "upgrade to mimic if you want cloning" might be reasonable. I do have some concerns around this on the Rook side of things but it should be feasible. |
@Madhu-1 |
closing this one, as flatten will be taken care in volume cloning PR #693 |
DFBUGS-906: Prevent dataloss due to the concurrent RPC calls (occurrence is very low)
Describe what this PR does
when a Cloned images retain a reference to the parent snapshot then
we cannot delete the volume. flattening will remove the reference
so that volume can be deleted even if it is cloned from a snapshot
Added a check in delete volume, if the volume contains any snapshot
we are not allowing the volume deletion, prior to volume delete
all its associated snapshots should be deleted first.
Signed-off-by: Madhu Rajanna [email protected]
Related issues
closes #70, closes #227