Make parameter pool optional in CephFS storageclass

Signed-off-by: Daniel-Pivonka <dpivonka@redhat.com>
This commit is contained in:
Daniel-Pivonka 2019-08-05 11:40:48 -04:00 committed by mergify[bot]
parent 5b461a0787
commit 0063727199
6 changed files with 30 additions and 13 deletions

View File

@ -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 |

View File

@ -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)

View File

@ -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",
}

View File

@ -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

View File

@ -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)
"--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

View File

@ -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
}