mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
util: add GetCephFSRadosNamespace method
This commit adds `GetCephFSRadosNamespace` util method that returns the `RadosNamespace` specified in ceph-csi-config ConfigMap under cephFS.radosNamespace. If not specified, the method returns the default RadosNamespace i.e, csi. Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
parent
178b642b01
commit
c7f41cf84b
@ -32,6 +32,11 @@ kind: ConfigMap
|
|||||||
# The "cephFS.fuseMountOptions" fields are common separated mount options
|
# The "cephFS.fuseMountOptions" fields are common separated mount options
|
||||||
# for `Ceph FUSE driver`. Setting this will override the fusemountoptions
|
# for `Ceph FUSE driver`. Setting this will override the fusemountoptions
|
||||||
# command line flag.
|
# command line flag.
|
||||||
|
# The "cephFS.radosNamespace" is optional and represents a radosNamespace in the
|
||||||
|
# metadata pool. If any given, the omap data of cephFS will be stored within
|
||||||
|
# this radosNamespace.
|
||||||
|
# NOTE: Make sure you don't add radosNamespace option to a currently in use
|
||||||
|
# configuration as it will cause issues.
|
||||||
# network namespace specified by the "cephFS.netNamespaceFilePath".
|
# network namespace specified by the "cephFS.netNamespaceFilePath".
|
||||||
# The "nfs.netNamespaceFilePath" fields are the various network namespace
|
# The "nfs.netNamespaceFilePath" fields are the various network namespace
|
||||||
# path for the Ceph cluster identified by the <cluster-id>, This will be used
|
# path for the Ceph cluster identified by the <cluster-id>, This will be used
|
||||||
@ -78,7 +83,8 @@ data:
|
|||||||
"subvolumeGroup": "<subvolumegroup for cephFS volumes>"
|
"subvolumeGroup": "<subvolumegroup for cephFS volumes>"
|
||||||
"netNamespaceFilePath": "<kubeletRootPath>/plugins/cephfs.csi.ceph.com/net",
|
"netNamespaceFilePath": "<kubeletRootPath>/plugins/cephfs.csi.ceph.com/net",
|
||||||
"kernelMountOptions": "<kernelMountOptions for cephFS volumes>",
|
"kernelMountOptions": "<kernelMountOptions for cephFS volumes>",
|
||||||
"fuseMountOptions": "<fuseMountOptions for cephFS volumes>"
|
"fuseMountOptions": "<fuseMountOptions for cephFS volumes>",
|
||||||
|
"radosNamespace": "<rados-namespace>"
|
||||||
}
|
}
|
||||||
"nfs": {
|
"nfs": {
|
||||||
"netNamespaceFilePath": "<kubeletRootPath>/plugins/nfs.csi.ceph.com/net",
|
"netNamespaceFilePath": "<kubeletRootPath>/plugins/nfs.csi.ceph.com/net",
|
||||||
|
@ -74,7 +74,7 @@ func (cvg *commonVolumeGroup) initCommonVolumeGroup(
|
|||||||
return fmt.Errorf("failed to get MONs for cluster id %q: %w", csiID.ClusterID, err)
|
return fmt.Errorf("failed to get MONs for cluster id %q: %w", csiID.ClusterID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, err := util.GetRadosNamespace(util.CsiConfigFile, csiID.ClusterID)
|
namespace, err := util.GetRBDRadosNamespace(util.CsiConfigFile, csiID.ClusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get RADOS namespace for cluster id %q: %w", csiID.ClusterID, err)
|
return fmt.Errorf("failed to get RADOS namespace for cluster id %q: %w", csiID.ClusterID, err)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ func (mgr *rbdManager) getVolumeGroupJournal(clusterID string) (journal.VolumeGr
|
|||||||
return nil, fmt.Errorf("failed to find MONs for cluster %q: %w", clusterID, err)
|
return nil, fmt.Errorf("failed to find MONs for cluster %q: %w", clusterID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ns, err := util.GetRadosNamespace(util.CsiConfigFile, clusterID)
|
ns, err := util.GetRBDRadosNamespace(util.CsiConfigFile, clusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to find the RADOS namespace for cluster %q: %w", clusterID, err)
|
return nil, fmt.Errorf("failed to find the RADOS namespace for cluster %q: %w", clusterID, err)
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ func genSnapFromSnapID(
|
|||||||
}
|
}
|
||||||
rbdSnap.JournalPool = rbdSnap.Pool
|
rbdSnap.JournalPool = rbdSnap.Pool
|
||||||
|
|
||||||
rbdSnap.RadosNamespace, err = util.GetRadosNamespace(util.CsiConfigFile, rbdSnap.ClusterID)
|
rbdSnap.RadosNamespace, err = util.GetRBDRadosNamespace(util.CsiConfigFile, rbdSnap.ClusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1134,7 +1134,7 @@ func generateVolumeFromVolumeID(
|
|||||||
return rbdVol, err
|
return rbdVol, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rbdVol.RadosNamespace, err = util.GetRadosNamespace(util.CsiConfigFile, rbdVol.ClusterID)
|
rbdVol.RadosNamespace, err = util.GetRBDRadosNamespace(util.CsiConfigFile, rbdVol.ClusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return rbdVol, err
|
return rbdVol, err
|
||||||
}
|
}
|
||||||
@ -1357,7 +1357,7 @@ func genVolFromVolumeOptions(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rbdVol.RadosNamespace, err = util.GetRadosNamespace(util.CsiConfigFile, rbdVol.ClusterID)
|
rbdVol.RadosNamespace, err = util.GetRBDRadosNamespace(util.CsiConfigFile, rbdVol.ClusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@ const (
|
|||||||
// 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"
|
||||||
|
|
||||||
|
// defaultCsiCephFSRadosNamespace defines the default RADOS namespace used for storing
|
||||||
|
// CSI-specific objects and keys for CephFS volumes.
|
||||||
|
defaultCsiCephFSRadosNamespace = "csi"
|
||||||
|
|
||||||
// CsiConfigFile is the location of the CSI config file.
|
// CsiConfigFile is the location of the CSI config file.
|
||||||
CsiConfigFile = "/etc/ceph-csi-config/config.json"
|
CsiConfigFile = "/etc/ceph-csi-config/config.json"
|
||||||
|
|
||||||
@ -96,8 +100,8 @@ func Mons(pathToConfig, clusterID string) (string, error) {
|
|||||||
return strings.Join(cluster.Monitors, ","), nil
|
return strings.Join(cluster.Monitors, ","), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRadosNamespace returns the namespace for the given clusterID.
|
// GetRBDRadosNamespace returns the namespace for the given clusterID.
|
||||||
func GetRadosNamespace(pathToConfig, clusterID string) (string, error) {
|
func GetRBDRadosNamespace(pathToConfig, clusterID string) (string, error) {
|
||||||
cluster, err := readClusterInfo(pathToConfig, clusterID)
|
cluster, err := readClusterInfo(pathToConfig, clusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -106,6 +110,21 @@ func GetRadosNamespace(pathToConfig, clusterID string) (string, error) {
|
|||||||
return cluster.RBD.RadosNamespace, nil
|
return cluster.RBD.RadosNamespace, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCephFSRadosNamespace returns the namespace for the given clusterID.
|
||||||
|
// If not set, it returns the default value "csi".
|
||||||
|
func GetCephFSRadosNamespace(pathToConfig, clusterID string) (string, error) {
|
||||||
|
cluster, err := readClusterInfo(pathToConfig, clusterID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if cluster.CephFS.RadosNamespace == "" {
|
||||||
|
return defaultCsiCephFSRadosNamespace, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return cluster.CephFS.RadosNamespace, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetRBDMirrorDaemonCount returns the number of mirror daemon count for the
|
// GetRBDMirrorDaemonCount returns the number of mirror daemon count for the
|
||||||
// given clusterID.
|
// given clusterID.
|
||||||
func GetRBDMirrorDaemonCount(pathToConfig, clusterID string) (int, error) {
|
func GetRBDMirrorDaemonCount(pathToConfig, clusterID string) (int, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user