sync: make RetryDelay and MaxRetries optional

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
Petu Eusebiu 2022-02-09 17:55:03 +02:00 committed by Ramkumar Chinchani
parent 37d150e32f
commit 0ec39c0313
4 changed files with 9 additions and 13 deletions

View File

@ -388,8 +388,8 @@ Configure each registry sync:
"pollInterval": "6h", # polling interval, if not set then periodically polling will not run
"tlsVerify": true, # whether or not to verify tls (default is true)
"certDir": "/home/user/certs", # use certificates at certDir path, if not specified then use the default certs dir
"maxRetries": 5, # mandatory option! maxRetries in case of temporary errors
"retryDelay": "10m", # mandatory option! delay between retries, retry options are applied for both on demand and periodically sync.
"maxRetries": 5, # maxRetries in case of temporary errors (default: no retries)
"retryDelay": "10m", # delay between retries, retry options are applied for both on demand and periodically sync and retryDelay is mandatory when using maxRetries.
"content":[ # which content to periodically pull, also it's used for filtering ondemand images, if not set then periodically polling will not run
{
"prefix":"/repo1/repo", # pull image repo1/repo
@ -411,8 +411,6 @@ Configure each registry sync:
"pollInterval": "12h",
"tlsVerify": false,
"onDemand": false,
"maxRetries": 5,
"retryDelay": "10m",
"content":[
{
"prefix":"/repo2",
@ -426,11 +424,11 @@ Configure each registry sync:
"urls": ["https://docker.io/library"],
"onDemand": true, # doesn't have content, don't periodically pull, pull just on demand.
"tlsVerify": true,
"maxRetries": 3,
"maxRetries": 3,
"retryDelay": "15m"
}
]
}
```
Prefixes can be strings that exactly match repositories or they can be glob patterns.
Prefixes can be strings that exactly match repositories or they can be [glob](https://en.wikipedia.org/wiki/Glob_(programming)) patterns.

View File

@ -40,8 +40,6 @@
"pollInterval": "12h",
"tlsVerify": false,
"onDemand": false,
"maxRetries": 5,
"retryDelay": "10m",
"content":[
{
"prefix":"/repo2",

View File

@ -246,11 +246,11 @@ func validateConfiguration(config *config.Config) {
// check glob patterns in sync config are compilable
if config.Extensions != nil && config.Extensions.Sync != nil {
for _, regCfg := range config.Extensions.Sync.Registries {
for id, regCfg := range config.Extensions.Sync.Registries {
// check retry options are configured for sync
if regCfg.MaxRetries == nil || regCfg.RetryDelay == nil {
log.Error().Err(errors.ErrBadConfig).Msg("extensions.sync.registries[].MaxRetries" +
"and extensions.sync.registries[].RetryDelay fields are mandatory")
if regCfg.MaxRetries != nil && regCfg.RetryDelay == nil {
log.Error().Err(errors.ErrBadConfig).Msgf("extensions.sync.registries[%d].retryDelay"+
" is required when using extensions.sync.registries[%d].maxRetries", id, id)
panic(errors.ErrBadConfig)
}

View File

@ -267,7 +267,7 @@ func TestVerify(t *testing.T) {
"http":{"address":"127.0.0.1","port":"8080","realm":"zot",
"auth":{"htpasswd":{"path":"test/data/htpasswd"},"failDelay":1}},
"extensions":{"sync": {"registries": [{"urls":["localhost:9999"],
"content": [{"prefix":"repo**"}]}]}}}`)
"maxRetries": 10, "content": [{"prefix":"repo**"}]}]}}}`)
_, err = tmpfile.Write(content)
So(err, ShouldBeNil)
err = tmpfile.Close()