Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default max-parallel-downloads in new config #2072

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/url"
"time"

"github.com/googlecloudplatform/gcsfuse/v2/internal/config"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -560,7 +561,7 @@ func BindFlags(flagSet *pflag.FlagSet) error {
return err
}

flagSet.IntP("max-parallel-downloads", "", -1, "Sets an uber limit of number of concurrent file download requests that are made across all files.")
flagSet.IntP("max-parallel-downloads", "", config.DefaultMaxParallelDownloads(), "Sets an uber limit of number of concurrent file download requests that are made across all files.")

err = viper.BindPFlag("file-cache.max-parallel-downloads", flagSet.Lookup("max-parallel-downloads"))
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ func TestValidConfig(t *testing.T) {
assert.Nil(t, cmd.Execute())
}

func TestDefaultMaxParallelDownloads(t *testing.T) {
var actual cfg.Config
cmd, err := NewRootCmd(func(c cfg.Config) error {
actual = c
return nil
})
require.Nil(t, err)
cmd.SetArgs([]string{"abc", "pqr"})

if assert.Nil(t, cmd.Execute()) {
assert.LessOrEqual(t, int64(16), actual.FileCache.MaxParallelDownloads)
}
}

func TestTooManyCobraArgs(t *testing.T) {
tests := []struct {
name string
Expand Down
1 change: 1 addition & 0 deletions tools/config-gen/config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"
"net/url"

"github.com/googlecloudplatform/gcsfuse/v2/internal/config"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
Expand Down
2 changes: 1 addition & 1 deletion tools/config-gen/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
config-path: "file-cache.max-parallel-downloads"
type: "int"
usage: "Sets an uber limit of number of concurrent file download requests that are made across all files."
default: "-1"
default: "config.DefaultMaxParallelDownloads()"

- flag-name: "download-chunk-size-mb"
config-path: "file-cache.download-chunk-size-mb"
Expand Down
Loading