remove support for create image with image-format 1

tried to create an image with image-format=1

```
sh-4.2# rbd create --size=1024 replicapool/test --image-format=1
rbd: image format 1 is deprecated
rbd: create error: (22) Invalid argument
2019-09-11 07:00:54.531 7fb0e40bfb00 -1 librbd: Format 1 image creation unsupported.
```

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2019-09-11 12:38:55 +05:30 committed by mergify[bot]
parent e395080cdc
commit 6da96c6327
3 changed files with 19 additions and 39 deletions

View File

@ -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 | | `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 | | `pool` | yes | Ceph pool into which the RBD image shall be created |
| `dataPool` | no | Ceph pool used for the data of the RBD images. | | `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. 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. 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) |
| `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-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 | | `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 | | `mounter` | no | if set to `rbd-nbd`, use `rbd-nbd` on nodes that have `rbd-nbd` and `nbd` kernel modules to map rbd images |

View File

@ -21,10 +21,7 @@ parameters:
# dataPool: ec-data-pool # dataPool: ec-data-pool
pool: rbd pool: rbd
# RBD image format. Defaults to "2". # RBD image features, CSI creates image with image-format 2
imageFormat: "2"
# RBD image features. Available for imageFormat: "2"
# CSI RBD currently supports only `layering` feature. # CSI RBD currently supports only `layering` feature.
imageFeatures: layering imageFeatures: layering

View File

@ -122,25 +122,15 @@ func createImage(ctx context.Context, pOpts *rbdVolume, volSz int64, cr *util.Cr
image := pOpts.RbdImageName image := pOpts.RbdImageName
volSzMiB := fmt.Sprintf("%dM", volSz) volSzMiB := fmt.Sprintf("%dM", volSz)
if pOpts.ImageFormat == rbdImageFormat2 { logMsg := "rbd: create %s size %s format 2 (features: %s) using mon %s, pool %s "
logMsg := "rbd: create %s size %s format %s (features: %s) using mon %s, pool %s "
if pOpts.DataPool != "" { if pOpts.DataPool != "" {
logMsg += fmt.Sprintf("data pool %s", pOpts.DataPool) logMsg += fmt.Sprintf("data pool %s", pOpts.DataPool)
} }
klog.V(4).Infof(util.Log(ctx, logMsg), klog.V(4).Infof(util.Log(ctx, logMsg),
image, volSzMiB, pOpts.ImageFormat, pOpts.ImageFeatures, pOpts.Monitors, pOpts.Pool) image, volSzMiB, pOpts.ImageFeatures, pOpts.Monitors, pOpts.Pool)
} else {
logMsg := "rbd: create %s size %s format %s using mon %s, pool %s " args := []string{"create", image, "--size", volSzMiB, "--pool", pOpts.Pool, "--id", cr.ID, "-m", pOpts.Monitors, "--keyfile=" + cr.KeyFile, "--image-feature", pOpts.ImageFeatures}
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)
}
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 != "" { if pOpts.DataPool != "" {
args = append(args, "--data-pool", pOpts.DataPool) args = append(args, "--data-pool", pOpts.DataPool)
} }
@ -479,14 +469,9 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st
} }
} }
rbdVol.ImageFormat, ok = volOptions["imageFormat"]
if !ok {
rbdVol.ImageFormat = rbdImageFormat2
}
if rbdVol.ImageFormat == rbdImageFormat2 {
// if no image features is provided, it results in empty string // if no image features is provided, it results in empty string
// which disable all RBD image format 2 features as we expected // which disable all RBD image format 2 features as we expected
imageFeatures, found := volOptions["imageFeatures"] imageFeatures, found := volOptions["imageFeatures"]
if found { if found {
arr := strings.Split(imageFeatures, ",") arr := strings.Split(imageFeatures, ",")
@ -498,7 +483,6 @@ func genVolFromVolumeOptions(ctx context.Context, volOptions, credentials map[st
} }
rbdVol.ImageFeatures = imageFeatures rbdVol.ImageFeatures = imageFeatures
} }
}
klog.V(3).Infof(util.Log(ctx, "setting disableInUseChecks on rbd volume to: %v"), disableInUseChecks) klog.V(3).Infof(util.Log(ctx, "setting disableInUseChecks on rbd volume to: %v"), disableInUseChecks)
rbdVol.DisableInUseChecks = disableInUseChecks rbdVol.DisableInUseChecks = disableInUseChecks