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 <madhupr007@gmail.com>
(cherry picked from commit b4acbd08a5)
This commit is contained in:
Madhu Rajanna 2022-04-18 11:38:52 +05:30 committed by mergify[bot]
parent 76398d6887
commit f8a19c8cbb
5 changed files with 36 additions and 17 deletions

View File

@ -44,7 +44,9 @@ data:
[ [
{ {
"clusterID": "rook-ceph", "clusterID": "rook-ceph",
"radosNamespace": "<rados-namespace>", "rbd": {
"radosNamespace": "<rados-namespace>",
},
"monitors": [ "monitors": [
"192.168.39.82:6789" "192.168.39.82:6789"
], ],
@ -54,7 +56,9 @@ data:
}, },
{ {
"clusterID": "fs-id", "clusterID": "fs-id",
"radosNamespace": "<rados-namespace>", "rbd": {
"radosNamespace": "<rados-namespace>",
},
"monitors": [ "monitors": [
"192.168.39.83:6789" "192.168.39.83:6789"
], ],

View File

@ -60,9 +60,14 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
return err return err
} }
conmap := []util.ClusterInfo{{ conmap := []util.ClusterInfo{{
ClusterID: fsID, ClusterID: fsID,
Monitors: mons, Monitors: mons,
RadosNamespace: radosNamespace, RBD: struct {
NetNamespaceFilePath string `json:"netNamespaceFilePath"`
RadosNamespace string `json:"radosNamespace"`
}{
RadosNamespace: radosNamespace,
},
}} }}
if upgradeTesting { if upgradeTesting {
subvolumegroup = "csi" subvolumegroup = "csi"
@ -132,7 +137,7 @@ func createCustomConfigMap(
case "radosNamespace": case "radosNamespace":
for c := range conmap { for c := range conmap {
if conmap[c].ClusterID == cluster { if conmap[c].ClusterID == cluster {
conmap[c].RadosNamespace = j conmap[c].RBD.RadosNamespace = j
} }
} }
} }

View File

@ -13,9 +13,9 @@ kind: ConfigMap
# each such cluster in use. # each such cluster in use.
# To add more clusters or edit MON addresses in an existing configmap, use # To add more clusters or edit MON addresses in an existing configmap, use
# the `kubectl replace` command. # the `kubectl replace` command.
# The <rados-namespace> is optional and represents a radosNamespace in the pool. # The "rbd.rados-namespace" is optional and represents a radosNamespace in the
# If any given, all of the rbd images, snapshots, and other metadata will be # pool. If any given, all of the rbd images, snapshots, and other metadata will
# stored within the radosNamespace. # be stored within the radosNamespace.
# NOTE: The given radosNamespace must already exists in the pool. # NOTE: The given radosNamespace must already exists in the pool.
# NOTE: Make sure you don't add radosNamespace option to a currently in use # NOTE: Make sure you don't add radosNamespace option to a currently in use
# configuration as it will cause issues. # configuration as it will cause issues.
@ -42,9 +42,9 @@ data:
[ [
{ {
"clusterID": "<cluster-id>", "clusterID": "<cluster-id>",
"radosNamespace": "<rados-namespace>",
"rbd": { "rbd": {
"netNamespaceFilePath": "<kubeletRootPath>/plugins/rbd.csi.ceph.com/net", "netNamespaceFilePath": "<kubeletRootPath>/plugins/rbd.csi.ceph.com/net",
"radosNamespace": "<rados-namespace>",
}, },
"monitors": [ "monitors": [
"<MONValue1>", "<MONValue1>",

View File

@ -41,7 +41,7 @@ type ClusterInfo struct {
// ClusterID is used for unique identification // ClusterID is used for unique identification
ClusterID string `json:"clusterID"` ClusterID string `json:"clusterID"`
// RadosNamespace is a rados namespace in the pool // 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 is monitor list for corresponding cluster ID
Monitors []string `json:"monitors"` Monitors []string `json:"monitors"`
// CephFS contains CephFS specific options // CephFS contains CephFS specific options
@ -54,18 +54,22 @@ type ClusterInfo struct {
RBD struct { RBD struct {
// symlink filepath for the network namespace where we need to execute commands. // symlink filepath for the network namespace where we need to execute commands.
NetNamespaceFilePath string `json:"netNamespaceFilePath"` NetNamespaceFilePath string `json:"netNamespaceFilePath"`
// RadosNamespace is a rados namespace in the pool
RadosNamespace string `json:"radosNamespace"`
} `json:"rbd"` } `json:"rbd"`
} }
// Expected JSON structure in the passed in config file is, // Expected JSON structure in the passed in config file is,
// [ // [
// { // {
// "clusterID": "<cluster-id>", // "clusterID": "<cluster-id>",
// "radosNamespace": "<rados-namespace>", // "rbd": {
// "monitors": // "radosNamespace": "<rados-namespace>"
// [ // },
// "<monitor-value>", // "monitors":
// "<monitor-value>", // [
// "<monitor-value>",
// "<monitor-value>",
// ... // ...
// ], // ],
// "cephFS": { // "cephFS": {
@ -121,6 +125,10 @@ func GetRadosNamespace(pathToConfig, clusterID string) (string, error) {
return "", err return "", err
} }
if cluster.RBD.RadosNamespace != "" {
return cluster.RBD.RadosNamespace, nil
}
return cluster.RadosNamespace, nil return cluster.RadosNamespace, nil
} }

View File

@ -170,6 +170,7 @@ func TestGetRBDNetNamespaceFilePath(t *testing.T) {
Monitors: []string{"ip-1", "ip-2"}, Monitors: []string{"ip-1", "ip-2"},
RBD: struct { RBD: struct {
NetNamespaceFilePath string `json:"netNamespaceFilePath"` NetNamespaceFilePath string `json:"netNamespaceFilePath"`
RadosNamespace string `json:"radosNamespace"`
}{ }{
NetNamespaceFilePath: "/var/lib/kubelet/plugins/rbd.ceph.csi.com/cluster1-net", 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"}, Monitors: []string{"ip-3", "ip-4"},
RBD: struct { RBD: struct {
NetNamespaceFilePath string `json:"netNamespaceFilePath"` NetNamespaceFilePath string `json:"netNamespaceFilePath"`
RadosNamespace string `json:"radosNamespace"`
}{ }{
NetNamespaceFilePath: "/var/lib/kubelet/plugins/rbd.ceph.csi.com/cluster2-net", NetNamespaceFilePath: "/var/lib/kubelet/plugins/rbd.ceph.csi.com/cluster2-net",
}, },