support configurable cache size

fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/20
This commit is contained in:
Chris Lu 2021-04-11 11:50:46 -07:00
parent 177fdf0ea0
commit 40fa2802eb
4 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,7 @@ var (
nodeID = flag.String("nodeid", "", "node id") nodeID = flag.String("nodeid", "", "node id")
version = flag.Bool("version", false, "Print the version and exit.") version = flag.Bool("version", false, "Print the version and exit.")
concurrentWriters = flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers if not 0") concurrentWriters = flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers if not 0")
cacheSizeMB = flag.Int64("cacheCapacityMB", 1000, "local file chunk cache capacity in MB (0 will disable cache)")
) )
func main() { func main() {
@ -35,5 +36,6 @@ func main() {
drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint) drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint)
drv.ConcurrentWriters = *concurrentWriters drv.ConcurrentWriters = *concurrentWriters
drv.CacheSizeMB = *cacheSizeMB
drv.Run() drv.Run()
} }

View File

@ -297,6 +297,7 @@ spec:
- "--endpoint=$(CSI_ENDPOINT)" - "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)" - "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)" - "--nodeid=$(NODE_ID)"
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
env: env:
- name: CSI_ENDPOINT - name: CSI_ENDPOINT
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
@ -306,6 +307,8 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: spec.nodeName fieldPath: spec.nodeName
- name: SEAWEEDFS_CACHE_CAPACITY_MB
value: "1000"
imagePullPolicy: "Always" imagePullPolicy: "Always"
volumeMounts: volumeMounts:
- name: socket-dir - name: socket-dir
@ -365,6 +368,7 @@ spec:
- "--endpoint=$(CSI_ENDPOINT)" - "--endpoint=$(CSI_ENDPOINT)"
- "--filer=$(SEAWEEDFS_FILER)" - "--filer=$(SEAWEEDFS_FILER)"
- "--nodeid=$(NODE_ID)" - "--nodeid=$(NODE_ID)"
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
env: env:
- name: CSI_ENDPOINT - name: CSI_ENDPOINT
value: unix:///csi/csi.sock value: unix:///csi/csi.sock
@ -374,6 +378,8 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: spec.nodeName fieldPath: spec.nodeName
- name: SEAWEEDFS_CACHE_CAPACITY_MB
value: "1000"
imagePullPolicy: "IfNotPresent" imagePullPolicy: "IfNotPresent"
volumeMounts: volumeMounts:
- name: plugin-dir - name: plugin-dir

View File

@ -38,6 +38,7 @@ type SeaweedFsDriver struct {
filer string filer string
grpcDialOption grpc.DialOption grpcDialOption grpc.DialOption
ConcurrentWriters int ConcurrentWriters int
CacheSizeMB int64
} }
func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver { func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {

View File

@ -36,6 +36,7 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) error {
fmt.Sprintf("-collection=%s", seaweedFs.bucketName), fmt.Sprintf("-collection=%s", seaweedFs.bucketName),
fmt.Sprintf("-filer=%s", seaweedFs.driver.filer), fmt.Sprintf("-filer=%s", seaweedFs.driver.filer),
fmt.Sprintf("-filer.path=/buckets/%s", seaweedFs.bucketName), fmt.Sprintf("-filer.path=/buckets/%s", seaweedFs.bucketName),
fmt.Sprintf("-cacheCapacityMB=%d", seaweedFs.driver.CacheSizeMB),
} }
for arg, value := range seaweedFs.volContext { for arg, value := range seaweedFs.volContext {