From 1d176004014ddc18ea9f3d86ce2593e5b475d183 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 12 Jan 2024 08:56:06 +0100 Subject: [PATCH 1/3] cephfs: make fsname as optional for static PVC consider fsName optional for static volume as it is not required to be set during mount operation with fuse and kernel client. fixes: #4311 Signed-off-by: Madhu Rajanna --- internal/cephfs/store/volumeoptions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cephfs/store/volumeoptions.go b/internal/cephfs/store/volumeoptions.go index 569b17ae93a..de5b14b1db0 100644 --- a/internal/cephfs/store/volumeoptions.go +++ b/internal/cephfs/store/volumeoptions.go @@ -697,7 +697,7 @@ func NewVolumeOptionsFromStaticVolume( return nil, nil, err } - if err = extractOption(&opts.FsName, "fsName", options); err != nil { + if err = extractOptionalOption(&opts.FsName, "fsName", options); err != nil { return nil, nil, err } From e008e1609551a58460cb9857e8c6f97bb60fec09 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 12 Jan 2024 09:08:16 +0100 Subject: [PATCH 2/3] e2e: add e2e to test static pvc added e2e test case to verify static pvc with and without fsName in the PV object. Signed-off-by: Madhu Rajanna --- e2e/cephfs.go | 14 +++++++++++--- e2e/staticpvc.go | 6 ++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e/cephfs.go b/e2e/cephfs.go index 43171537f49..6a1de944d43 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -474,11 +474,19 @@ var _ = Describe(cephfsType, func() { } }) - By("check static PVC", func() { + By("check static PVC with FsName", func() { scPath := cephFSExamplePath + "secret.yaml" - err := validateCephFsStaticPV(f, appPath, scPath) + err := validateCephFsStaticPV(f, appPath, scPath, fileSystemName) if err != nil { - framework.Failf("failed to validate CephFS static pv: %v", err) + framework.Failf("failed to validate CephFS static pv with filesystem name: %v", err) + } + }) + + By("check static PVC with without FsName", func() { + scPath := cephFSExamplePath + "secret.yaml" + err := validateCephFsStaticPV(f, appPath, scPath, "") + if err != nil { + framework.Failf("failed to validate CephFS static pv without filesystem name: %v", err) } }) diff --git a/e2e/staticpvc.go b/e2e/staticpvc.go index f76d76f6a2f..bed9bd3abea 100644 --- a/e2e/staticpvc.go +++ b/e2e/staticpvc.go @@ -323,7 +323,7 @@ func validateRBDStaticMigrationPVC(f *framework.Framework, appPath, scName strin } //nolint:gocyclo,cyclop // reduce complexity -func validateCephFsStaticPV(f *framework.Framework, appPath, scPath string) error { +func validateCephFsStaticPV(f *framework.Framework, appPath, scPath, fsName string) error { opt := make(map[string]string) var ( cephFsVolName = "testSubVol" @@ -406,7 +406,9 @@ func validateCephFsStaticPV(f *framework.Framework, appPath, scPath string) erro } opt["clusterID"] = fsID - opt["fsName"] = fileSystemName + if fsName != "" { + opt["fsName"] = fsName + } opt["staticVolume"] = strconv.FormatBool(true) opt["rootPath"] = rootPath pv := getStaticPV( From 200fbdbf28591c404a85888d8bfc9561fa23dbb8 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 12 Jan 2024 10:12:16 +0100 Subject: [PATCH 3/3] doc: fix fsName details in PV object fsName is optional and its required to mount the filesystem incase if we have multiple filesystem in the cluster. Signed-off-by: Madhu Rajanna --- docs/static-pvc.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/static-pvc.md b/docs/static-pvc.md index 601bf450ddf..8adde7f7bb6 100644 --- a/docs/static-pvc.md +++ b/docs/static-pvc.md @@ -202,9 +202,10 @@ spec: # node stage secret namespace where above secret is created namespace: default volumeAttributes: + # optional file system to be mounted + "fsName": "myfs" # Required options from storageclass parameters need to be added in volumeAttributes "clusterID": "ba68226a-672f-4ba5-97bc-22840318b2ec" - "fsName": "myfs" "staticVolume": "true" "rootPath": /volumes/testGroup/testSubVolume # volumeHandle can be anything, need not to be same @@ -228,7 +229,7 @@ static CephFS PV | Attributes | Description | Required | | :----------: | :--------------------------------------------------------------------------------------------------------------------------------------------------: | :------: | | clusterID | The clusterID is used by the CSI plugin to uniquely identify and use a Ceph cluster (this is the key in configmap created duing ceph-csi deployment) | Yes | -| fsName | CephFS filesystem name into which the subvolume should be created/present | Yes | +| fsName | CephFS filesystem name to be mounted. Not passing this option mounts the default file system. | No | | staticVolume | Value must be set to `true` to mount and unmount static cephFS PVC | Yes | | rootPath | Actual path of the subvolume in ceph cluster, can be retrieved by issuing getpath command as described above | Yes |