util: move csiconfigfile to util

as we have csiconfigfile in both cephfs
and rbd moving the configfile path to
util folder.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-08-10 11:49:38 +05:30 committed by mergify[bot]
parent 35c5afcd3e
commit 18f4e9d519
6 changed files with 11 additions and 14 deletions

View File

@ -30,9 +30,6 @@ const (
// volIDVersion is the version number of volume ID encoding scheme // volIDVersion is the version number of volume ID encoding scheme
volIDVersion uint16 = 1 volIDVersion uint16 = 1
// csiConfigFile is the location of the CSI config file
csiConfigFile = "/etc/ceph-csi-config/config.json"
// RADOS namespace to store CSI specific objects and keys // RADOS namespace to store CSI specific objects and keys
radosNamespace = "csi" radosNamespace = "csi"
) )

View File

@ -153,7 +153,7 @@ func getMonsAndClusterID(ctx context.Context, options map[string]string) (monito
return return
} }
if monitors, err = util.Mons(csiConfigFile, clusterID); err != nil { if monitors, err = util.Mons(util.CsiConfigFile, clusterID); err != nil {
klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err) klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err)
err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err) err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err)
return return

View File

@ -122,13 +122,13 @@ func getClusterInformation(options map[string]string) (*util.ClusterInfo, error)
return nil, err return nil, err
} }
monitors, err := util.Mons(csiConfigFile, clusterID) monitors, err := util.Mons(util.CsiConfigFile, clusterID)
if err != nil { if err != nil {
err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err) err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err)
return nil, err return nil, err
} }
subvolumeGroup, err := util.CephFSSubvolumeGroup(csiConfigFile, clusterID) subvolumeGroup, err := util.CephFSSubvolumeGroup(util.CsiConfigFile, clusterID)
if err != nil { if err != nil {
err = fmt.Errorf("failed to fetch subvolumegroup using clusterID (%s): %w", clusterID, err) err = fmt.Errorf("failed to fetch subvolumegroup using clusterID (%s): %w", clusterID, err)
return nil, err return nil, err
@ -237,11 +237,11 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
vid.VolumeID = volID vid.VolumeID = volID
volOptions.FscID = vi.LocationID volOptions.FscID = vi.LocationID
if volOptions.Monitors, err = util.Mons(csiConfigFile, vi.ClusterID); err != nil { if volOptions.Monitors, err = util.Mons(util.CsiConfigFile, vi.ClusterID); err != nil {
return nil, nil, fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", vi.ClusterID, err) return nil, nil, fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", vi.ClusterID, err)
} }
if volOptions.SubvolumeGroup, err = util.CephFSSubvolumeGroup(csiConfigFile, vi.ClusterID); err != nil { if volOptions.SubvolumeGroup, err = util.CephFSSubvolumeGroup(util.CsiConfigFile, vi.ClusterID); err != nil {
return nil, nil, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err) return nil, nil, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err)
} }
@ -430,11 +430,11 @@ func newSnapshotOptionsFromID(ctx context.Context, snapID string, cr *util.Crede
sid.SnapshotID = snapID sid.SnapshotID = snapID
volOptions.FscID = vi.LocationID volOptions.FscID = vi.LocationID
if volOptions.Monitors, err = util.Mons(csiConfigFile, vi.ClusterID); err != nil { if volOptions.Monitors, err = util.Mons(util.CsiConfigFile, vi.ClusterID); err != nil {
return &volOptions, nil, &sid, fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", vi.ClusterID, err) return &volOptions, nil, &sid, fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", vi.ClusterID, err)
} }
if volOptions.SubvolumeGroup, err = util.CephFSSubvolumeGroup(csiConfigFile, vi.ClusterID); err != nil { if volOptions.SubvolumeGroup, err = util.CephFSSubvolumeGroup(util.CsiConfigFile, vi.ClusterID); err != nil {
return &volOptions, nil, &sid, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err) return &volOptions, nil, &sid, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err)
} }

View File

@ -29,9 +29,6 @@ import (
const ( const (
// volIDVersion is the version number of volume ID encoding scheme // volIDVersion is the version number of volume ID encoding scheme
volIDVersion uint16 = 1 volIDVersion uint16 = 1
// csiConfigFile is the location of the CSI config file
csiConfigFile = "/etc/ceph-csi-config/config.json"
) )
// Driver contains the default identity,node and controller struct. // Driver contains the default identity,node and controller struct.

View File

@ -671,7 +671,7 @@ func getMonsAndClusterID(ctx context.Context, options map[string]string) (monito
return return
} }
if monitors, err = util.Mons(csiConfigFile, clusterID); err != nil { if monitors, err = util.Mons(util.CsiConfigFile, clusterID); err != nil {
klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err) klog.Errorf(util.Log(ctx, "failed getting mons (%s)"), err)
err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err) err = fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", clusterID, err)
return return

View File

@ -27,6 +27,9 @@ const (
// defaultCsiSubvolumeGroup defines the default name for the CephFS CSI subvolumegroup. // defaultCsiSubvolumeGroup defines the default name for the CephFS CSI subvolumegroup.
// This was hardcoded once and defaults to the old value to keep backward compatibility. // This was hardcoded once and defaults to the old value to keep backward compatibility.
defaultCsiSubvolumeGroup = "csi" defaultCsiSubvolumeGroup = "csi"
// CsiConfigFile is the location of the CSI config file
CsiConfigFile = "/etc/ceph-csi-config/config.json"
) )
// ClusterInfo strongly typed JSON spec for the below JSON structure. // ClusterInfo strongly typed JSON spec for the below JSON structure.