-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Retry pulling image #6905
Retry pulling image #6905
Conversation
@QiWang19 Please fixup you PR explanation, Explain what is going to happen |
Do we need this for podman create and podman run? |
This retry also plans to work for create and run since the retry function wrapped the inner helper method that is used by create and run. |
Great. |
libpod/image/pull.go
Outdated
|
||
_, err = cp.Image(ctx, policyContext, imageInfo.dstRef, imageInfo.srcRef, copyOptions) | ||
if err != nil { | ||
destRef := imageInfo.dstRef |
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: Why do you need to use variables?
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.
Gating tests complain about using imageInfo
in the retry loop cause it's a variable from the outer loop.
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 that warning is about the loop variable changing in next iteration, affecting the closure, an imageInfo := imageInfo
might work just as well.
libpod/image/utils.go
Outdated
@@ -174,3 +182,63 @@ func imageNameForSaveDestination(img *Image, imgUserInput string) string { | |||
} | |||
return fmt.Sprintf("%s%s", prepend, imgUserInput) | |||
} | |||
|
|||
func retryIfNecessary(operation func() error) 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.
Can you put this code into containers/common, since podman, Buildah and Skopeo are all going to use it?
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.
This functionality along with @ParkerVR pulling of shortnames should be put into common/pkg/image shared functions.
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 can draft a PR in c/common, will this be common/pkg/image/image.go or pull.go? @ParkerVR?
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 have been testing locally with pkg/image/pull.go, which I think makes more sense for consistency.
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.
containers/common PR has been merged.
f30a9c4
to
1e27781
Compare
ae412f2
to
e3aaf5e
Compare
@QiWang19 Open the PR against containers/common |
@QiWang19 containers/common merged, can you update this PR? |
LGTM |
libpod/image/image.go
Outdated
@@ -14,6 +14,7 @@ import ( | |||
"syscall" | |||
"time" | |||
|
|||
commonimage "github.com/containers/common/pkg/image" |
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.
Is @mtrmac happy with this package name? I thought he raised concerns over in common (containers/common#229) and I'd like to settle that before we move forward with this PR.
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.
That really depends on what else is planned to go into that package.
The retry code is somewhat image-independent (but not entirely, it does check for registry errors, and drag in a registry subpackage) and could be used for other network operations, so I don’t think it’s a good name for a package containing only this code. A larger package containing several more image-related utilities might make more sense, OTOH it’s currently not clear to me that that would have to be a single package versus a set of utility subpackages (from which only a subset could be used to minimize dependencies in consumers).
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.
This package plans to merge the work from @ParkerVR pulling of shortnames .
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.
Yeah — is there value in having both in a single subpackage? Skopeo won’t use the short name part, at least.
(I don’t really want to make a big deal out of this, the c/common has no API guarantee, it’s not that much code I expect, and the repos are tightly coupled enough that we can rearrange any time. I guess dragging in the full containers.conf config file, or some user-observable non-optional initialization behavior, into Skopeo would be the point I’d start feeling stronger about this.)
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 don't object to having them both in the same package, but I do object to the name. Importing both github.com/containers/libpod/v2/libpod/image
and github.com/containers/common/pkg/image
in the same file is horribly confusing and renaming one at import time does not make things much better.
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.
thanks @mtrmac . I moved it to a single pkg. PTAL containers/common#237
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 definitely do not like the name retry, it is too small, I am leaning torwards containers/common/pkg/pull.
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 agree with Dan - but do we want more organization with something like containers/common/pkg/image/pull ? This might give us more space for the future with less refactoring
Changes LGTM , but I want a head nod from @mtrmac on the package naming before moving forward. |
@QiWang19 What is going on with this PR? Can we move this to no longer WIP? |
Wrap the inner helper in the retry function. Functions pullimage failed with retriable error will default maxretry 3 times using exponential backoff. Signed-off-by: Qi Wang <[email protected]>
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: QiWang19, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[wip] removed |
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, great work, @QiWang19
/lgtm |
@QiWang19 is skopeo and Buildah now using the same code from containers/common? |
No, they are not using c/common. Will open PRs for that. |
related: Podman Pull Images always error when docker not #4251 (comment)
Signed-off-by: Qi Wang [email protected]