support configurable cache directory
fix https://github.com/seaweedfs/seaweedfs-csi-driver/issues/20
This commit is contained in:
parent
40fa2802eb
commit
45ba112fa1
@ -17,6 +17,7 @@ var (
|
||||
version = flag.Bool("version", false, "Print the version and exit.")
|
||||
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)")
|
||||
cacheDir = flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -37,5 +38,6 @@ func main() {
|
||||
drv := driver.NewSeaweedFsDriver(*filer, *nodeID, *endpoint)
|
||||
drv.ConcurrentWriters = *concurrentWriters
|
||||
drv.CacheSizeMB = *cacheSizeMB
|
||||
drv.CacheDir = *cacheDir
|
||||
drv.Run()
|
||||
}
|
||||
|
||||
@ -298,6 +298,7 @@ spec:
|
||||
- "--filer=$(SEAWEEDFS_FILER)"
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
||||
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
|
||||
env:
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
|
||||
@ -309,6 +310,8 @@ spec:
|
||||
fieldPath: spec.nodeName
|
||||
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
||||
value: "1000"
|
||||
- name: SEAWEEDFS_CACHE_DIR
|
||||
value: /tmp
|
||||
imagePullPolicy: "Always"
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
@ -369,6 +372,7 @@ spec:
|
||||
- "--filer=$(SEAWEEDFS_FILER)"
|
||||
- "--nodeid=$(NODE_ID)"
|
||||
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
||||
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
|
||||
env:
|
||||
- name: CSI_ENDPOINT
|
||||
value: unix:///csi/csi.sock
|
||||
@ -380,6 +384,8 @@ spec:
|
||||
fieldPath: spec.nodeName
|
||||
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
||||
value: "1000"
|
||||
- name: SEAWEEDFS_CACHE_DIR
|
||||
value: /tmp
|
||||
imagePullPolicy: "IfNotPresent"
|
||||
volumeMounts:
|
||||
- name: plugin-dir
|
||||
|
||||
@ -39,6 +39,7 @@ type SeaweedFsDriver struct {
|
||||
grpcDialOption grpc.DialOption
|
||||
ConcurrentWriters int
|
||||
CacheSizeMB int64
|
||||
CacheDir string
|
||||
}
|
||||
|
||||
func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {
|
||||
|
||||
@ -51,6 +51,9 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) error {
|
||||
if seaweedFs.driver.ConcurrentWriters > 0 {
|
||||
args = append(args, fmt.Sprintf("-concurrentWriters=%d", seaweedFs.driver.ConcurrentWriters))
|
||||
}
|
||||
if seaweedFs.driver.CacheDir != "" {
|
||||
args = append(args, fmt.Sprintf("-cacheDir=%s", seaweedFs.driver.CacheDir))
|
||||
}
|
||||
err := fuseMount(target, seaweedFsCmd, args)
|
||||
if err != nil {
|
||||
glog.Errorf("mount %s %s to %s: %s", seaweedFs.driver.filer, seaweedFs.bucketName, target, err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user