Skip to content

feat(build-index): make the manifest download backoff configurable - #722

Merged
thijmv merged 2 commits into
uber:masterfrom
Thanatos9404:build-index-configurable-backoff
Oct 27, 2026
Merged

thijmv merged 2 commits into
uber:masterfrom
Thanatos9404:build-index-configurable-backoff

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

Fixes #506

The docker tag type retries manifest downloads with a backoff that is hard coded in tagtype.NewMap (the default* constants added in #502). Following the review of #502, this lets each tag_types entry set it in the build-index config.

tagtype.Config gets a backoff field of type httputil.ExponentialBackOffConfig, the type already used for sync_retry_backoff and the http backend's download_backoff:

tag_types:
  - namespace: .*
    type: docker
    backoff:
      initial_interval: 1s
      max_retries: 5

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 backoff behaves exactly as before. The defaults wait about 3.5s in total; keep the total under the 30s timeout tagclient uses for tag PUTs, or the caller gives up while build-index is still retrying.

Retries stay on for the docker type and enabled is ignored. A missing enabled reads as false, so honoring enabled: false would also turn retries off for every existing config without a backoff section. sync_retry_backoff instead ignores all values unless enabled: true is set; I used per-field defaults so a partial backoff section just works, but can switch to the sync_retry_backoff behavior if you prefer. As with the other users of this type, max_retries: 0 means the default, so the smallest setting is max_retries: 1.

I kept backoff on 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

TestMapDockerBackoffConfig in build-index/tagtype/map_test.go loads tag_types from yaml and checks the backoff the docker resolver gets in four cases: no backoff, every field set, only some fields set (the rest fall back to the defaults), and enabled: false (still the defaults). On master the two override cases fail because the backoff key 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/... and gofmt -l build-index: clean
  • golangci-lint run ./build-index/... and golangci-lint run --new-from-rev=master ./... (v2.14.0, repo .golangci.yml): 0 issues

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.
Copilot AI balanced review requested due to automatic review settings October 16, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CLAassistant

CLAassistant commented Oct 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gkeesh7
gkeesh7 requested a review from thijmv October 22, 2026 11:15

@thijmv thijmv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider using the backoff constants for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Consider asserting m.subResolvers has length 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added require.Len(m.subResolvers, 1) before the type assertion.

Comment thread build-index/tagtype/map_test.go Outdated
initial_interval: 2s
max_retries: 6
`,
want: partial,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we inline partial to make it more explicit and readable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined it, so the expected config for that case is now written out in full.

Comment thread build-index/tagtype/map.go Outdated
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we be more explicit about the backoff config always being enabled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@thijmv

thijmv commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Hi @Thanatos9404, the license CI is not passing. Can you try resigning it so we can merge this?

@Thanatos9404

Copy link
Copy Markdown
Contributor Author

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.

@cm-howard

Copy link
Copy Markdown

Heads up: this PR is being closed and immediately re-opened to re-trigger the CLA Assistant. The license/cla status was never reported on the latest commit, so this is to help remedy the missing CLA attribution. No action is needed from you; the CLA check should update shortly.

@cm-howard cm-howard closed this Oct 27, 2026
@cm-howard cm-howard reopened this Oct 27, 2026
@thijmv
thijmv merged commit b75fbcb into uber:master Oct 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the build index backoff configuration, config driven

5 participants