Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Add BackoffMax config to registry config (#343)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Rename BackoffMax to RetryBackoffMax

Co-Authored-By: Ahmed Magdy <[email protected]>
  • Loading branch information
ahmagdy authored Aug 19, 2020
1 parent 4b7d347 commit abbdf51
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand All @@ -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:
Expand Down

0 comments on commit abbdf51

Please sign in to comment.