Repository navigation
feat(build-index): count manifest downloads that succeed after a retry - #723
Conversation
|
Hi @Thanatos9404 |
|
Thanks! #723 is already built on #722 (its first commit is #722's), but GitHub's stacked PRs need both branches in the same repository, and these come from my fork, so I can't link them as a stack. Once #722 is merged I'll rebase this so it only has its own commit. If you'd prefer, I can close #722 and keep both changes here instead. The |
thijmv
left a comment
There was a problem hiding this comment.
Could you keep this PR to the metric addition only? That is, drop the configurable backoff commit from this PR (or rebase this PR onto Thanatos9404:build-index-configurable-backoff).
| return 0 | ||
| } | ||
|
|
||
| func TestDockerResolver_DownloadManifest_RetrySuccessMetric(t *testing.T) { |
There was a problem hiding this comment.
Can we add a case where the download never succeeds after retrying, and assert that the metric is not emitted?
| failures int | ||
| want int64 | ||
| }{ | ||
| {"succeeds on the first attempt", 0, 0}, |
There was a problem hiding this comment.
nit: Can we use field names for the test cases? It may not be immediately clear to a new reader what, e.g. 0, 0 refers to.
4308831 to
4090d39
Compare
|
Thanks for the review! I dropped the backoff commit, so this PR is now only the metric change on top of master. The resolver test has a new case where every attempt fails and checks the counter stays at 0, and the test cases now use field names. Since #722 touches the same |
| {desc: "succeeds after one retry", failures: 1, succeeds: true, want: 1}, | ||
| {desc: "succeeds after two retries", failures: 2, succeeds: true, want: 1}, | ||
| // MaxRetries is 3, so every one of the 4 attempts fails. | ||
| {desc: "never succeeds", failures: 4, succeeds: false, want: 0}, |
There was a problem hiding this comment.
nit: We could add a testMaxRetries constant (also used by newTestDockerResolver) to avoid a comment and magic number here.
There was a problem hiding this comment.
Good idea, done in e1dd338: testMaxRetries now sets MaxRetries in newTestDockerResolver, and the never-succeeds case uses testMaxRetries + 1, so the comment is gone.
|
Heads up: this PR is being closed and immediately re-opened to re-trigger the CLA Assistant. The |
|
Hi @Thanatos9404, can you rebase your branch with the latest changes from master? |
Since uber#502 the docker tag type retries manifest downloads that fail with a 404 or a network error, but nothing records how often a retry is what made the download succeed, so there is no way to see what the retries buy. Pass the build-index tally scope into tagtype.NewMap, tag it with module tagtype as other components do, and increment a manifest_download_retry_successes counter when a manifest download succeeds on an attempt after the first. Downloads that succeed on the first attempt and downloads that fail after every retry are not counted. Fixes uber#507.
…metric test Add a case where every attempt fails and check that the counter is not incremented, and name the fields of the test cases.
Add a testMaxRetries constant for the MaxRetries value in newTestDockerResolver and use it in the never-succeeds case of the retry metric test, instead of a hardcoded attempt count and a comment.
e1dd338 to
c120889
Compare
|
Done, rebased onto master. The only conflict was in |
Fixes #507
#502 added retries to the manifest download that build-index does when it resolves a tag's dependencies, and its review asked for a way to see how many downloads only succeed thanks to a retry. This adds a counter for that.
tagtype.NewMapnow takes the build-indextally.Scope(passed frombuild-index/cmd/cmd.go) and tags it withmodule: tagtype, like the tagserver and other components do.dockerResolver.downloadManifestincrementsmanifest_download_retry_successeswhen the download succeeds on an attempt after the first. Downloads that succeed on the first attempt, and downloads that still fail after the last retry, are not counted.Tests
TestDockerResolver_DownloadManifest_RetrySuccessMetricinbuild-index/tagtype/docker_resolver_test.gochecks the counter after a download that succeeds on the first attempt (0), after one or two retries (1), and when every attempt fails (0).TestMapDockerRetrySuccessMetricinbuild-index/tagtype/map_test.gogoes throughNewMapandResolvewith one retry and checks formanifest_download_retry_successes+module=tagtype= 1.NewMapcallers inmap_test.gopasstally.NoopScope.go test --tags unit ./build-index/tagtype/passes on Linux andgo vetis clean for the package.