Skip to content

Commit

Permalink
Refactor options to be backward compatible, fixes #133
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaster committed Aug 8, 2023
1 parent f294627 commit 21e23d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
30 changes: 25 additions & 5 deletions cmd/seaweedfs-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"strings"

"github.com/seaweedfs/seaweedfs-csi-driver/pkg/datalocality"
"github.com/seaweedfs/seaweedfs-csi-driver/pkg/driver"
Expand All @@ -12,9 +13,8 @@ import (
)

var (
runNode = flag.Bool("node", false, "run node server")
runController = flag.Bool("controller", false, "run controller server")
enableAttacher = flag.Bool("attacher", false, "enable attacher")
components = flag.String("components", "controller,node", "components to run, by default both controller and node")
enableAttacher = flag.Bool("attacher", true, "enable attacher, by default enabled for backward compatibility")

filer = flag.String("filer", "localhost:8888", "filer server")
endpoint = flag.String("endpoint", "unix://tmp/seaweedfs-csi.sock", "CSI endpoint to accept gRPC calls")
Expand Down Expand Up @@ -55,12 +55,32 @@ func main() {
os.Exit(1)
}

runNode := false
runController := false
for _, c := range strings.Split(*components, ",") {
switch c {
case "controller":
runController = true
case "noe":
runNode = true
default:
glog.Errorf("invalid component %s", c)
os.Exit(1)
}
}

glog.Infof("will run node: %v, controller: %v, attacher: %v", runNode, runController, *enableAttacher)
if !runNode && !runController {
glog.Errorf("at least one component should be enabled: either controller or node (use --components=...)")
os.Exit(1)
}

glog.Infof("connect to filer %s", *filer)

drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint, *enableAttacher)

drv.RunNode = *runNode
drv.RunController = *runController
drv.RunNode = runNode
drv.RunController = runController

drv.ConcurrentWriters = *concurrentWriters
drv.CacheCapacityMB = *cacheCapacityMB
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/seaweedfs-csi-driver/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
{{- if .Values.node.injectTopologyInfoFromNodeLabel.enabled }}
- --dataCenter=$(DATACENTER)
{{- end }}
- --node
- --components=node
env:
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
Expand Down
6 changes: 2 additions & 4 deletions deploy/helm/seaweedfs-csi-driver/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ spec:
- --endpoint=$(CSI_ENDPOINT)
- --filer=$(SEAWEEDFS_FILER)
- --nodeid=$(NODE_ID)"
- --controller
{{- if .Values.csiAttacher.enabled }}
- --attacher
{{- end }}
- --components=controller
- --attacher={{ .Values.csiAttacher.enabled }}
env:
- name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
Expand Down

0 comments on commit 21e23d1

Please sign in to comment.