Skip to content

Commit 9f90cc8

Browse files
committed
Use different (longer) login retries config
1 parent 4121fb5 commit 9f90cc8

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

cmd/lakectl/cmd/login.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ var loginCmd = &cobra.Command{
4848
DieErr(fmt.Errorf("get server URL %s: %w", cfg.Server.EndpointURL, err))
4949
}
5050

51-
client := getClient(apigen.WithHTTPClient(getHTTPClient(loginRetryPolicy)))
51+
httpClient := getHTTPClientWithRetryConfig(loginRetryPolicy, cfg.Server.LoginRetries)
52+
client := getClient(apigen.WithHTTPClient(httpClient))
5253
tokenRedirect, err := client.GetTokenRedirectWithResponse(cmd.Context())
5354
// TODO(ariels): Change back to http.StatusSeeOther after fixing lakeFS server!
5455
DieOnErrorOrUnexpectedStatusCode(tokenRedirect, err, http.StatusOK)

cmd/lakectl/cmd/root.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ type Configuration struct {
9292
} `mapstructure:"http2"`
9393
} `mapstructure:"network"`
9494
Server struct {
95-
EndpointURL lakefsconfig.OnlyString `mapstructure:"endpoint_url"`
96-
Retries RetriesCfg `mapstructure:"retries"`
95+
EndpointURL lakefsconfig.OnlyString `mapstructure:"endpoint_url"`
96+
Retries RetriesCfg `mapstructure:"retries"`
97+
LoginRetries RetriesCfg `mapstructure:"login_retries"`
9798
} `mapstructure:"server"`
9899
Options struct {
99100
Parallelism int `mapstructure:"parallelism"`
@@ -182,6 +183,10 @@ const (
182183
defaultMaxAttempts = 4
183184
defaultMaxRetryInterval = 30 * time.Second
184185
defaultMinRetryInterval = 200 * time.Millisecond
186+
187+
defaultBrowserLoginMaxAttempts = 75
188+
defaultBrowserLoginMaxRetryInterval = 1 * time.Second
189+
defaultBrowserLoginMinRetryInterval = 50 * time.Millisecond
185190
)
186191

187192
const (
@@ -558,6 +563,10 @@ func sendStats(cmd *cobra.Command, cmdSuffix string) {
558563
}
559564

560565
func getHTTPClient(checkRetry func(ctx context.Context, resp *http.Response, err error) (bool, error)) *http.Client {
566+
return getHTTPClientWithRetryConfig(checkRetry, cfg.Server.Retries)
567+
}
568+
569+
func getHTTPClientWithRetryConfig(checkRetry func(ctx context.Context, resp *http.Response, err error) (bool, error), retriesCfg RetriesCfg) *http.Client {
561570
// Override MaxIdleConnsPerHost to allow highly concurrent access to our API client.
562571
// This is done to avoid accumulating many sockets in `TIME_WAIT` status that were closed
563572
// only to be immediately reopened.
@@ -568,10 +577,10 @@ func getHTTPClient(checkRetry func(ctx context.Context, resp *http.Response, err
568577
transport.TLSClientConfig.NextProtos = []string{}
569578
}
570579
transport.MaxIdleConnsPerHost = DefaultMaxIdleConnsPerHost
571-
if !cfg.Server.Retries.Enabled {
580+
if !retriesCfg.Enabled {
572581
return &http.Client{Transport: transport}
573582
}
574-
return NewRetryClient(cfg.Server.Retries, transport, checkRetry)
583+
return NewRetryClient(retriesCfg, transport, checkRetry)
575584
}
576585

577586
func newAWSIAMAuthProviderConfig() (*awsiam.IAMAuthParams, error) {
@@ -915,11 +924,15 @@ func initConfig() {
915924

916925
// set defaults
917926
viper.SetDefault("server.endpoint_url", "http://127.0.0.1:8000")
927+
viper.SetDefault("network.http2.enabled", defaultHTTP2Enabled)
918928
viper.SetDefault("server.retries.enabled", true)
919929
viper.SetDefault("server.retries.max_attempts", defaultMaxAttempts)
920-
viper.SetDefault("network.http2.enabled", defaultHTTP2Enabled)
921930
viper.SetDefault("server.retries.max_wait_interval", defaultMaxRetryInterval)
922931
viper.SetDefault("server.retries.min_wait_interval", defaultMinRetryInterval)
932+
viper.SetDefault("server.login_retries.enabled", true)
933+
viper.SetDefault("server.login_retries.max_attempts", defaultBrowserLoginMaxAttempts)
934+
viper.SetDefault("server.login_retries.max_wait_interval", defaultBrowserLoginMaxRetryInterval)
935+
viper.SetDefault("server.login_retries.min_wait_interval", defaultBrowserLoginMinRetryInterval)
923936
viper.SetDefault("experimental.local.posix_permissions.enabled", false)
924937
viper.SetDefault("local.skip_non_regular_files", false)
925938
viper.SetDefault("local.symlink_support", false)

0 commit comments

Comments
 (0)