Skip to content

Commit

Permalink
update snapshot implementation with new design
Browse files Browse the repository at this point in the history
```
* create temporary RBD snapshot on source volume's RBD image
* RBD clone CO source volume's RBD image's snapshot to new RBD image
* remove temporary RBD snapshot on CO source volume's RBD image

* serialize work on RBD snapshot image clone
* test RBD snapshot image clone's depth
* if depth over hard limit flatten clone
* create RBD snapshot on RBD snapshot image clone
* create RBD volume image clone from RBD snapshot image clone

* delete temporary RBD image
* delete temporary RBD snapshot
```

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Mar 3, 2020
1 parent a027fdb commit 70c3b52
Show file tree
Hide file tree
Showing 10 changed files with 504 additions and 251 deletions.
8 changes: 8 additions & 0 deletions cmd/cephcsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func init() {

flag.BoolVar(&conf.Version, "version", false, "Print cephcsi version information")

flag.UintVar(&conf.RbdHardMaxCloneDepth, "rbdhardmaxclonedepth", 5, "Hard limit for maximum number of nested volume clones that are taken before a flatten occurs")
klog.InitFlags(nil)
if err := flag.Set("logtostderr", "true"); err != nil {
klog.Exitf("failed to set logtostderr flag: %v", err)
Expand Down Expand Up @@ -169,6 +170,7 @@ func main() {
klog.Infof("Starting driver type: %v with name: %v", conf.Vtype, dname)
switch conf.Vtype {
case rbdType:
validateCloneDepthFlag(&conf)
driver := rbd.NewDriver()
driver.Run(&conf, cp)

Expand All @@ -188,3 +190,9 @@ func main() {

os.Exit(0)
}

func validateCloneDepthFlag(conf *util.Config) {
if conf.RbdHardMaxCloneDepth > 16 {
klog.Fatalln("rbdhardmaxclonedepth flag value should be less than 16")
}
}
1 change: 1 addition & 0 deletions docs/deploy-rbd.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ make image-cephcsi
| `mounter` | no | if set to `rbd-nbd`, use `rbd-nbd` on nodes that have `rbd-nbd` and `nbd` kernel modules to map rbd images |
| `encrypted` | no | disabled by default, use `"true"` to enable LUKS encryption on pvc and `"false"` to disable it. **Do not change for existing storageclasses** |
| `encryptionKMSID` | no | required if encryption is enabled and a kms is used to store passphrases |
| `--rbdhardmaxclonedepth` | `10` | Hard limit for maximum number of nested volume clones that are taken before a flatten occurs |

**NOTE:** An accompanying CSI configuration file, needs to be provided to the
running pods. Refer to [Creating CSI configuration](../examples/README.md#creating-csi-configuration)
Expand Down
58 changes: 1 addition & 57 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,19 @@ var _ = Describe("RBD", func() {
deleteConfigMap(rbdDirPath)
deleteResource(rbdExamplePath + "secret.yaml")
deleteResource(rbdExamplePath + "storageclass.yaml")
<<<<<<< HEAD
// deleteResource(rbdExamplePath + "snapshotclass.yaml")
deleteVault()
=======
deleteResource(rbdExamplePath + "snapshotclass.yaml")
>>>>>>> parent of 90fef919d... Skip snapshot testing in CI
})

Context("Test RBD CSI", func() {
It("Test RBD CSI", func() {
pvcPath := rbdExamplePath + "pvc.yaml"
appPath := rbdExamplePath + "pod.yaml"
<<<<<<< HEAD
rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
// pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
// appClonePath := rbdExamplePath + "pod-restore.yaml"
// snapshotPath := rbdExamplePath + "snapshot.yaml"
=======
// rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
// rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
appClonePath := rbdExamplePath + "pod-restore.yaml"
snapshotPath := rbdExamplePath + "snapshot.yaml"
>>>>>>> parent of 90fef919d... Skip snapshot testing in CI

By("checking provisioner deployment is running")
var err error
Expand Down Expand Up @@ -168,51 +156,7 @@ var _ = Describe("RBD", func() {

By("create a PVC clone and Bind it to an app", func() {
createRBDSnapshotClass(f)
pvc, err := loadPVC(pvcPath)
if err != nil {
Fail(err.Error())
}

pvc.Namespace = f.UniqueName
e2elog.Logf("The PVC template %+v", pvc)
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
Fail(err.Error())
}
// validate created backend rbd images
images := listRBDImages(f)
if len(images) != 1 {
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
Fail("validate backend image failed")
}
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
snap.Spec.Source.Name = pvc.Name
snap.Spec.Source.Kind = "PersistentVolumeClaim"
err = createSnapshot(&snap, deployTimeout)
if err != nil {
Fail(err.Error())
}
pool := "replicapool"
snapList, err := listSnapshots(f, pool, images[0])
if err != nil {
Fail(err.Error())
}
if len(snapList) != 1 {
e2elog.Logf("backend snapshot not matching kube snap count,snap count = % kube snap count %d", len(snapList), 1)
Fail("validate backend snapshot failed")
}

validatePVCAndAppBinding(pvcClonePath, appClonePath, f)

err = deleteSnapshot(&snap, deployTimeout)
if err != nil {
Fail(err.Error())
}
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
Fail(err.Error())
}
validateCloneFromSnapshot(pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath, 1, true, false, f)
})

By("create a block type PVC and Bind it to an app", func() {
Expand Down
Loading

0 comments on commit 70c3b52

Please sign in to comment.