Skip to content
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

Merged
merged 1 commit into from
Aug 5, 2020
Merged

Conversation

QiWang19
Copy link
Contributor

@QiWang19 QiWang19 commented Jul 8, 2020

@rhatdan
Copy link
Member

rhatdan commented Jul 8, 2020

@QiWang19 Please fixup you PR explanation, Explain what is going to happen

@rhatdan
Copy link
Member

rhatdan commented Jul 8, 2020

Do we need this for podman create and podman run?

@QiWang19
Copy link
Contributor Author

QiWang19 commented Jul 8, 2020

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.

@rhatdan
Copy link
Member

rhatdan commented Jul 8, 2020

Great.

@QiWang19 QiWang19 marked this pull request as draft July 9, 2020 14:05
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 9, 2020
@QiWang19 QiWang19 changed the title retry pulling image [WIP]retry pulling image Jul 9, 2020
@QiWang19 QiWang19 removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2020
@QiWang19 QiWang19 marked this pull request as ready for review July 15, 2020 14:33
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2020
@QiWang19 QiWang19 changed the title [WIP]retry pulling image Retry pulling image Jul 15, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2020

_, err = cp.Image(ctx, policyContext, imageInfo.dstRef, imageInfo.srcRef, copyOptions)
if err != nil {
destRef := imageInfo.dstRef
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

@@ -174,3 +182,63 @@ func imageNameForSaveDestination(img *Image, imgUserInput string) string {
}
return fmt.Sprintf("%s%s", prepend, imgUserInput)
}

func retryIfNecessary(operation func() error) error {
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Member

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.

@QiWang19 QiWang19 force-pushed the retry-pull branch 2 times, most recently from f30a9c4 to 1e27781 Compare July 20, 2020 23:29
@QiWang19 QiWang19 marked this pull request as draft July 20, 2020 23:29
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 20, 2020
@QiWang19 QiWang19 force-pushed the retry-pull branch 2 times, most recently from ae412f2 to e3aaf5e Compare July 21, 2020 00:10
@rhatdan
Copy link
Member

rhatdan commented Jul 21, 2020

@QiWang19 Open the PR against containers/common

@rhatdan
Copy link
Member

rhatdan commented Jul 22, 2020

@QiWang19 containers/common merged, can you update this PR?

@QiWang19 QiWang19 marked this pull request as ready for review July 22, 2020 14:24
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2020
@rhatdan
Copy link
Member

rhatdan commented Jul 22, 2020

LGTM
@ParkerVR @mtrmac @mheon @vrothberg PTAL

@@ -14,6 +14,7 @@ import (
"syscall"
"time"

commonimage "github.com/containers/common/pkg/image"
Copy link
Member

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.

Copy link
Collaborator

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).

Copy link
Contributor Author

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 .

Copy link
Collaborator

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.)

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Collaborator

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

@TomSweeneyRedHat
Copy link
Member

Changes LGTM , but I want a head nod from @mtrmac on the package naming before moving forward.

@rhatdan rhatdan changed the title Retry pulling image [wip] Retry pulling image Jul 22, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2020
@rhatdan
Copy link
Member

rhatdan commented Aug 4, 2020

@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]>
@rhatdan
Copy link
Member

rhatdan commented Aug 5, 2020

/approve
LGTM
@QiWang19 Can you remove [wip] from description?

@openshift-ci-robot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2020
@QiWang19 QiWang19 changed the title [wip] Retry pulling image Retry pulling image Aug 5, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 5, 2020
@QiWang19
Copy link
Contributor Author

QiWang19 commented Aug 5, 2020

[wip] removed

Copy link
Member

@vrothberg vrothberg left a 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

@vrothberg
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2020
@openshift-merge-robot openshift-merge-robot merged commit 7a7c8e9 into containers:master Aug 5, 2020
@rhatdan
Copy link
Member

rhatdan commented Aug 6, 2020

@QiWang19 is skopeo and Buildah now using the same code from containers/common?

@QiWang19
Copy link
Contributor Author

QiWang19 commented Aug 6, 2020

@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.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants