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>
This commit is contained in:
Madhu Rajanna 2022-04-18 11:38:52 +05:30 committed by mergify[bot]
parent 766346868e
commit b4acbd08a5
5 changed files with 36 additions and 17 deletions

View File

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

View File

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

View File

@ -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 <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.
# 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": "<cluster-id>",
"radosNamespace": "<rados-namespace>",
"rbd": {
"netNamespaceFilePath": "<kubeletRootPath>/plugins/rbd.csi.ceph.com/net",
"radosNamespace": "<rados-namespace>",
},
"monitors": [
"<MONValue1>",

View File

@ -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": "<cluster-id>",
// "radosNamespace": "<rados-namespace>",
// "monitors":
// [
// "<monitor-value>",
// "<monitor-value>",
// "clusterID": "<cluster-id>",
// "rbd": {
// "radosNamespace": "<rados-namespace>"
// },
// "monitors":
// [
// "<monitor-value>",
// "<monitor-value>",
// ...
// ],
// "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
}

View File

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