-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[release/8.0.4xx] Containers - Retry on download blob #48987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/8.0.4xx
Are you sure you want to change the base?
Conversation
@@ -539,6 +539,37 @@ public void IsRegistryInsecure(string registryName, string? insecureRegistriesEn | |||
Assert.Equal(expectedInsecure, registrySettings.IsInsecure); | |||
} | |||
|
|||
[Fact] | |||
public async Task DownloadBlobAsync_RetriesOnFailure() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there also be a test that the download gives up if the number of retries is exceeded?
mockRegistryAPI.Verify(api => api.Blob.GetStreamAsync(repoName, descriptor.Digest, cancellationToken), Times.Exactly(3)); // Verify retries | ||
|
||
//Cleanup | ||
File.Delete(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should this be in a finally block so it cleans up even when the test fails?
@@ -237,6 +237,11 @@ private static async Task<int> PushToRemoteRegistryAsync(ILogger logger, BuiltIm | |||
cancellationToken)).ConfigureAwait(false); | |||
logger.LogInformation(Strings.ContainerBuilder_ImageUploadedToRegistry, destinationImageReference, destinationImageReference.RemoteRegistry.RegistryName); | |||
} | |||
catch (UnableToDownloadFromRepositoryException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect to see this updated in PushToLocalRegistryAsync
as well, correct? That's at the root of the stack in the linked issue.
Fixes #48940
Description/Customer Impact
When building images we often have to pull base image layers from remote sources. These layers can be quite large, and so network interruption can cause the entire build to report failure. Typically we try to retry these operations (e.g. the Copy Task in MSBuild itself), so we should do the same here.
We're forced to use pretty naive retries (operation-level, not chunk-level) because the OCI HTTP API and many popular registries do not support chunked requests well.
Changes made
DownloadBlobAsync
in case of failure from upgraded logging for #595 log url when connection is closed #44953 (too many commits, something goes wrong when try git cherry-pick)Registry.DownloadBlobAsync
by adding a retry mechanismTesting
Added unit test for retry mechanism.
Risk
Low - tests have been added and the mechanism is very simple.