Repository navigation
feat(build-index): make the manifest download backoff configurable - #722
Conversation
The docker tag type retries manifest downloads with a backoff that was hard coded in tagtype.NewMap, so tuning it needed a code change. Add a backoff field to tagtype.Config so each tag_types entry can set it in yaml. It reuses httputil.ExponentialBackOffConfig, the type already behind sync_retry_backoff and download_backoff. Fields left at zero keep the current values (500ms initial interval, 0.05 randomization factor, multiplier 2, 30s max interval, 3 retries), so existing configs behave as before. Retries stay enabled for the docker type and enabled is ignored, since a missing enabled reads as false. Fixes uber#506.
thijmv
left a comment
There was a problem hiding this comment.
LGTM.
I will leave this open for a couple of days before merging, in case you want to address the nits.
| } | ||
|
|
||
| func TestMapDockerBackoffConfig(t *testing.T) { | ||
| defaults := httputil.ExponentialBackOffConfig{ |
There was a problem hiding this comment.
nit: Consider using the backoff constants for this.
There was a problem hiding this comment.
Thanks, done in eef5eaf: the defaults case now uses the constants.
| m, err := NewMap(configs, nil) | ||
| require.NoError(err) | ||
|
|
||
| r, ok := m.subResolvers[0].resolver.(*dockerResolver) |
There was a problem hiding this comment.
nit: Consider asserting m.subResolvers has length 1.
There was a problem hiding this comment.
Added require.Len(m.subResolvers, 1) before the type assertion.
| initial_interval: 2s | ||
| max_retries: 6 | ||
| `, | ||
| want: partial, |
There was a problem hiding this comment.
nit: Can we inline partial to make it more explicit and readable?
There was a problem hiding this comment.
Inlined it, so the expected config for that case is now written out in full.
| Type string `yaml:"type"` | ||
|
|
||
| // Backoff controls how the docker type retries manifest downloads. Fields | ||
| // left at zero take the defaults above, and retries are always enabled. |
There was a problem hiding this comment.
nit: Can we be more explicit about the backoff config always being enabled?
There was a problem hiding this comment.
Reworded the field comment to say that Backoff.Enabled is ignored and always set to true for the docker type, and added a short note in applyDefaults on why (a missing enabled key reads as false).
Use the default backoff constants in TestMapDockerBackoffConfig, inline the partially configured case, and check that the map holds exactly one sub resolver before the type assertion. Also say plainly in the Config and applyDefaults comments that retries are always enabled for the docker type.
|
Hi @Thanatos9404, the license CI is not passing. Can you try resigning it so we can merge this? |
|
Thanks! The CLA is already signed (CLA Assistant confirmed it on 16 Oct), but it didn't post a status on the latest commit. I've re-run the check from the CLA Assistant link; let me know if it still shows as missing on your side. |
|
Heads up: this PR is being closed and immediately re-opened to re-trigger the CLA Assistant. The |
Fixes #506
The docker tag type retries manifest downloads with a backoff that is hard coded in
tagtype.NewMap(thedefault*constants added in #502). Following the review of #502, this lets eachtag_typesentry set it in the build-index config.tagtype.Configgets abackofffield of typehttputil.ExponentialBackOffConfig, the type already used forsync_retry_backoffand the http backend'sdownload_backoff:Fields left at zero keep the current values (500ms initial interval, 0.05 randomization factor, multiplier 2, 30s max interval, 3 retries), so a config without
backoffbehaves exactly as before. The defaults wait about 3.5s in total; keep the total under the 30s timeouttagclientuses for tag PUTs, or the caller gives up while build-index is still retrying.Retries stay on for the docker type and
enabledis ignored. A missingenabledreads as false, so honoringenabled: falsewould also turn retries off for every existing config without abackoffsection.sync_retry_backoffinstead ignores all values unlessenabled: trueis set; I used per-field defaults so a partialbackoffsection just works, but can switch to thesync_retry_backoffbehavior if you prefer. As with the other users of this type,max_retries: 0means the default, so the smallest setting ismax_retries: 1.I kept
backoffon the tag type entry, next to the resolver that uses it, and reused the shared backoff type. If you'd rather have a single build-index level setting, closer to the shared retry policy suggested in #502, I can move it.Tests
TestMapDockerBackoffConfiginbuild-index/tagtype/map_test.goloadstag_typesfrom yaml and checks the backoff the docker resolver gets in four cases: nobackoff, every field set, only some fields set (the rest fall back to the defaults), andenabled: false(still the defaults). On master the two override cases fail because thebackoffkey is ignored and the resolver gets the defaults; with this change all four pass.Run on Linux (WSL Ubuntu) with Go 1.24.13, the version CI uses:
go test -race -timeout=30s --tags unit ./build-index/...: tagserver, tagstore and tagtype pass (14 tests in tagtype)go vet --tags unit ./build-index/...andgofmt -l build-index: cleangolangci-lint run ./build-index/...andgolangci-lint run --new-from-rev=master ./...(v2.14.0, repo.golangci.yml): 0 issues