-
Notifications
You must be signed in to change notification settings - Fork 28
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
core: add flatten-rbd-pvc command #229
core: add flatten-rbd-pvc command #229
Conversation
998315d
to
07c4b39
Compare
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.
@satoru-takeuchi i left some early suggestion (even for draft PR) please let me know if it makes sense :)
@Madhu-1 Thank you for your valuable comments! I'll reflect them later. |
3039295
to
86ce349
Compare
@satoru-takeuchi any update on this? |
@subhamkrai Oops, sorry. I overlooked your message. I'll update this PR to be ready to review in this week. |
Tests has not been finished yet. I'll udate this PR the beginning of the next week. |
86ce349
to
29b75f6
Compare
I lost working-on branch by mistake. Please wait for a more bit.. |
@Madhu-1 I reflected all your comments. I have two questions about testing.
|
@satoru-takeuchi not all the commands required unit test, generally when we string passing in helper function we are adding unit tests but overall not really.
@Madhu-1 could you take q2? Thanks |
Sorry for delay as i was on PTO, Lets not block this PR for it but good to have tests to cover all cases, we can open a new issue to add more tests to ensure it works for all the cases |
556c9e3
to
67fd2bf
Compare
@subhamkrai @Madhu-1 Thank you for your comments. I'm trying on adding an integration test. I'll make this PR ready to review after that. |
c17aa32
to
66a2398
Compare
0a12e1f
to
77541b1
Compare
c9a8056
to
c934d63
Compare
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.
some nits, @satoru-takeuchi you have covered most of the cases 👏🏻
} | ||
|
||
wait_for_rbd_pvc_clone_to_be_bound() { | ||
kubectl create -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/csi/rbd/pvc-clone.yaml |
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.
i think you are referring to pvc-pvc clone here not pvc-restore right?
where are we creating the volumesnapshotclass and volumesnapshot, if its planned in different PR can we make the changes related to it in same PR instead of 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.
i think you are referring to pvc-pvc clone here not pvc-restore right?
Yes, I only handle pvc-pvc clone for now.
I'll add other tests in another PR as you suggested.
Lets not block this PR for it but good to have tests to cover all cases, we can open a new issue to add more tests to ensure it works for all the cases
I'll create an issue to track this test improvement. The other tests will have the following items.
- PVC restore: pass without deleting the temporary image corresponding to VolumeSnapshot.
- static PVC: fail
- in-use PVC without allow-in-use option: fail
- in-use PVC with allow-in-use option: pass
- non-cloned/restored PVC: fail
- not-bounded PVC: fail
@Madhu-1 Thank you for your comments. I'm back from PTO. I'll update this PR tomorrow. |
c74c409
to
7207eab
Compare
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.
@satoru-takeuchi Thanks for the recent update, i have 2 more comments. everything else LGTM.
cmd/commands/flatten_rbd_pvc.go
Outdated
const ( | ||
storageProvisionerBetaAnnotation = "volume.beta.kubernetes.io/storage-provisioner" | ||
storageProvisionerAnnotation = "volume.kubernetes.io/storage-provisioner" | ||
cephCSIRBDStorageProviderAnnotation = "volume.beta.kubernetes.io/storage-provisioner" |
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 looks to be same as storageProvisionerBetaAnnotation
do we need both?
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.
Oops, sorry. I meant not "volume.beta.kubernetes.io/storage-provisioner" but "ceph-ssd.rbd.csi.ceph.com" for cephCSIRBDStorageProviderAnnotation
.
cmd/commands/flatten_rbd_pvc.go
Outdated
if pvc.Annotations[storageProvisionerAnnotation] == cephCSIRBDStorageProviderAnnotation || pvc.Annotations[storageProvisionerBetaAnnotation] == cephCSIRBDStorageProviderAnnotation { | ||
logging.Fatal(fmt.Errorf("PVC %s is not a CSI RBD PVC", pvcName)) | ||
} |
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 check seems to be wrong, we are checking annotation but not checking if its rbd PVC. can you please check
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.
Yes, it's completely wrong. Sorry for the inconvenience. This code passed integration tests contingency.
What I want to do is verify whether the target PVC is really a RBD PVC by checking the existence of one of the the following annotations.
- volume.beta.kubernetes.io/storage-provisioner: "ceph-ssd.rbd.csi.ceph.com"
- volume.kubernetes.io/storage-provisioner: "ceph-ssd.rbd.csi.ceph.com"
Static PVC doesn't have these annotations.
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.
instead of annotation can we check the presence of ImageName
or something or check if it is CSI PV not in-tree PV?
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.
OK, I'll update this PR tomorrorw.
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 I realized that we've already checked the existence of ImageName
as follows.
imageName, ok := pv.Spec.CSI.VolumeAttributes["imageName"]
if !ok {
logging.Fatal(fmt.Errorf("PV %s doesn't contains `imageName` in VolumeAttributes", pvName))
}
In other words, we got the name of RBD image name from RBD PVC's spec.csi.volumeAttributes.imageName
. Since this field only exists in RBD PVC, it can be said that we checked whether the target PVC is really an RBD PVC here.
So re-removing checking attribute is enough and I updated this PR as so. Could you check the updated PR again? Correct me if I'm wrong.
Note:
I edited this message to correct the mention from myself to Madhu-1.
3f27f53
to
48302e8
Compare
cmd/commands/flatten_rbd_pvc.go
Outdated
} | ||
if !(strings.HasSuffix(pvc.Annotations[storageProvisionerAnnotationKey], cephCSIRBDStorageProviderAnnotationValSuffix) || | ||
strings.HasSuffix(pvc.Annotations[storageProvisionerBetaAnnotationKey], cephCSIRBDStorageProviderAnnotationValSuffix)) { | ||
logging.Fatal(fmt.Errorf("PVC %s is not a CSI RBD PVC", pvcName)) |
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.
i think we dont need to worry about the static PV as most of the cases they are backed by RBD image not clones.
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.
@satoru-takeuchi Thanks for taking this up!. LGTM
48302e8
to
b2473fb
Compare
|
||
[1]: https://github.com/ceph/ceph-csi/blob/devel/docs/design/proposals/rbd-snap-clone.md`, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { |
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.
@satoru-takeuchi overall pr looks good, small suggestion if you could move the implementation function to under pkg/
folder and not put it in the same file as where command is written. Thanks after that PR will be ready to merge.
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.
@subhamkrai Indeed, moved.
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.
merged
Add flatten-rbd-pvc command to accomplish the following things: - Flatten an RBD image corrensponding to the target PVC. - Remove the temporary RBD image too. Closes: rook#222 Signed-off-by: Satoru Takeuchi <[email protected]>
b2473fb
to
f003e54
Compare
Description of your changes:
Which issue is resolved by this Pull Request:
Resolves #222
Checklist: