diff --git a/docs/deploy-cephfs.md b/docs/deploy-cephfs.md index fcffbf954..2ca5b4b96 100644 --- a/docs/deploy-cephfs.md +++ b/docs/deploy-cephfs.md @@ -70,7 +70,7 @@ is used to define in which namespace you want the configmaps to be stored | `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 | | `fsName` | yes | CephFS filesystem name into which the volume shall be created | | `mounter` | no | Mount method to be used for this volume. Available options are `kernel` for Ceph kernel client and `fuse` for Ceph FUSE driver. Defaults to "default mounter", see command line arguments. | -| `pool` | yes | Ceph pool into which the volume shall be created | +| `pool` | no | Ceph pool into which volume data shall be stored | | `csi.storage.k8s.io/provisioner-secret-name`, `csi.storage.k8s.io/node-stage-secret-name` | 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` | for Kubernetes | Namespaces of the above Secret objects | diff --git a/e2e/cephfs.go b/e2e/cephfs.go index 96b208cb5..ceb3a2b75 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -44,7 +44,6 @@ var _ = Describe("cephfs", func() { createFileSystem(f.ClientSet) createConfigMap(cephfsDirPath, f.ClientSet, f) deployCephfsPlugin() - createCephfsStorageClass(f.ClientSet, f) createCephfsSecret(f.ClientSet, f) }) @@ -85,6 +84,14 @@ var _ = Describe("cephfs", func() { Fail(err.Error()) } + By("create a storage class with pool and a PVC then Bind it to an app", func() { + createCephfsStorageClass(f.ClientSet, f, true) + validatePVCAndAppBinding(pvcPath, appPath, f) + deleteResource(cephfsExamplePath + "storageclass.yaml") + }) + + createCephfsStorageClass(f.ClientSet, f, false) + By("create and delete a PVC", func() { By("create a PVC and Bind it to an app", func() { validatePVCAndAppBinding(pvcPath, appPath, f) diff --git a/e2e/utils.go b/e2e/utils.go index 4bc17ffcf..1bef73753 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -200,11 +200,13 @@ func getSnapshot(path string) v1alpha1.VolumeSnapshot { return sc } -func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework) { +func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool) { scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml") sc := getStorageClass(scPath) - sc.Parameters["pool"] = "myfs-data0" sc.Parameters["fsName"] = "myfs" + if enablePool { + sc.Parameters["pool"] = "myfs-data0" + } opt := metav1.ListOptions{ LabelSelector: "app=rook-ceph-tools", } diff --git a/examples/cephfs/storageclass.yaml b/examples/cephfs/storageclass.yaml index f5974e98a..2db52a0a6 100644 --- a/examples/cephfs/storageclass.yaml +++ b/examples/cephfs/storageclass.yaml @@ -17,8 +17,8 @@ parameters: # CephFS filesystem name into which the volume shall be created fsName: myfs - # Ceph pool into which the volume shall be created - pool: cephfs_data + # (optional) Ceph pool into which volume data shall be stored + # pool: cephfs_data # The secrets have to contain user and/or Ceph admin credentials. csi.storage.k8s.io/provisioner-secret-name: csi-cephfs-secret diff --git a/pkg/cephfs/volume.go b/pkg/cephfs/volume.go index 45f69a81c..8f3e2fdb4 100644 --- a/pkg/cephfs/volume.go +++ b/pkg/cephfs/volume.go @@ -94,8 +94,8 @@ func createVolume(volOptions *volumeOptions, cr *util.Credentials, volID volumeI klog.V(4).Infof("cephfs: created subvolume group csi") cephfsInit = true } - err := execCommandErr( - "ceph", + + args := []string{ "fs", "subvolume", "create", @@ -104,12 +104,20 @@ func createVolume(volOptions *volumeOptions, cr *util.Credentials, volID volumeI strconv.FormatInt(bytesQuota, 10), "--group_name", csiSubvolumeGroup, - "--pool_layout", volOptions.Pool, "--mode", "777", "-m", volOptions.Monitors, "-c", util.CephConfigPath, - "-n", cephEntityClientPrefix+cr.ID, - "--keyfile="+cr.KeyFile) + "-n", cephEntityClientPrefix + cr.ID, + "--keyfile=" + cr.KeyFile, + } + + if volOptions.Pool != "" { + args = append(args, "--pool_layout", volOptions.Pool) + } + + err := execCommandErr( + "ceph", + args[:]...) if err != nil { klog.Errorf("failed to create subvolume %s(%s) in fs %s", string(volID), err, volOptions.FsName) return err diff --git a/pkg/cephfs/volumeoptions.go b/pkg/cephfs/volumeoptions.go index 13ee4932e..670c76141 100644 --- a/pkg/cephfs/volumeoptions.go +++ b/pkg/cephfs/volumeoptions.go @@ -134,7 +134,7 @@ func newVolumeOptions(requestName string, size int64, volOptions, secret map[str return nil, err } - if err = extractOption(&opts.Pool, "pool", volOptions); err != nil { + if err = extractOptionalOption(&opts.Pool, "pool", volOptions); err != nil { return nil, err } @@ -218,7 +218,7 @@ func newVolumeOptionsFromVolID(volID string, volOpt, secrets map[string]string) } if volOpt != nil { - if err = extractOption(&volOptions.Pool, "pool", volOpt); err != nil { + if err = extractOptionalOption(&volOptions.Pool, "pool", volOpt); err != nil { return nil, nil, err }