mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
e2e: change createCustomConfigmap to be more general
createCustomConfigmap helps to create a custom cluster entry in the configmap, however this was coupled with subvolumegroup filling in the cluster configuration. This commit helps to make it more general and the subvolumegroup filling is controlled now with a flag Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
parent
90d246fc55
commit
a4a2dc93c1
@ -533,12 +533,17 @@ var _ = Describe("cephfs", func() {
|
||||
if err != nil {
|
||||
e2elog.Failf("failed to delete storageclass with error %v", err)
|
||||
}
|
||||
|
||||
// re-define configmap with information of multiple clusters.
|
||||
subvolgrpInfo := map[string]string{
|
||||
"clusterID-1": "subvolgrp1",
|
||||
"clusterID-2": "subvolgrp2",
|
||||
}
|
||||
err = createCustomConfigMap(f.ClientSet, cephFSDirPath, subvolgrpInfo)
|
||||
clusterInfo := map[string]map[string]string{}
|
||||
clusterID1 := "clusterID-1"
|
||||
clusterID2 := "clusterID-2"
|
||||
clusterInfo[clusterID1] = map[string]string{}
|
||||
clusterInfo[clusterID1]["subvolumeGroup"] = "subvolgrp1"
|
||||
clusterInfo[clusterID2] = map[string]string{}
|
||||
clusterInfo[clusterID2]["subvolumeGroup"] = "subvolgrp2"
|
||||
|
||||
err = createCustomConfigMap(f.ClientSet, cephFSDirPath, clusterInfo)
|
||||
if err != nil {
|
||||
e2elog.Failf("failed to create configmap with error %v", err)
|
||||
}
|
||||
|
@ -76,7 +76,10 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
|
||||
}
|
||||
|
||||
// createCustomConfigMap provides multiple clusters information.
|
||||
func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpInfo map[string]string) error {
|
||||
func createCustomConfigMap(
|
||||
c kubernetes.Interface,
|
||||
pluginPath string,
|
||||
clusterInfo map[string]map[string]string) error {
|
||||
path := pluginPath + configMap
|
||||
cm := v1.ConfigMap{}
|
||||
err := unmarshal(path, &cm)
|
||||
@ -90,7 +93,7 @@ func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpI
|
||||
}
|
||||
// get clusterIDs
|
||||
var clusterID []string
|
||||
for key := range subvolgrpInfo {
|
||||
for key := range clusterInfo {
|
||||
clusterID = append(clusterID, key)
|
||||
}
|
||||
conmap := []util.ClusterInfo{
|
||||
@ -103,9 +106,27 @@ func createCustomConfigMap(c kubernetes.Interface, pluginPath string, subvolgrpI
|
||||
Monitors: mons,
|
||||
},
|
||||
}
|
||||
for i := 0; i < len(subvolgrpInfo); i++ {
|
||||
conmap[i].CephFS.SubvolumeGroup = subvolgrpInfo[clusterID[i]]
|
||||
|
||||
// fill radosNamespace and subvolgroups
|
||||
for cluster, confItems := range clusterInfo {
|
||||
for i, j := range confItems {
|
||||
switch i {
|
||||
case "subvolumeGroup":
|
||||
for c := range conmap {
|
||||
if conmap[c].ClusterID == cluster {
|
||||
conmap[c].CephFS.SubvolumeGroup = j
|
||||
}
|
||||
}
|
||||
case "radosNamespace":
|
||||
for c := range conmap {
|
||||
if conmap[c].ClusterID == cluster {
|
||||
conmap[c].RadosNamespace = j
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data, err := json.Marshal(conmap)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user