Add retry logic for retrieving top layer SHA with registry mirrors#1675
Merged
Conversation
jabrown85
reviewed
Jun 18, 2026
vpelikh
commented
Jun 18, 2026
vpelikh
left a comment
Contributor
Author
There was a problem hiding this comment.
@jabrown85 , thank you for the thorough review! I've gone through all your comments and pushed the necessary fixes. The PR should be ready for another look when you have a moment.
Really appreciate your time and attention to detail!
vpelikh
commented
Jun 18, 2026
| Metadata files.LauncherMetadata | ||
| } | ||
|
|
||
| // ExportOptions is the set of options for exporting an image. |
Contributor
Author
There was a problem hiding this comment.
@jabrown85, linting fail without comment for ExportOptions and Rebaser. Should I keep it?
jabrown85
reviewed
Jun 18, 2026
- Add TopLayerWithRetry function with exponential backoff for transient registry errors - Exporter and Rebaser now use TopLayerWithRetry instead of direct TopLayer calls - Return error directly from TopLayerWithRetry (callers wrap with context) - Delays made constant to avoid recreation on each call Closes: buildpacks#1674 Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
TopLayerWithRetry now accepts an image factory to create fresh images per retry attempt, bypassing go-containerregistry's manifest cache for registry mirrors. Non-retryable errors (401, 403) are returned immediately without retry. Retry uses backoff delays (100ms-2s) with a final bare attempt. Exporter and rebaser callers provide factory closures for remote images. Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Simplify retry architecture by replacing WorkingImageFactory/NewBaseImageFactory plumbing with a single OpenRemoteImage function that opens a remote image with retry logic for registry mirror transient errors. Changes: - Add phase.OpenRemoteImage(logger, newImage func()) that retries both image creation and TopLayer() sniff test on transient errors - Remove TopLayerWithRetry from phase package - Remove WorkingImageFactory from ExportOptions and NewBaseImageFactory from Rebaser struct - Update cmd callers to use OpenRemoteImage directly - Remove factory plumbing from cmd/lifecycle/exporter.go initRemoteAppImage and cmd/lifecycle/rebaser.go Exec() - Rewrite retry_test.go for OpenRemoteImage API Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
jabrown85
reviewed
Jun 19, 2026
jabrown85
left a comment
Contributor
There was a problem hiding this comment.
This is looking much better! A few nits and we'll be ready
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
Signed-off-by: Vasily Pelikh <2010720+vpelikh@users.noreply.github.com>
jabrown85
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds retry logic to mitigate intermittent failures when retrieving the top layer SHA from registry mirrors. Registry mirrors may temporarily return incomplete manifests as layers sync, causing the
image has no layerserror. The retry mechanism gives the mirror time to stabilize.Release notes
When using registry mirrors, the lifecycle will now retry top layer retrieval up to 5 times with exponential backoff before failing.
Related
Resolves #1674
Context
OpenRemoteImagefunction inphase/retry.gowith 5 retry attemptsOpenRemoteImageinstead of directTopLayer()calls