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.")
|
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)")
|
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() {
|
func main() {
|
||||||
@ -37,5 +38,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.CacheSizeMB = *cacheSizeMB
|
||||||
|
drv.CacheDir = *cacheDir
|
||||||
drv.Run()
|
drv.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -298,6 +298,7 @@ spec:
|
|||||||
- "--filer=$(SEAWEEDFS_FILER)"
|
- "--filer=$(SEAWEEDFS_FILER)"
|
||||||
- "--nodeid=$(NODE_ID)"
|
- "--nodeid=$(NODE_ID)"
|
||||||
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
||||||
|
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
|
||||||
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
|
||||||
@ -309,6 +310,8 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
||||||
value: "1000"
|
value: "1000"
|
||||||
|
- name: SEAWEEDFS_CACHE_DIR
|
||||||
|
value: /tmp
|
||||||
imagePullPolicy: "Always"
|
imagePullPolicy: "Always"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: socket-dir
|
- name: socket-dir
|
||||||
@ -369,6 +372,7 @@ spec:
|
|||||||
- "--filer=$(SEAWEEDFS_FILER)"
|
- "--filer=$(SEAWEEDFS_FILER)"
|
||||||
- "--nodeid=$(NODE_ID)"
|
- "--nodeid=$(NODE_ID)"
|
||||||
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
- "--cacheCapacityMB=$(SEAWEEDFS_CACHE_CAPACITY_MB)"
|
||||||
|
- "--cacheDir=$(SEAWEEDFS_CACHE_DIR)"
|
||||||
env:
|
env:
|
||||||
- name: CSI_ENDPOINT
|
- name: CSI_ENDPOINT
|
||||||
value: unix:///csi/csi.sock
|
value: unix:///csi/csi.sock
|
||||||
@ -380,6 +384,8 @@ spec:
|
|||||||
fieldPath: spec.nodeName
|
fieldPath: spec.nodeName
|
||||||
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
- name: SEAWEEDFS_CACHE_CAPACITY_MB
|
||||||
value: "1000"
|
value: "1000"
|
||||||
|
- name: SEAWEEDFS_CACHE_DIR
|
||||||
|
value: /tmp
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugin-dir
|
- name: plugin-dir
|
||||||
|
|||||||
@ -39,6 +39,7 @@ type SeaweedFsDriver struct {
|
|||||||
grpcDialOption grpc.DialOption
|
grpcDialOption grpc.DialOption
|
||||||
ConcurrentWriters int
|
ConcurrentWriters int
|
||||||
CacheSizeMB int64
|
CacheSizeMB int64
|
||||||
|
CacheDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {
|
func NewSeaweedFsDriver(filer, nodeID, endpoint string) *SeaweedFsDriver {
|
||||||
|
|||||||
@ -51,6 +51,9 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) error {
|
|||||||
if seaweedFs.driver.ConcurrentWriters > 0 {
|
if seaweedFs.driver.ConcurrentWriters > 0 {
|
||||||
args = append(args, fmt.Sprintf("-concurrentWriters=%d", seaweedFs.driver.ConcurrentWriters))
|
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)
|
err := fuseMount(target, seaweedFsCmd, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("mount %s %s to %s: %s", seaweedFs.driver.filer, seaweedFs.bucketName, target, err)
|
glog.Errorf("mount %s %s to %s: %s", seaweedFs.driver.filer, seaweedFs.bucketName, target, err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user