util: add support to configure mirror daemon count

Currently we are assuming that only one
rbd mirror daemon running on the ceph cluster
but that is not true for many cases and it
can be more that one, this PR make this as a
configurable parameter.

fixes: #4312

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2024-04-18 14:02:29 +02:00
committed by mergify[bot]
parent 51d1d46dd2
commit 4c2d2caf9f
6 changed files with 116 additions and 1 deletions

View File

@ -45,6 +45,7 @@ const (
"clusterID": "<cluster-id>",
"rbd": {
"radosNamespace": "<rados-namespace>"
"mirrorDaemonCount": 1
},
"monitors": [
"<monitor-value>",
@ -105,6 +106,22 @@ func GetRadosNamespace(pathToConfig, clusterID string) (string, error) {
return cluster.RBD.RadosNamespace, nil
}
// GetRBDMirrorDaemonCount returns the number of mirror daemon count for the
// given clusterID.
func GetRBDMirrorDaemonCount(pathToConfig, clusterID string) (int, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID)
if err != nil {
return 0, err
}
// if it is empty, set the default to 1 which is most common in a cluster.
if cluster.RBD.MirrorDaemonCount == 0 {
return 1, nil
}
return cluster.RBD.MirrorDaemonCount, nil
}
// CephFSSubvolumeGroup returns the subvolumeGroup for CephFS volumes. If not set, it returns the default value "csi".
func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID)