Skip to content
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

feat(snapshot): add snapshot support for LVM PV #12

Merged
merged 28 commits into from
Feb 8, 2021

Conversation

akhilerm
Copy link
Member

@akhilerm akhilerm commented Jan 11, 2021

Why is this PR required? What issue does it fix?:
This PR adds support for LVM snapshot to the lvm-localPV CSI driver. The snapshots created will be readonly (as opposed to the default ReadWrite). Also, once snapshots are created for a volume, resize will not work for those volumes, since LVM does't support that.

To create a snapshot, create a snapshot class as given below and then create a volumesnapshot resource

kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
metadata:
  name: lvm-localpv-snapclass
  annotations:
    snapshot.storage.kubernetes.io/is-default-class: "true"
driver: local.csi.openebs.io
deletionPolicy: Delete
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: lvm-localpv-snap
spec:
  volumeSnapshotClassName: lvm-localpv-snapclass
  source:
    persistentVolumeClaimName: <pvc-name>

What this PR does?:

  • adds LVMSnapshot CRDs
  • add snapshot controller to watch for LVMSnapshot CRs
  • adds the volumesnapshot related CRDs from storage.k8s.io to the deployment
  • use container images from k8s.gcr.io for CSI components

Limitation
Volumes with snapshots cannot be resized, as LVM does not support online resize of origin volumes with a snapshot. ControllerExpandVolume will error out if the volume to resized has any active snapshots.

Does this PR require any upgrade changes?:
dm-snapshot kernel module should be loaded for snapshot to work

If the changes in this PR are manually verified, list down the scenarios covered::

  1. Snapshot creation
  2. Try to resize volume with snapshot (will error out the volume expansion)
  3. resize should work after snapshots are removed
  4. create multiple snapshots for the same volume

Any additional information for your reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

@akhilerm akhilerm marked this pull request as ready for review January 25, 2021 05:51
@akhilerm akhilerm force-pushed the snapshot-clone branch 2 times, most recently from 98a5dbf to d0d48a1 Compare January 29, 2021 06:08
pkg/driver/agent.go Outdated Show resolved Hide resolved
pkg/apis/openebs.io/lvm/v1alpha1/lvmvolume.go Outdated Show resolved Hide resolved
pkg/mgmt/snapshot/snapshot.go Outdated Show resolved Hide resolved
pkg/driver/controller.go Show resolved Hide resolved
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
Signed-off-by: Akhil Mohan <[email protected]>
@akhilerm
Copy link
Member Author

akhilerm commented Feb 4, 2021

@pawanpraka1 Updated the NodeExpandVolume to error out if the volume contains any snapshots

@pawanpraka1
Copy link
Contributor

pawanpraka1 commented Feb 4, 2021

@akhilerm we need to block that in ControllerExpandVolume. Also test this and see if behavior is fine.

@akhilerm
Copy link
Member Author

akhilerm commented Feb 4, 2021

@akhilerm we need to block that in ControllerExpandVolume. Also test this and see if behavior is fine.

Done. @pawanpraka1. Yes , tested and its working fine.

One issue I faced is in the following test case:

  1. Create PVC of 4Gi
  2. Create a snapshot
  3. Resize PVC to 5Gi
  4. Resize fails because of active snapshot
  5. Delete the snapshot
  6. But the controller logs is not having the ControllerExpandVolume call again.
  7. Even after deleting the snapshot the resize is not happening.

@pawanpraka1
Copy link
Contributor

@akhilerm it uses exponential backoff to retry the next time. You might need to wait enough to get the call again?

Signed-off-by: Akhil Mohan <[email protected]>
@akhilerm
Copy link
Member Author

akhilerm commented Feb 5, 2021

@pawanpraka1 Changing the grpc error code worked.

@codecov-io
Copy link

Codecov Report

Merging #12 (07ac6ea) into master (b370f3c) will decrease coverage by 0.18%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #12      +/-   ##
=========================================
- Coverage    1.41%   1.22%   -0.19%     
=========================================
  Files          11      11              
  Lines         708     818     +110     
=========================================
  Hits           10      10              
- Misses        698     808     +110     
Impacted Files Coverage Δ
pkg/driver/agent.go 0.00% <0.00%> (ø)
pkg/driver/controller.go 0.77% <0.00%> (-0.30%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b370f3c...07ac6ea. Read the comment docs.

Signed-off-by: Akhil Mohan <[email protected]>
Copy link
Contributor

@pawanpraka1 pawanpraka1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

@pawanpraka1 pawanpraka1 merged commit 7e0bd8a into openebs:master Feb 8, 2021
@pawanpraka1 pawanpraka1 added this to the v0.2 milestone Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add snapshot support for lvm-localpv
4 participants