diff --git a/docs/deploy-rbd.md b/docs/deploy-rbd.md index 6c47508fb..86e0eb025 100644 --- a/docs/deploy-rbd.md +++ b/docs/deploy-rbd.md @@ -51,8 +51,7 @@ make image-cephcsi | `clusterID` | yes | String representing a Ceph cluster, must be unique across all Ceph clusters in use for provisioning, cannot be greater than 36 bytes in length, and should remain immutable for the lifetime of the Ceph cluster in use | | `pool` | yes | Ceph pool into which the RBD image shall be created | | `dataPool` | no | Ceph pool used for the data of the RBD images. | -| `imageFormat` | no | RBD image format. Defaults to `2`. See [man pages](http://docs.ceph.com/docs/mimic/man/8/rbd/#cmdoption-rbd-image-format) | -| `imageFeatures` | no | RBD image features. Available for `imageFormat=2`. CSI RBD currently supports only `layering` feature. See [man pages](http://docs.ceph.com/docs/mimic/man/8/rbd/#cmdoption-rbd-image-feature) | +| `imageFeatures` | no | RBD image features. CSI RBD currently supports only `layering` feature. See [man pages](http://docs.ceph.com/docs/mimic/man/8/rbd/#cmdoption-rbd-image-feature) | | `csi.storage.k8s.io/provisioner-secret-name`, `csi.storage.k8s.io/node-stage-secret-name` | yes (for Kubernetes) | name of the Kubernetes Secret object containing Ceph client credentials. Both parameters should have the same value | | `csi.storage.k8s.io/provisioner-secret-namespace`, `csi.storage.k8s.io/node-stage-secret-namespace` | yes (for Kubernetes) | namespaces of the above Secret objects | | `mounter` | no | if set to `rbd-nbd`, use `rbd-nbd` on nodes that have `rbd-nbd` and `nbd` kernel modules to map rbd images | diff --git a/examples/rbd/storageclass.yaml b/examples/rbd/storageclass.yaml index 7785c4d27..116bb1e1e 100644 --- a/examples/rbd/storageclass.yaml +++ b/examples/rbd/storageclass.yaml @@ -21,10 +21,7 @@ parameters: # dataPool: ec-data-pool pool: rbd - # RBD image format. Defaults to "2". - imageFormat: "2" - - # RBD image features. Available for imageFormat: "2" + # RBD image features, CSI creates image with image-format 2 # CSI RBD currently supports only `layering` feature. imageFeatures: layering diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index fe9b93ed9..30c77f64f 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -122,25 +122,15 @@ func createImage(ctx context.Context, pOpts *rbdVolume, volSz int64, cr *util.Cr image := pOpts.RbdImageName volSzMiB := fmt.Sprintf("%dM", volSz) - if pOpts.ImageFormat == rbdImageFormat2 { - logMsg := "rbd: create %s size %s format %s (features: %s) using mon %s, pool %s " - if pOpts.DataPool != "" { - logMsg += fmt.Sprintf("data pool %s", pOpts.DataPool) - } - klog.V(4).Infof(util.Log(ctx, logMsg), - image, volSzMiB, pOpts.ImageFormat, pOpts.ImageFeatures, pOpts.Monitors, pOpts.Pool) - } else { - logMsg := "rbd: create %s size %s format %s using mon %s, pool %s " - if pOpts.DataPool != "" { - logMsg += fmt.Sprintf("data pool %s", pOpts.DataPool) - } - klog.V(4).Infof(util.Log(ctx, logMsg), image, volSzMiB, pOpts.ImageFormat, pOpts.Monitors, pOpts.Pool) + logMsg := "rbd: create %s size %s format 2 (features: %s) using mon %s, pool %s " + if pOpts.DataPool != "" { + logMsg += fmt.Sprintf("data pool %s", pOpts.DataPool) } + klog.V(4).Infof(util.Log(ctx, logMsg), + image, volSzMiB, pOpts.ImageFeatures, pOpts.Monitors, pOpts.Pool) + + args := []string{"create", image, "--size", volSzMiB, "--pool", pOpts.Pool, "--id", cr.ID, "-m", pOpts.Monitors, "--keyfile=" + cr.KeyFile, "--image-feature", pOpts.ImageFeatures} - args := []string{"create", image, "--size", volSzMiB, "--pool", pOpts.Pool, "--id", cr.ID, "-m", pOpts.Monitors, "--keyfile=" + cr.KeyFile, "--image-format", pOpts.ImageFormat} - if pOpts.ImageFormat == rbdImageFormat2 { - args = append(args, "--image-feature", pOpts.ImageFeatures) - } if pOpts.DataPool != "" { args = append(args, "--data-pool", pOpts.DataPool) } @@ -479,25 +469,19 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st } } - rbdVol.ImageFormat, ok = volOptions["imageFormat"] - if !ok { - rbdVol.ImageFormat = rbdImageFormat2 - } + // if no image features is provided, it results in empty string + // which disable all RBD image format 2 features as we expected - if rbdVol.ImageFormat == rbdImageFormat2 { - // if no image features is provided, it results in empty string - // which disable all RBD image format 2 features as we expected - imageFeatures, found := volOptions["imageFeatures"] - if found { - arr := strings.Split(imageFeatures, ",") - for _, f := range arr { - if !supportedFeatures.Has(f) { - return nil, fmt.Errorf("invalid feature %q for volume csi-rbdplugin, supported"+ - " features are: %v", f, supportedFeatures) - } + imageFeatures, found := volOptions["imageFeatures"] + if found { + arr := strings.Split(imageFeatures, ",") + for _, f := range arr { + if !supportedFeatures.Has(f) { + return nil, fmt.Errorf("invalid feature %q for volume csi-rbdplugin, supported"+ + " features are: %v", f, supportedFeatures) } - rbdVol.ImageFeatures = imageFeatures } + rbdVol.ImageFeatures = imageFeatures } klog.V(3).Infof(util.Log(ctx, "setting disableInUseChecks on rbd volume to: %v"), disableInUseChecks)