From fb3835691f2a90ea1661b60833d8cacfc42e5593 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 17 Feb 2022 11:31:34 +0530 Subject: [PATCH] rbd: add support for deep-flatten image feature as deep-flatten is long supported in ceph and its enabled by default in the librbd, providing an option to enable it in cephcsi for the rbd images we are creating. Signed-off-by: Madhu Rajanna --- charts/ceph-csi-rbd/values.yaml | 8 ++--- docs/deploy-rbd.md | 2 +- e2e/rbd.go | 57 +++++++++++++++++++++++++++++++++ e2e/rbd_helper.go | 12 +++++++ examples/rbd/storageclass.yaml | 8 ++--- internal/rbd/rbd_util.go | 3 ++ internal/rbd/rbd_util_test.go | 8 +++++ 7 files changed, 89 insertions(+), 9 deletions(-) diff --git a/charts/ceph-csi-rbd/values.yaml b/charts/ceph-csi-rbd/values.yaml index 81d6df623..90c09dcbb 100644 --- a/charts/ceph-csi-rbd/values.yaml +++ b/charts/ceph-csi-rbd/values.yaml @@ -279,10 +279,10 @@ storageClass: # eg: pool: replicapool pool: replicapool - # (required) RBD image features, CSI creates image with image-format 2 - # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, - # `object-map`, `fast-diff` features. If `journaling` is enabled, must - # enable `exclusive-lock` too. + # (required) RBD image features, CSI creates image with image-format 2 CSI + # RBD currently supports `layering`, `journaling`, `exclusive-lock`, + # `object-map`, `fast-diff`, `deep-flatten` features. If `journaling` is + # enabled, must enable `exclusive-lock` too. # imageFeatures: layering,journaling,exclusive-lock,object-map,fast-diff imageFeatures: "layering" diff --git a/docs/deploy-rbd.md b/docs/deploy-rbd.md index bdb9d30b1..a800a7367 100644 --- a/docs/deploy-rbd.md +++ b/docs/deploy-rbd.md @@ -56,7 +56,7 @@ make image-cephcsi | `dataPool` | no | Ceph pool used for the data of the RBD images. | | `volumeNamePrefix` | no | Prefix to use for naming RBD images (defaults to `csi-vol-`). | | `snapshotNamePrefix` | no | Prefix to use for naming RBD snapshot images (defaults to `csi-snap-`). | -| `imageFeatures` | yes | RBD image features. CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, `object-map`, `fast-diff` features. If `journaling` is enabled, must enable `exclusive-lock` too. See [man pages](http://docs.ceph.com/docs/master/man/8/rbd/#cmdoption-rbd-image-feature) Note that the required support for [object-map and fast-diff were added in 5.3 and journaling does not have KRBD support yet](https://docs.ceph.com/en/latest/rbd/rbd-config-ref/#image-features). deep-flatten is added for cloned images. | +| `imageFeatures` | yes | RBD image features. CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, `object-map`, `fast-diff`, `deep-flatten` features. If `journaling` is enabled, must enable `exclusive-lock` too. See [man pages](http://docs.ceph.com/docs/master/man/8/rbd/#cmdoption-rbd-image-feature) Note that the required support for [object-map and fast-diff were added in 5.3, deep-flatten was added in 5.1 and journaling does not have KRBD support yet](https://docs.ceph.com/en/latest/rbd/rbd-config-ref/#image-features). deep-flatten is added for cloned images. | | `tryOtherMounters` | no | Specifies whether to try other mounters in case if the current mounter fails to mount the rbd image for any reason | | `mapOptions` | no | Map options to use when mapping rbd image. See [krbd](https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options) and [nbd](https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options) options. | | `unmapOptions` | no | Unmap options to use when unmapping rbd image. See [krbd](https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options) and [nbd](https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options) options. | diff --git a/e2e/rbd.go b/e2e/rbd.go index 2a071ead7..ccce3093d 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -795,6 +795,63 @@ var _ = Describe("RBD", func() { } }) + By("create PVC with layering,deep-flatten image-features and bind it to an app", + func() { + err := deleteResource(rbdExamplePath + "storageclass.yaml") + if err != nil { + e2elog.Failf("failed to delete storageclass: %v", err) + } + err = createRBDStorageClass( + f.ClientSet, + f, + defaultSCName, + nil, + map[string]string{ + "imageFeatures": "layering,deep-flatten", + }, + deletePolicy) + if err != nil { + e2elog.Failf("failed to create storageclass: %v", err) + } + // set up PVC + pvc, err := loadPVC(pvcPath) + if err != nil { + e2elog.Failf("failed to load PVC: %v", err) + } + pvc.Namespace = f.UniqueName + err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) + if err != nil { + e2elog.Failf("failed to create PVC: %v", err) + } + // validate created backend rbd images + validateRBDImageCount(f, 1, defaultRBDPool) + + if util.CheckKernelSupport(kernelRelease, deepFlattenSupport) { + app, aErr := loadApp(appPath) + if aErr != nil { + e2elog.Failf("failed to load application: %v", aErr) + } + app.Namespace = f.UniqueName + err = createApp(f.ClientSet, app, deployTimeout) + if err != nil { + e2elog.Failf("failed to create application: %v", err) + } + // delete pod as we should not create snapshot for in-use pvc + err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout) + if err != nil { + e2elog.Failf("failed to delete application: %v", err) + } + + } + // clean up after ourselves + err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) + if err != nil { + e2elog.Failf("failed to delete PVC: %v", err) + } + // validate created backend rbd images + validateRBDImageCount(f, 0, defaultRBDPool) + }) + By("create PVC with journaling,fast-diff image-features and bind it to an app using rbd-nbd mounter", func() { if util.CheckKernelSupport(kernelRelease, fastDiffSupport) { diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index 290eab933..4777b2545 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -62,6 +62,18 @@ var fastDiffSupport = []util.KernelVersion{ }, // standard 5.3+ versions } +// nolint:gomnd // numbers specify Kernel versions. +var deepFlattenSupport = []util.KernelVersion{ + { + Version: 5, + PatchLevel: 1, + SubLevel: 0, + ExtraVersion: 0, + Distribution: "", + Backport: false, + }, // standard 5.1+ versions +} + // To use `io-timeout=0` we need // www.mail-archive.com/linux-block@vger.kernel.org/msg38060.html // nolint:gomnd // numbers specify Kernel versions. diff --git a/examples/rbd/storageclass.yaml b/examples/rbd/storageclass.yaml index 2d6e0927c..dd858e861 100644 --- a/examples/rbd/storageclass.yaml +++ b/examples/rbd/storageclass.yaml @@ -29,10 +29,10 @@ parameters: # eg: pool: rbdpool pool: - # (required) RBD image features, CSI creates image with image-format 2 - # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, - # `object-map`, `fast-diff` features. If `journaling` is enabled, must - # enable `exclusive-lock` too. + # (required) RBD image features, CSI creates image with image-format 2 CSI + # RBD currently supports `layering`, `journaling`, `exclusive-lock`, + # `object-map`, `fast-diff`, `deep-flatten` features. If `journaling` is + # enabled, must enable `exclusive-lock` too. # imageFeatures: layering,journaling,exclusive-lock,object-map,fast-diff imageFeatures: "layering" diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 71eb98685..f515d12ce 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -209,6 +209,9 @@ var supportedFeatures = map[string]imageFeature{ needRbdNbd: true, dependsOn: []string{librbd.FeatureNameExclusiveLock}, }, + librbd.FeatureNameDeepFlatten: { + needRbdNbd: false, + }, } // GetKrbdSupportedFeatures load the module if needed and return supported diff --git a/internal/rbd/rbd_util_test.go b/internal/rbd/rbd_util_test.go index 6007106ba..16820b8c7 100644 --- a/internal/rbd/rbd_util_test.go +++ b/internal/rbd/rbd_util_test.go @@ -152,6 +152,14 @@ func TestValidateImageFeatures(t *testing.T) { true, "invalid feature ayering", }, + { + "deep-flatten", + &rbdVolume{ + Mounter: rbdDefaultMounter, + }, + false, + "", + }, } for _, test := range tests {