mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
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:
parent
68bd44beba
commit
30af703a2f
@ -24,6 +24,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ceph/ceph-csi/internal/cephfs"
|
"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/liveness"
|
||||||
"github.com/ceph/ceph-csi/internal/rbd"
|
"github.com/ceph/ceph-csi/internal/rbd"
|
||||||
"github.com/ceph/ceph-csi/internal/util"
|
"github.com/ceph/ceph-csi/internal/util"
|
||||||
@ -32,9 +34,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
rbdType = "rbd"
|
rbdType = "rbd"
|
||||||
cephfsType = "cephfs"
|
cephfsType = "cephfs"
|
||||||
livenessType = "liveness"
|
livenessType = "liveness"
|
||||||
|
controllerType = "controller"
|
||||||
|
|
||||||
rbdDefaultName = "rbd.csi.ceph.com"
|
rbdDefaultName = "rbd.csi.ceph.com"
|
||||||
cephfsDefaultName = "cephfs.csi.ceph.com"
|
cephfsDefaultName = "cephfs.csi.ceph.com"
|
||||||
@ -42,6 +45,9 @@ const (
|
|||||||
|
|
||||||
pollTime = 60 // seconds
|
pollTime = 60 // seconds
|
||||||
probeTimeout = 3 // seconds
|
probeTimeout = 3 // seconds
|
||||||
|
|
||||||
|
// use default namespace if namespace is not set
|
||||||
|
defaultNS = "default"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -50,9 +56,10 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// common flags
|
// 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.Endpoint, "endpoint", "unix://tmp/csi.sock", "CSI endpoint")
|
||||||
flag.StringVar(&conf.DriverName, "drivername", "", "name of the driver")
|
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.NodeID, "nodeid", "", "node id")
|
||||||
flag.StringVar(&conf.InstanceID, "instanceid", "", "Unique ID distinguishing this instance of Ceph CSI among other"+
|
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")
|
" instances, when sharing Ceph clusters across CSI instances for provisioning")
|
||||||
@ -181,11 +188,29 @@ func main() {
|
|||||||
|
|
||||||
case livenessType:
|
case livenessType:
|
||||||
liveness.Run(&conf)
|
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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initControllers will initialize all the controllers.
|
||||||
|
func initControllers() {
|
||||||
|
// Add list of controller here.
|
||||||
|
persistentvolume.Init()
|
||||||
|
}
|
||||||
|
|
||||||
func validateCloneDepthFlag(conf *util.Config) {
|
func validateCloneDepthFlag(conf *util.Config) {
|
||||||
// keeping hardlimit to 14 as max to avoid max image depth
|
// keeping hardlimit to 14 as max to avoid max image depth
|
||||||
if conf.RbdHardMaxCloneDepth == 0 || conf.RbdHardMaxCloneDepth > 14 {
|
if conf.RbdHardMaxCloneDepth == 0 || conf.RbdHardMaxCloneDepth > 14 {
|
||||||
|
@ -68,13 +68,14 @@ var (
|
|||||||
|
|
||||||
// Config holds the parameters list which can be configured.
|
// Config holds the parameters list which can be configured.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Vtype string // driver type [rbd|cephfs|liveness]
|
Vtype string // driver type [rbd|cephfs|liveness|controller]
|
||||||
Endpoint string // CSI endpoint
|
Endpoint string // CSI endpoint
|
||||||
DriverName string // name of the driver
|
DriverName string // name of the driver
|
||||||
NodeID string // node id
|
DriverNamespace string // namespace in which driver is deployed
|
||||||
InstanceID string // unique ID distinguishing this instance of Ceph CSI
|
NodeID string // node id
|
||||||
PluginPath string // location of cephcsi plugin
|
InstanceID string // unique ID distinguishing this instance of Ceph CSI
|
||||||
DomainLabels string // list of domain labels to read from the node
|
PluginPath string // location of cephcsi plugin
|
||||||
|
DomainLabels string // list of domain labels to read from the node
|
||||||
|
|
||||||
// metrics related flags
|
// metrics related flags
|
||||||
MetricsPath string // path of prometheus endpoint where metrics will be available
|
MetricsPath string // path of prometheus endpoint where metrics will be available
|
||||||
|
Loading…
Reference in New Issue
Block a user