mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
util: modify GetMonsAndClusterID() to take clusterID instead of options
This commit:
- modifies GetMonsAndClusterID() to take clusterID instead of options.
- moves out validation of clusterID is set or not out of GetMonsAndClusterID().
- defines ErrClusterIDNotSet new error for reusability.
- add GetClusterID() to obtain clusterID from options.
Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit 82d09d81cf
)
This commit is contained in:
@ -844,11 +844,7 @@ func genSnapFromSnapID(
|
||||
snapshotID string,
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) error {
|
||||
var (
|
||||
options map[string]string
|
||||
vi util.CSIIdentifier
|
||||
)
|
||||
options = make(map[string]string)
|
||||
var vi util.CSIIdentifier
|
||||
|
||||
rbdSnap.VolID = snapshotID
|
||||
|
||||
@ -860,9 +856,8 @@ func genSnapFromSnapID(
|
||||
}
|
||||
|
||||
rbdSnap.ClusterID = vi.ClusterID
|
||||
options["clusterID"] = rbdSnap.ClusterID
|
||||
|
||||
rbdSnap.Monitors, _, err = util.GetMonsAndClusterID(ctx, options, false)
|
||||
rbdSnap.Monitors, _, err = util.GetMonsAndClusterID(ctx, rbdSnap.ClusterID, false)
|
||||
if err != nil {
|
||||
util.ErrorLog(ctx, "failed getting mons (%s)", err)
|
||||
|
||||
@ -936,11 +931,9 @@ func generateVolumeFromVolumeID(
|
||||
cr *util.Credentials,
|
||||
secrets map[string]string) (*rbdVolume, error) {
|
||||
var (
|
||||
options map[string]string
|
||||
rbdVol *rbdVolume
|
||||
err error
|
||||
rbdVol *rbdVolume
|
||||
err error
|
||||
)
|
||||
options = make(map[string]string)
|
||||
|
||||
// rbdVolume fields that are not filled up in this function are:
|
||||
// Mounter, MultiNodeWritable
|
||||
@ -948,9 +941,8 @@ func generateVolumeFromVolumeID(
|
||||
rbdVol.VolID = volumeID
|
||||
|
||||
rbdVol.ClusterID = vi.ClusterID
|
||||
options["clusterID"] = rbdVol.ClusterID
|
||||
|
||||
rbdVol.Monitors, _, err = util.GetMonsAndClusterID(ctx, options, false)
|
||||
rbdVol.Monitors, _, err = util.GetMonsAndClusterID(ctx, rbdVol.ClusterID, false)
|
||||
if err != nil {
|
||||
util.ErrorLog(ctx, "failed getting mons (%s)", err)
|
||||
|
||||
@ -1166,7 +1158,11 @@ func genVolFromVolumeOptions(
|
||||
rbdVol.NamePrefix = namePrefix
|
||||
}
|
||||
|
||||
rbdVol.Monitors, rbdVol.ClusterID, err = util.GetMonsAndClusterID(ctx, volOptions, checkClusterIDMapping)
|
||||
clusterID, err := util.GetClusterID(volOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rbdVol.Monitors, rbdVol.ClusterID, err = util.GetMonsAndClusterID(ctx, clusterID, checkClusterIDMapping)
|
||||
if err != nil {
|
||||
util.ErrorLog(ctx, "failed getting mons (%s)", err)
|
||||
|
||||
@ -1243,7 +1239,11 @@ func genSnapFromOptions(ctx context.Context, rbdVol *rbdVolume, snapOptions map[
|
||||
rbdSnap.JournalPool = rbdVol.JournalPool
|
||||
rbdSnap.RadosNamespace = rbdVol.RadosNamespace
|
||||
|
||||
rbdSnap.Monitors, rbdSnap.ClusterID, err = util.GetMonsAndClusterID(ctx, snapOptions, false)
|
||||
clusterID, err := util.GetClusterID(snapOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rbdSnap.Monitors, rbdSnap.ClusterID, err = util.GetMonsAndClusterID(ctx, clusterID, false)
|
||||
if err != nil {
|
||||
util.ErrorLog(ctx, "failed getting mons (%s)", err)
|
||||
|
||||
|
Reference in New Issue
Block a user