diff options
| author | Viktor Kuzmin <kvaster@gmail.com> | 2023-08-07 11:23:40 +0300 |
|---|---|---|
| committer | Chris Lu <chrislusf@users.noreply.github.com> | 2023-08-07 10:22:05 -0700 |
| commit | a5a2c638d1622ac194d108fdb9b2aa6a1e56bdbd (patch) | |
| tree | e2d4d5aff1bf028452ed90c5d4c660d29ff946b7 /pkg/driver/driver.go | |
| parent | 44d2cf555cf470e9fe689976b8f55f6be2730ab5 (diff) | |
| download | seaweedfs-csi-driver-a5a2c638d1622ac194d108fdb9b2aa6a1e56bdbd.tar.xz seaweedfs-csi-driver-a5a2c638d1622ac194d108fdb9b2aa6a1e56bdbd.zip | |
Allow to separate ControllerServer and NodeServer, allow to disable attacher (it do nothing in reality)
Diffstat (limited to 'pkg/driver/driver.go')
| -rw-r--r-- | pkg/driver/driver.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 23dbae3..0d3af5a 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -49,9 +49,12 @@ type SeaweedFsDriver struct { signature int32 DataCenter string DataLocality datalocality.DataLocality + + RunNode bool + RunController bool } -func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver { +func NewSeaweedFsDriver(filer, nodeID, endpoint string, enableAttacher bool) *SeaweedFsDriver { glog.Infof("Driver: %v version: %v", driverName, version) @@ -75,11 +78,17 @@ func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver { }) n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, - csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, csi.ControllerServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER, csi.ControllerServiceCapability_RPC_EXPAND_VOLUME, }) + // we need this just only for csi-attach, but we do nothing for attach/detach + if enableAttacher { + n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ + csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, + }) + } + return n } @@ -95,15 +104,21 @@ func (n *SeaweedFsDriver) initClient() error { func (n *SeaweedFsDriver) Run() { glog.Info("starting") - controller := NewControllerServer(n) - node := NewNodeServer(n) + var controller *ControllerServer + if n.RunController { + controller = NewControllerServer(n) + } + + var node *NodeServer + if n.RunNode { + node = NewNodeServer(n) + } s := NewNonBlockingGRPCServer() s.Start(n.endpoint, NewIdentityServer(n), controller, node) - s.Wait() stopChan := make(chan os.Signal) signal.Notify(stopChan, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP) @@ -114,8 +129,10 @@ func (n *SeaweedFsDriver) Run() { s.Stop() s.Wait() - glog.Infof("node cleanup") - node.NodeCleanup() + if node != nil { + glog.Infof("node cleanup") + node.NodeCleanup() + } glog.Infof("stopped") } |
