rbd: add controller to main

initialize and start the rbd controller when
we the driver type is controller.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-11-17 13:08:54 +05:30 committed by mergify[bot]
parent 68bd44beba
commit 30af703a2f
2 changed files with 37 additions and 11 deletions

View File

@ -24,6 +24,8 @@ import (
"time"
"github.com/ceph/ceph-csi/internal/cephfs"
"github.com/ceph/ceph-csi/internal/controller"
"github.com/ceph/ceph-csi/internal/controller/persistentvolume"
"github.com/ceph/ceph-csi/internal/liveness"
"github.com/ceph/ceph-csi/internal/rbd"
"github.com/ceph/ceph-csi/internal/util"
@ -32,9 +34,10 @@ import (
)
const (
rbdType = "rbd"
cephfsType = "cephfs"
livenessType = "liveness"
rbdType = "rbd"
cephfsType = "cephfs"
livenessType = "liveness"
controllerType = "controller"
rbdDefaultName = "rbd.csi.ceph.com"
cephfsDefaultName = "cephfs.csi.ceph.com"
@ -42,6 +45,9 @@ const (
pollTime = 60 // seconds
probeTimeout = 3 // seconds
// use default namespace if namespace is not set
defaultNS = "default"
)
var (
@ -50,9 +56,10 @@ var (
func init() {
// common flags
flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|liveness]")
flag.StringVar(&conf.Vtype, "type", "", "driver type [rbd|cephfs|liveness|controller]")
flag.StringVar(&conf.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
flag.StringVar(&conf.DriverName, "drivername", "", "name of the driver")
flag.StringVar(&conf.DriverNamespace, "drivernamespace", defaultNS, "namespace in which driver is deployed")
flag.StringVar(&conf.NodeID, "nodeid", "", "node id")
flag.StringVar(&conf.InstanceID, "instanceid", "", "Unique ID distinguishing this instance of Ceph CSI among other"+
" instances, when sharing Ceph clusters across CSI instances for provisioning")
@ -181,11 +188,29 @@ func main() {
case livenessType:
liveness.Run(&conf)
case controllerType:
cfg := controller.Config{
DriverName: dname,
Namespace: conf.DriverNamespace,
}
// initialize all controllers before starting.
initControllers()
err = controller.Start(cfg)
if err != nil {
logAndExit(err.Error())
}
}
os.Exit(0)
}
// initControllers will initialize all the controllers.
func initControllers() {
// Add list of controller here.
persistentvolume.Init()
}
func validateCloneDepthFlag(conf *util.Config) {
// keeping hardlimit to 14 as max to avoid max image depth
if conf.RbdHardMaxCloneDepth == 0 || conf.RbdHardMaxCloneDepth > 14 {

View File

@ -68,13 +68,14 @@ var (
// Config holds the parameters list which can be configured.
type Config struct {
Vtype string // driver type [rbd|cephfs|liveness]
Endpoint string // CSI endpoint
DriverName string // name of the driver
NodeID string // node id
InstanceID string // unique ID distinguishing this instance of Ceph CSI
PluginPath string // location of cephcsi plugin
DomainLabels string // list of domain labels to read from the node
Vtype string // driver type [rbd|cephfs|liveness|controller]
Endpoint string // CSI endpoint
DriverName string // name of the driver
DriverNamespace string // namespace in which driver is deployed
NodeID string // node id
InstanceID string // unique ID distinguishing this instance of Ceph CSI
PluginPath string // location of cephcsi plugin
DomainLabels string // list of domain labels to read from the node
// metrics related flags
MetricsPath string // path of prometheus endpoint where metrics will be available