mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rbd: check for clusterid mapping in genVolFromVolumeOptions()
This commit adds capability to genVolFromVolumeOptions() to fetch mapped clusted-id & mon ips for mirrored PVC on secondary cluster which may have different cluster-id. This is required for NodeStageVolume(). We also don't need to check for mapping during volume create requests, so it can be disabled by passing a bool checkClusterIDMapping as false. GetMonsAndClusterID() is modified to accept bool checkClusterIDMapping based on which clustermapping is checked to fetch mapped cluster-id and mon-ips. Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -131,11 +132,19 @@ func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) {
|
||||
|
||||
// GetMonsAndClusterID returns monitors and clusterID information read from
|
||||
// configfile.
|
||||
func GetMonsAndClusterID(options map[string]string) (string, string, error) {
|
||||
func GetMonsAndClusterID(ctx context.Context, options map[string]string, checkClusterIDMapping bool) (string, string, error) {
|
||||
clusterID, ok := options["clusterID"]
|
||||
if !ok {
|
||||
return "", "", errors.New("clusterID must be set")
|
||||
}
|
||||
if checkClusterIDMapping {
|
||||
monitors, mappedClusterID, err := FetchMappedClusterIDAndMons(ctx, clusterID)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return monitors, mappedClusterID, nil
|
||||
}
|
||||
|
||||
monitors, err := Mons(CsiConfigFile, clusterID)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user