From f8a19c8cbb58bba8b1c95bd6f3385247dce0ecaf Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 18 Apr 2022 11:38:52 +0530 Subject: [PATCH] rbd: move radosNamespace to RBD section As radosNamespace is more specific to RBD not the general ceph configuration. Now we introduced a new RBD section for RBD specific options, Moving the radosNamespace to RBD section and keeping the radosNamespace still under the global ceph level configration for backward compatibility. Signed-off-by: Madhu Rajanna (cherry picked from commit b4acbd08a5e5c6169dd52cc99be5ccfad06419d1) --- docs/design/proposals/clusterid-mapping.md | 8 ++++++-- e2e/configmap.go | 13 +++++++++---- examples/csi-config-map-sample.yaml | 8 ++++---- internal/util/csiconfig.go | 22 +++++++++++++++------- internal/util/csiconfig_test.go | 2 ++ 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/docs/design/proposals/clusterid-mapping.md b/docs/design/proposals/clusterid-mapping.md index 4f45e05d5..182b87e3a 100644 --- a/docs/design/proposals/clusterid-mapping.md +++ b/docs/design/proposals/clusterid-mapping.md @@ -44,7 +44,9 @@ data: [ { "clusterID": "rook-ceph", - "radosNamespace": "", + "rbd": { + "radosNamespace": "", + }, "monitors": [ "192.168.39.82:6789" ], @@ -54,7 +56,9 @@ data: }, { "clusterID": "fs-id", - "radosNamespace": "", + "rbd": { + "radosNamespace": "", + }, "monitors": [ "192.168.39.83:6789" ], diff --git a/e2e/configmap.go b/e2e/configmap.go index 932f37fe0..348740092 100644 --- a/e2e/configmap.go +++ b/e2e/configmap.go @@ -60,9 +60,14 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra return err } conmap := []util.ClusterInfo{{ - ClusterID: fsID, - Monitors: mons, - RadosNamespace: radosNamespace, + ClusterID: fsID, + Monitors: mons, + RBD: struct { + NetNamespaceFilePath string `json:"netNamespaceFilePath"` + RadosNamespace string `json:"radosNamespace"` + }{ + RadosNamespace: radosNamespace, + }, }} if upgradeTesting { subvolumegroup = "csi" @@ -132,7 +137,7 @@ func createCustomConfigMap( case "radosNamespace": for c := range conmap { if conmap[c].ClusterID == cluster { - conmap[c].RadosNamespace = j + conmap[c].RBD.RadosNamespace = j } } } diff --git a/examples/csi-config-map-sample.yaml b/examples/csi-config-map-sample.yaml index 2e59ab6b2..ee8c6a63d 100644 --- a/examples/csi-config-map-sample.yaml +++ b/examples/csi-config-map-sample.yaml @@ -13,9 +13,9 @@ kind: ConfigMap # each such cluster in use. # To add more clusters or edit MON addresses in an existing configmap, use # the `kubectl replace` command. -# The is optional and represents a radosNamespace in the pool. -# If any given, all of the rbd images, snapshots, and other metadata will be -# stored within the radosNamespace. +# The "rbd.rados-namespace" is optional and represents a radosNamespace in the +# pool. If any given, all of the rbd images, snapshots, and other metadata will +# be stored within the radosNamespace. # NOTE: The given radosNamespace must already exists in the pool. # NOTE: Make sure you don't add radosNamespace option to a currently in use # configuration as it will cause issues. @@ -42,9 +42,9 @@ data: [ { "clusterID": "", - "radosNamespace": "", "rbd": { "netNamespaceFilePath": "/plugins/rbd.csi.ceph.com/net", + "radosNamespace": "", }, "monitors": [ "", diff --git a/internal/util/csiconfig.go b/internal/util/csiconfig.go index 0eb3c021b..9ccd52ffd 100644 --- a/internal/util/csiconfig.go +++ b/internal/util/csiconfig.go @@ -41,7 +41,7 @@ type ClusterInfo struct { // ClusterID is used for unique identification ClusterID string `json:"clusterID"` // RadosNamespace is a rados namespace in the pool - RadosNamespace string `json:"radosNamespace"` + RadosNamespace string `json:"radosNamespace"` // For backward compatibility. TODO: Remove this in 3.7.0 // Monitors is monitor list for corresponding cluster ID Monitors []string `json:"monitors"` // CephFS contains CephFS specific options @@ -54,18 +54,22 @@ type ClusterInfo struct { RBD struct { // symlink filepath for the network namespace where we need to execute commands. NetNamespaceFilePath string `json:"netNamespaceFilePath"` + // RadosNamespace is a rados namespace in the pool + RadosNamespace string `json:"radosNamespace"` } `json:"rbd"` } // Expected JSON structure in the passed in config file is, // [ // { -// "clusterID": "", -// "radosNamespace": "", -// "monitors": -// [ -// "", -// "", +// "clusterID": "", +// "rbd": { +// "radosNamespace": "" +// }, +// "monitors": +// [ +// "", +// "", // ... // ], // "cephFS": { @@ -121,6 +125,10 @@ func GetRadosNamespace(pathToConfig, clusterID string) (string, error) { return "", err } + if cluster.RBD.RadosNamespace != "" { + return cluster.RBD.RadosNamespace, nil + } + return cluster.RadosNamespace, nil } diff --git a/internal/util/csiconfig_test.go b/internal/util/csiconfig_test.go index edecc83d9..519b25011 100644 --- a/internal/util/csiconfig_test.go +++ b/internal/util/csiconfig_test.go @@ -170,6 +170,7 @@ func TestGetRBDNetNamespaceFilePath(t *testing.T) { Monitors: []string{"ip-1", "ip-2"}, RBD: struct { NetNamespaceFilePath string `json:"netNamespaceFilePath"` + RadosNamespace string `json:"radosNamespace"` }{ NetNamespaceFilePath: "/var/lib/kubelet/plugins/rbd.ceph.csi.com/cluster1-net", }, @@ -179,6 +180,7 @@ func TestGetRBDNetNamespaceFilePath(t *testing.T) { Monitors: []string{"ip-3", "ip-4"}, RBD: struct { NetNamespaceFilePath string `json:"netNamespaceFilePath"` + RadosNamespace string `json:"radosNamespace"` }{ NetNamespaceFilePath: "/var/lib/kubelet/plugins/rbd.ceph.csi.com/cluster2-net", },