-
Notifications
You must be signed in to change notification settings - Fork 182
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
Conversation
Signed-off-by: Austin Abro <[email protected]>
✅ Deploy Preview for zarf-docs canceled.
|
Signed-off-by: Austin Abro <[email protected]>
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
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.
LGTM, nice work 💯
// Push pushes images to a registry. | ||
func Push(ctx context.Context, cfg PushConfig) error { | ||
if cfg.Retries < 1 { |
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.
👍
|
||
if err = pushImage(img.Reference, offlineNameCRC); err != nil { | ||
return err | ||
pushImage := func(srcName, dstName string) error { |
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.
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.
if err = pushImage(img, offlineName); err != nil { | ||
return err | ||
} | ||
pushed = append(pushed, img) |
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.
elegant and readable!
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

Checklist before merging