Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/storagecluster/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ func updateMetricsExporterClusterRoles(ctx context.Context, r *StorageClusterRec
APIGroups: []string{""},
Resources: []string{"configmaps"},
Verbs: []string{"get"},
ResourceNames: []string{"rook-ceph-csi-config"},
ResourceNames: []string{"ceph-csi-config"},
},
{
APIGroups: []string{""},
Expand Down
26 changes: 7 additions & 19 deletions metrics/internal/cache/rbd-mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ type RBDMirrorPeerSite struct {
}

type csiClusterConfig struct {
ClusterID string `json:"clusterID"`
Monitors []string `json:"monitors"`
Namespace string `json:"namespace"`
Monitors []string `json:"monitors"`
}

// Cache mirror data for all CephBlockPools with mirroring enabled
Expand Down Expand Up @@ -165,42 +163,32 @@ func initCeph(kubeclient clientset.Interface, cephClusterNamespace, cephAuthName
return cephMonitorConfig{}, fmt.Errorf("failed to get ceph user key in namespace %q", namespace)
}

configmap, err := kubeclient.CoreV1().ConfigMaps(cephAuthNamespace).Get(context.TODO(), "rook-ceph-csi-config", metav1.GetOptions{})
configmap, err := kubeclient.CoreV1().ConfigMaps(cephAuthNamespace).Get(context.TODO(), "ceph-csi-config", metav1.GetOptions{})
if err != nil {
return cephMonitorConfig{}, fmt.Errorf("failed to get configmap in namespace %q: %v", namespace, err)
}

data, ok := configmap.Data["csi-cluster-config-json"]
data, ok := configmap.Data["config.json"]
if !ok {
return cephMonitorConfig{}, fmt.Errorf("failed to get CSI cluster config from configmap in namespace %q", namespace)
}

var clusterConfigs []csiClusterConfig
err = json.Unmarshal([]byte(data), &clusterConfigs)
if err != nil {
return cephMonitorConfig{}, fmt.Errorf("failed to unmarshal csi-cluster-config-json in namespace %q: %v", namespace, err)
return cephMonitorConfig{}, fmt.Errorf("failed to unmarshal config.json in namespace %q: %v", namespace, err)
}

if len(clusterConfigs) == 0 {
return cephMonitorConfig{}, fmt.Errorf("expected 1 or more CSI cluster config but found 0 from configmap in namespace %q", namespace)
}

var clusterConfig csiClusterConfig
for idx := range clusterConfigs {
if clusterConfigs[idx].Namespace == cephClusterNamespace {
clusterConfig = clusterConfigs[idx]
break
}
}

if len(clusterConfig.Monitors) == 0 {
if len(clusterConfigs[0].Monitors) == 0 {
return cephMonitorConfig{}, fmt.Errorf("expected 1 or more monitors but found 0 from configmap in namespace %q", namespace)
}

input := cephMonitorConfig{}
input.clusterID = clusterConfig.ClusterID
input.cephClusterNamespace = clusterConfig.Namespace
input.monitor = clusterConfig.Monitors[0]
input.monitor = clusterConfigs[0].Monitors[0]
input.id = string(id)
input.key = string(key)

Expand Down Expand Up @@ -343,7 +331,7 @@ func CreateCephBlockPoolListWatch(cephClient rookclient.Interface, namespace, fi
/* RBD CLI Commands */

type cephMonitorConfig struct {
clusterID, cephClusterNamespace, monitor, id, key string
monitor, id, key string
}

func rbdImageStatus(config *cephMonitorConfig, poolName string) (RBDMirrorStatusVerbose, error) {
Expand Down
Loading