From abbdf516ab1a639f4d35013b74b13b38bbc57257 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Wed, 19 Aug 2020 12:46:23 +0200 Subject: [PATCH] Add BackoffMax config to registry config (#343) * Add BackoffMax config to registry config Make it possible to set backoff max value through the config file. The config file is passed using `registry-config` flag. It's backward compatible and if the user didn't pass the value it will fallback to the default `30 sec`. Co-Authored-By: Ahmed Magdy * Rename BackoffMax to RetryBackoffMax Co-Authored-By: Ahmed Magdy --- lib/registry/config.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/registry/config.go b/lib/registry/config.go index bf0f90f2..8b8b757e 100644 --- a/lib/registry/config.go +++ b/lib/registry/config.go @@ -46,12 +46,13 @@ type RepositoryMap map[string]Config // Config contains docker registry client configuration. type Config struct { - Concurrency int `yaml:"concurrency" json:"concurrency"` - Timeout time.Duration `yaml:"timeout" json:"timeout"` - Retries int `yaml:"retries" json:"retries"` - RetryInterval time.Duration `yaml:"retry_interval" json:"retry_interval"` - RetryBackoff float64 `yaml:"retry_backoff" json:"retry_backoff"` - PushRate float64 `yaml:"push_rate" json:"push_rate"` + Concurrency int `yaml:"concurrency" json:"concurrency"` + Timeout time.Duration `yaml:"timeout" json:"timeout"` + Retries int `yaml:"retries" json:"retries"` + RetryInterval time.Duration `yaml:"retry_interval" json:"retry_interval"` + RetryBackoff float64 `yaml:"retry_backoff" json:"retry_backoff"` + RetryBackoffMax time.Duration `yaml:"retry_backoff_max" json:"retry_backoff_max"` + PushRate float64 `yaml:"push_rate" json:"push_rate"` // If not specify, a default chunk size will be used. // Set it to -1 to turn off chunk upload. // NOTE: gcr and ecr do not support chunked upload. @@ -76,6 +77,9 @@ func (c Config) applyDefaults() Config { if c.RetryBackoff == 0 { c.RetryBackoff = 2 } + if c.RetryBackoffMax == 0 { + c.RetryBackoffMax = 30 * time.Second + } if c.PushRate == 0 { c.PushRate = 100 * 1024 * 1024 // 100 MB/s } @@ -90,7 +94,8 @@ func (c *Config) sendRetry() httputil.SendOption { return httputil.SendRetry( httputil.RetryMax(c.Retries), httputil.RetryInterval(c.RetryInterval), - httputil.RetryBackoff(c.RetryBackoff)) + httputil.RetryBackoff(c.RetryBackoff), + httputil.RetryBackoffMax(c.RetryBackoffMax)) } // UpdateGlobalConfig updates the global registry config given either: