mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
Address remenant subject reference and code style reviews
Signed-off-by: ShyamsundarR <srangana@redhat.com>
This commit is contained in:
parent
fc0cf957be
commit
ba2e5cff51
@ -58,7 +58,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
driver := rbd.NewDriver()
|
driver := rbd.NewDriver()
|
||||||
driver.Run(*driverName, *nodeID, *endpoint, *containerized, *configRoot, cp)
|
driver.Run(*driverName, *nodeID, *endpoint, *configRoot, *containerized, cp)
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ Parameter | Required | Description
|
|||||||
|
|
||||||
NOTE: If `clusterID` parameter is used, then an accompanying Ceph cluster
|
NOTE: If `clusterID` parameter is used, then an accompanying Ceph cluster
|
||||||
configuration secret or config files needs to be provided to the running pods.
|
configuration secret or config files needs to be provided to the running pods.
|
||||||
Refer to `examples/README.md` section titled "Cluster ID based configuration"
|
Refer to [Cluster ID based configuration](../examples/README.md#cluster-id-based-configuration)
|
||||||
for more information. A suggested way to populate the clusterID is to use the
|
for more information. A suggested way to populate the clusterID is to use the
|
||||||
output of `ceph fsid` of the Ceph cluster to be used for provisioning.
|
output of `ceph fsid` of the Ceph cluster to be used for provisioning.
|
||||||
|
|
||||||
|
@ -239,7 +239,9 @@ Get the following information from the Ceph cluster,
|
|||||||
* Output of `ceph fsid`
|
* Output of `ceph fsid`
|
||||||
* Used to substitute `<cluster-id>` references in the files below
|
* Used to substitute `<cluster-id>` references in the files below
|
||||||
|
|
||||||
Update the template `rbd/template-ceph-cluster-ID-secret.yaml` with values from
|
Update the template
|
||||||
|
[template-ceph-cluster-ID-secret.yaml](./rbd/template-ceph-cluster-ID-secret.yaml)
|
||||||
|
with values from
|
||||||
a Ceph cluster and replace `<cluster-id>` with the chosen clusterID to create
|
a Ceph cluster and replace `<cluster-id>` with the chosen clusterID to create
|
||||||
the following secret,
|
the following secret,
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ parameters:
|
|||||||
monitors: mon1:port,mon2:port,...
|
monitors: mon1:port,mon2:port,...
|
||||||
# OR,
|
# OR,
|
||||||
# String representing a Ceph cluster to provision storage from.
|
# String representing a Ceph cluster to provision storage from.
|
||||||
# Should be unique unique across all Ceph clusters in use for provisioning,
|
# Should be unique across all Ceph clusters in use for provisioning,
|
||||||
# cannot be greater than 36 bytes in length, and should remain immutable for
|
# cannot be greater than 36 bytes in length, and should remain immutable for
|
||||||
# the lifetime of the StorageClass in use.
|
# the lifetime of the StorageClass in use.
|
||||||
# If using clusterID, ensure to create a secret, as in
|
# If using clusterID, ensure to create a secret, as in
|
||||||
|
@ -10,7 +10,7 @@ parameters:
|
|||||||
monitors: mon1:port,mon2:port,...
|
monitors: mon1:port,mon2:port,...
|
||||||
# OR,
|
# OR,
|
||||||
# String representing a Ceph cluster to provision storage from.
|
# String representing a Ceph cluster to provision storage from.
|
||||||
# Should be unique unique across all Ceph clusters in use for provisioning,
|
# Should be unique across all Ceph clusters in use for provisioning,
|
||||||
# cannot be greater than 36 bytes in length, and should remain immutable for
|
# cannot be greater than 36 bytes in length, and should remain immutable for
|
||||||
# the lifetime of the StorageClass in use.
|
# the lifetime of the StorageClass in use.
|
||||||
# If using clusterID, ensure to create a secret, as in
|
# If using clusterID, ensure to create a secret, as in
|
||||||
|
@ -89,12 +89,12 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*NodeServer, err
|
|||||||
|
|
||||||
// Run start a non-blocking grpc controller,node and identityserver for
|
// Run start a non-blocking grpc controller,node and identityserver for
|
||||||
// rbd CSI driver which can serve multiple parallel requests
|
// rbd CSI driver which can serve multiple parallel requests
|
||||||
func (r *Driver) Run(driverName, nodeID, endpoint string, containerized bool, configroot string, cachePersister util.CachePersister) {
|
func (r *Driver) Run(driverName, nodeID, endpoint, configRoot string, containerized bool, cachePersister util.CachePersister) {
|
||||||
var err error
|
var err error
|
||||||
klog.Infof("Driver: %v version: %v", driverName, version)
|
klog.Infof("Driver: %v version: %v", driverName, version)
|
||||||
|
|
||||||
// Initialize config store
|
// Initialize config store
|
||||||
confStore, err = util.NewConfigStore(configroot)
|
confStore, err = util.NewConfigStore(configRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Fatalln("Failed to initialize config store.")
|
klog.Fatalln("Failed to initialize config store.")
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,12 @@ var (
|
|||||||
supportedFeatures = sets.NewString("layering")
|
supportedFeatures = sets.NewString("layering")
|
||||||
)
|
)
|
||||||
|
|
||||||
func getRBDKey(clusterid string, id string, credentials map[string]string) (string, error) {
|
func getRBDKey(clusterid, id string, credentials map[string]string) (string, error) {
|
||||||
var ok bool
|
var (
|
||||||
var err error
|
ok bool
|
||||||
var key string
|
err error
|
||||||
|
key string
|
||||||
|
)
|
||||||
|
|
||||||
if key, ok = credentials[id]; !ok {
|
if key, ok = credentials[id]; !ok {
|
||||||
if clusterid != "" {
|
if clusterid != "" {
|
||||||
@ -272,8 +274,8 @@ func getIDs(options map[string]string, clusterID string) (adminID, userID string
|
|||||||
case ok:
|
case ok:
|
||||||
case clusterID != "":
|
case clusterID != "":
|
||||||
if adminID, err = confStore.AdminID(clusterID); err != nil {
|
if adminID, err = confStore.AdminID(clusterID); err != nil {
|
||||||
klog.Errorf("failed getting subject (%s)", err)
|
klog.Errorf("failed getting adminID (%s)", err)
|
||||||
return "", "", fmt.Errorf("failed to fetch admin ID for clusterID (%s)", clusterID)
|
return "", "", fmt.Errorf("failed to fetch adminID for clusterID (%s)", clusterID)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
adminID = rbdDefaultAdminID
|
adminID = rbdDefaultAdminID
|
||||||
@ -284,8 +286,8 @@ func getIDs(options map[string]string, clusterID string) (adminID, userID string
|
|||||||
case ok:
|
case ok:
|
||||||
case clusterID != "":
|
case clusterID != "":
|
||||||
if userID, err = confStore.UserID(clusterID); err != nil {
|
if userID, err = confStore.UserID(clusterID); err != nil {
|
||||||
klog.Errorf("failed getting subject (%s)", err)
|
klog.Errorf("failed getting userID (%s)", err)
|
||||||
return "", "", fmt.Errorf("failed to fetch user ID using clusterID (%s)", clusterID)
|
return "", "", fmt.Errorf("failed to fetch userID using clusterID (%s)", clusterID)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
userID = rbdDefaultUserID
|
userID = rbdDefaultUserID
|
||||||
@ -295,8 +297,10 @@ func getIDs(options map[string]string, clusterID string) (adminID, userID string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getRBDVolumeOptions(volOptions map[string]string, disableInUseChecks bool) (*rbdVolume, error) {
|
func getRBDVolumeOptions(volOptions map[string]string, disableInUseChecks bool) (*rbdVolume, error) {
|
||||||
var ok bool
|
var (
|
||||||
var err error
|
ok bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
rbdVol := &rbdVolume{}
|
rbdVol := &rbdVolume{}
|
||||||
rbdVol.Pool, ok = volOptions["pool"]
|
rbdVol.Pool, ok = volOptions["pool"]
|
||||||
@ -342,8 +346,10 @@ func getRBDVolumeOptions(volOptions map[string]string, disableInUseChecks bool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCredsFromVol(rbdVol *rbdVolume, volOptions map[string]string) error {
|
func getCredsFromVol(rbdVol *rbdVolume, volOptions map[string]string) error {
|
||||||
var ok bool
|
var (
|
||||||
var err error
|
ok bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
rbdVol.AdminID, rbdVol.UserID, err = getIDs(volOptions, rbdVol.ClusterID)
|
rbdVol.AdminID, rbdVol.UserID, err = getIDs(volOptions, rbdVol.ClusterID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -355,12 +361,14 @@ func getCredsFromVol(rbdVol *rbdVolume, volOptions map[string]string) error {
|
|||||||
rbdVol.Mounter = rbdDefaultMounter
|
rbdVol.Mounter = rbdDefaultMounter
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRBDSnapshotOptions(snapOptions map[string]string) (*rbdSnapshot, error) {
|
func getRBDSnapshotOptions(snapOptions map[string]string) (*rbdSnapshot, error) {
|
||||||
var ok bool
|
var (
|
||||||
var err error
|
ok bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
rbdSnap := &rbdSnapshot{}
|
rbdSnap := &rbdSnapshot{}
|
||||||
rbdSnap.Pool, ok = snapOptions["pool"]
|
rbdSnap.Pool, ok = snapOptions["pool"]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 The Ceph-CSI Authors.
|
Copyright 2019 The Ceph-CSI Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -34,7 +34,7 @@ type StoreReader interface {
|
|||||||
- csMonitors: MON list, comma separated
|
- csMonitors: MON list, comma separated
|
||||||
- csAdminID: adminID, used for provisioning
|
- csAdminID: adminID, used for provisioning
|
||||||
- csUserID: userID, used for publishing
|
- csUserID: userID, used for publishing
|
||||||
- csAdminKey: key, for userID in csProvisionerUser
|
- csAdminKey: key, for adminID in csProvisionerUser
|
||||||
- csUserKey: key, for userID in csPublisherUser
|
- csUserKey: key, for userID in csPublisherUser
|
||||||
- csPools: Pool list, comma separated
|
- csPools: Pool list, comma separated
|
||||||
*/
|
*/
|
||||||
@ -55,13 +55,12 @@ type ConfigStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dataForKey returns data from the config store for the provided key
|
// dataForKey returns data from the config store for the provided key
|
||||||
func (dc *ConfigStore) dataForKey(clusterID string, key string) (string, error) {
|
func (dc *ConfigStore) dataForKey(clusterID, key string) (string, error) {
|
||||||
if dc.StoreReader != nil {
|
if dc.StoreReader != nil {
|
||||||
return dc.StoreReader.DataForKey(clusterID, key)
|
return dc.StoreReader.DataForKey(clusterID, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := errors.New("config store location uninitialized")
|
return "", errors.New("config store location uninitialized")
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mons returns a comma separated MON list from the cluster config represented by clusterID
|
// Mons returns a comma separated MON list from the cluster config represented by clusterID
|
||||||
|
@ -43,7 +43,7 @@ type FileConfig struct {
|
|||||||
|
|
||||||
// DataForKey reads the appropriate config file, named using key, and returns
|
// DataForKey reads the appropriate config file, named using key, and returns
|
||||||
// the contents of the file to the caller
|
// the contents of the file to the caller
|
||||||
func (fc *FileConfig) DataForKey(clusterid string, key string) (data string, err error) {
|
func (fc *FileConfig) DataForKey(clusterid, key string) (data string, err error) {
|
||||||
pathToKey := path.Join(fc.BasePath, "ceph-cluster-"+clusterid, key)
|
pathToKey := path.Join(fc.BasePath, "ceph-cluster-"+clusterid, key)
|
||||||
// #nosec
|
// #nosec
|
||||||
content, err := ioutil.ReadFile(pathToKey)
|
content, err := ioutil.ReadFile(pathToKey)
|
||||||
|
@ -40,7 +40,7 @@ type K8sConfig struct {
|
|||||||
|
|
||||||
// DataForKey reads the appropriate k8s secret, named using clusterid, and
|
// DataForKey reads the appropriate k8s secret, named using clusterid, and
|
||||||
// returns the contents of key within the secret
|
// returns the contents of key within the secret
|
||||||
func (kc *K8sConfig) DataForKey(clusterid string, key string) (data string, err error) {
|
func (kc *K8sConfig) DataForKey(clusterid, key string) (data string, err error) {
|
||||||
secret, err := kc.Client.CoreV1().Secrets(kc.Namespace).Get("ceph-cluster-"+clusterid, metav1.GetOptions{})
|
secret, err := kc.Client.CoreV1().Secrets(kc.Namespace).Get("ceph-cluster-"+clusterid, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("error fetching configuration for cluster ID (%s). (%s)", clusterid, err)
|
err = fmt.Errorf("error fetching configuration for cluster ID (%s). (%s)", clusterid, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user