Skip to content

feat: add retries to image push #3718

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

Merged
merged 6 commits into from
Apr 23, 2025
Merged

feat: add retries to image push #3718

merged 6 commits into from
Apr 23, 2025

Conversation

AustinAbro321
Copy link
Contributor

@AustinAbro321 AustinAbro321 commented Apr 22, 2025

Description

In #3559 we moved from Crane to ORAS. As part of that move, the retry logic was removed on image push. ORAS does have builtin retries but these do not account for failures on the port-forward. For example, an HPA may spin down the Zarf registry and break, these situations can only be saved by retrying and creating another tunnel. By adding back in retries at the Zarf level, we can account for these situations.

To manually test a pod failure, I restarted the Zarf registry mid push. I verified that I got a failure doing this on current Zarf, and verified that this will recover when trying with the change in this PR
image

Checklist before merging

Signed-off-by: Austin Abro <[email protected]>
@AustinAbro321 AustinAbro321 requested review from a team as code owners April 22, 2025 16:23
Copy link

netlify bot commented Apr 22, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit cf56c96
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/6807fe7ef4712b0008332d71

@AustinAbro321 AustinAbro321 marked this pull request as draft April 22, 2025 16:30
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 55.00000% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/packager/images/push.go 57.14% 24 Missing and 9 partials ⚠️
src/internal/packager2/mirror.go 0.00% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/packager2/mirror.go 0.00% <0.00%> (ø)
src/internal/packager/images/push.go 53.62% <57.14%> (+5.31%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
@AustinAbro321 AustinAbro321 marked this pull request as ready for review April 22, 2025 20:39
Copy link
Contributor

@mkcp mkcp left a comment

Choose a reason for hiding this comment

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

LGTM, nice work 💯

// Push pushes images to a registry.
func Push(ctx context.Context, cfg PushConfig) error {
if cfg.Retries < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


if err = pushImage(img.Reference, offlineNameCRC); err != nil {
return err
pushImage := func(srcName, dstName string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Declaring this as a private package func is also a valid approach, and a good way to test how portable logic in your function is (e.g. how easy it is to change should requirements change in the future). However, the params get much more complicated without using the parent func's scope, so this feels like a reasonable tradeoff here. IMO this is about the upper limit of how complex a locally scoped function variable should be.

Comment on lines +134 to +137
if err = pushImage(img, offlineName); err != nil {
return err
}
pushed = append(pushed, img)
Copy link
Contributor

Choose a reason for hiding this comment

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

elegant and readable!

@AustinAbro321 AustinAbro321 added this pull request to the merge queue Apr 23, 2025
Merged via the queue into main with commit f64329e Apr 23, 2025
26 checks passed
@AustinAbro321 AustinAbro321 deleted the retry-on-image-push branch April 23, 2025 12:04
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.

2 participants