From 1ac8a0f360e1e6e3305675cf115baba40a2647bd Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 16 Jan 2023 19:47:17 +0100 Subject: [PATCH 1/3] Use argsMap as whitelist for merging with volContext --- pkg/driver/mounter_seaweedfs.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/driver/mounter_seaweedfs.go b/pkg/driver/mounter_seaweedfs.go index 51adfdb..dbb8440 100644 --- a/pkg/driver/mounter_seaweedfs.go +++ b/pkg/driver/mounter_seaweedfs.go @@ -74,7 +74,8 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { args = append(args, fmt.Sprintf("-collectionQuotaMB=%d", capacityMB)) } - // Initial values for override-able args + // Values for override-able args + // Whitelist for merging with volContext argsMap := map[string]string { "collection": seaweedFs.collection, "filer": strings.Join(filers, ","), @@ -83,6 +84,8 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { "concurrentWriters": fmt.Sprint(seaweedFs.driver.ConcurrentWriters), "map.uid": seaweedFs.driver.UidMap, "map.gid": seaweedFs.driver.GidMap, + "disk": "", + "dataCenter": "", } // volContext-parameter -> mount-arg @@ -96,16 +99,18 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { // Merge volContext into argsMap with key-mapping for arg, value := range seaweedFs.volContext { - if(arg == "volumeCapacity"){ // Ignore volumeCapacity, not the nicest solution like this :/ - continue - } - // Check if key-mapping exists newArg, ok := parameterArgMap[arg] if(ok){ arg = newArg } + // Check if arg can be applied + if _, ok := argsMap[arg]; !ok { + glog.Warningf("VolumeContext '%s' ignored", arg) + continue + } + // Write to args-map argsMap[arg] = value } From 9749272b412d6179b76ced72a346ebd363bbc068 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 16 Jan 2023 20:04:54 +0100 Subject: [PATCH 2/3] Ignore and suppress warning for explicitly handled volContext args --- pkg/driver/mounter_seaweedfs.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/driver/mounter_seaweedfs.go b/pkg/driver/mounter_seaweedfs.go index dbb8440..b2a437a 100644 --- a/pkg/driver/mounter_seaweedfs.go +++ b/pkg/driver/mounter_seaweedfs.go @@ -96,9 +96,16 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { // volumeContext has "diskType", but mount-option is "disk", converting for backwards compatability "diskType": "disk", } + + // Explicitly ignored volContext args e.g. handled somewhere else + ignoreArgs := []string{ + "volumeCapacity", + } // Merge volContext into argsMap with key-mapping for arg, value := range seaweedFs.volContext { + if(in_arr(ignoreArgs, arg)){continue} + // Check if key-mapping exists newArg, ok := parameterArgMap[arg] if(ok){ @@ -158,3 +165,12 @@ func parseVolumeCapacity(volumeCapacity string) int64 { capacityMB := capacity / 1024 / 1024 return capacityMB } + +func in_arr(arr []string, val string) bool { + for _, v := range arr { + if(val == v) { + return true + } + } + return false +} From 3be6e2f80354ca8182d60fb862c318b734ecc00a Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 16 Jan 2023 20:18:37 +0100 Subject: [PATCH 3/3] Add other useful args from weed mount --- pkg/driver/mounter_seaweedfs.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/driver/mounter_seaweedfs.go b/pkg/driver/mounter_seaweedfs.go index b2a437a..16d97c8 100644 --- a/pkg/driver/mounter_seaweedfs.go +++ b/pkg/driver/mounter_seaweedfs.go @@ -86,6 +86,11 @@ func (seaweedFs *seaweedFsMounter) Mount(target string) (Unmounter, error) { "map.gid": seaweedFs.driver.GidMap, "disk": "", "dataCenter": "", + "replication": "", + "ttl": "", + "chunkSizeLimitMB": "", + "volumeServerAccess": "", + "readRetryTime": "", } // volContext-parameter -> mount-arg