20318: Add -cache-size flag to arvados-client mount.
authorTom Clegg <tom@curii.com>
Tue, 26 Dec 2023 20:44:12 +0000 (15:44 -0500)
committerTom Clegg <tom@curii.com>
Tue, 26 Dec 2023 20:45:08 +0000 (15:45 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/mount/command.go

index 666f2cf4acebfce59918e64894dda894e332438d..7ab518faee78a8ab20305b91132cacadc26cfddf 100644 (file)
@@ -19,6 +19,7 @@ import (
        "git.arvados.org/arvados.git/sdk/go/arvadosclient"
        "git.arvados.org/arvados.git/sdk/go/keepclient"
        "github.com/arvados/cgofuse/fuse"
+       "github.com/ghodss/yaml"
 )
 
 var Command = &mountCommand{}
@@ -43,6 +44,7 @@ func (c *mountCommand) RunCommand(prog string, args []string, stdin io.Reader, s
        flags := flag.NewFlagSet(prog, flag.ContinueOnError)
        ro := flags.Bool("ro", false, "read-only")
        experimental := flags.Bool("experimental", false, "acknowledge this is an experimental command, and should not be used in production (required)")
+       cacheSizeStr := flags.String("cache-size", "0", "cache size as percent of home filesystem size (\"5%\") or size (\"10GiB\") or 0 for automatic")
        pprof := flags.String("pprof", "", "serve Go profile data at `[addr]:port`")
        if ok, code := cmd.ParseFlags(flags, prog, args, "[FUSE mount options]", stderr); !ok {
                return code
@@ -58,6 +60,10 @@ func (c *mountCommand) RunCommand(prog string, args []string, stdin io.Reader, s
        }
 
        client := arvados.NewClientFromEnv()
+       if err := yaml.Unmarshal([]byte(*cacheSizeStr), &client.DiskCacheSize); err != nil {
+               logger.Printf("error parsing -cache-size argument: %s", err)
+               return 2
+       }
        ac, err := arvadosclient.New(client)
        if err != nil {
                logger.Print(err)