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

Fix pulling of images within buildah #1319

Closed
wants to merge 4 commits into from
Closed

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Feb 2, 2019

Change references to Transfer to transfer to make it internal only.
It should be determined from the image specification and only determined
in one place.

Make buildah.Pull use registries.conf

Currently buildah pull does not resolve images based on registries.conf
This does not match the behaviour of buildah from or buildah bud

Signed-off-by: Daniel J Walsh [email protected]

@TomSweeneyRedHat
Copy link
Member

Does this resolve #1316?

pull.go Outdated
if options.ReportWriter != nil {
options.ReportWriter.Write([]byte("Pulling " + name + "\n"))
}
ref, err := pullImage(ctx, options.Store, name, options, systemContext)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I've not had enuf tea today, but it looks like you're only pulling images now when you have --all-tags involved. Does this still work for buildah pull alpine?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.
srcRef, _, err := resolveImage(ctx, systemContext, options.Store, boptions)
Actually pulls the image. The dump-tags is just using the resolved first image name to pull all of the tags.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 2, 2019

Fixes #1316

@rhatdan
Copy link
Member Author

rhatdan commented Feb 3, 2019

@TomSweeneyRedHat
Copy link
Member

I'd like to take a deeper dive an run some test with this Tues morn. But if others OK this before, then fine by me.

pull.go Show resolved Hide resolved
pull.go Show resolved Hide resolved
pull.go Outdated Show resolved Hide resolved
pull.go Outdated Show resolved Hide resolved
@TomSweeneyRedHat
Copy link
Member

When an image is pulled, the imageID is not being printed with this patch as it had been prior.

# buildah images
# buildah pull docker.io/busybox
# buildah images
IMAGE NAME                                               IMAGE TAG            IMAGE ID             CREATED AT             SIZE
docker.io/library/busybox                                latest               3a093384ac30         Dec 31, 2018 20:21     1.42 MB

@TomSweeneyRedHat
Copy link
Member

Not only no imageId at the end, but no progress bars.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 5, 2019

Fixed imageid and progress problems.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 14, 2019

@TomSweeneyRedHat Could you merge this one.

@TomSweeneyRedHat
Copy link
Member

Code and testing LGTM, but I'd like to get a head nod from @mtrmac to make sure his concerns were addressed. I'm not quite sure about his second comment in the old code in particular having been addressed.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 15, 2019

I would rather get his concerns addressed in a new effort to get this code rewritten into containers/image and then vendored into podman, Buildah and CRI-O to do it the same way in all packages.

@TomSweeneyRedHat
Copy link
Member

I was hoping @mtrmac would be able to check in by now, but I'll go ahead and merge now. I agree the right place for this functionality in my book is containers/image and it looks like we're moving in that direction.

@TomSweeneyRedHat
Copy link
Member

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 73361eb has been approved by TomSweeneyRedHat

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 73361eb with merge f183b09...

rh-atomic-bot pushed a commit that referenced this pull request Feb 15, 2019
Currently buildah pull does not resolve images based on registries.conf
This does not match the behaviour of buildah from or buildah bud

This patch makes buildah pull use the same image resolver as the other
two tools.

Signed-off-by: Daniel J Walsh <[email protected]>

Closes: #1319
Approved by: TomSweeneyRedHat
@rh-atomic-bot
Copy link
Collaborator

💔 Test failed - status-travis

@mtrmac
Copy link
Contributor

mtrmac commented Feb 15, 2019

Code and testing LGTM, but I'd like to get a head nod from @mtrmac to make sure his concerns were addressed. I'm not quite sure about his second comment in the old code in particular having been addressed.

AFAICS all of those review comments are still applicable.

In my experience it’s pretty much never worth it to knowingly introduce new bugs in order to get a new feature, especially if introducing those bugs is not at all essential for the feature (as is the case of
https://github.com/containers/buildah/pull/1319/files#r253626657 , which needs about three more lines; the other comments may require notably more code). But, *shrug*, I realize that’s a bit extremist approach, and there may not be time or, well, interest, to avoid such situations — again, not my call, but that decision did depend on me being happy with the PR, I’m afraid I’m still not.


On a more conceptual level, does it even make much sense to buildah pull --all-tags fedora? Does that mean “I want all fedora:* tags from all registries on the search list”, or “I want all fedora:* tags from the first registry on the search list that contains a fedora, but I don’t care at all which registry it is”? The latter seems a tiny bit more sane, but both seem, fundamentally, rather useless. When would anyone ever want to use either?

So, maybe, at the highest level, there should be a separate PullAllTags + Pull, with PullAllTags not using the search path at all (and minimally modified), and Pull modified roughly like this PR? That would also nicely bypass the ":" and the srcRef concerns (but not the other alltransports.ParseImageName semantics breakage).

OTOH doing that the easy way would cause PullAllTags to (continue to) use the docker.io/library normalization, which may be considered very undesirable.

@mtrmac
Copy link
Contributor

mtrmac commented Feb 15, 2019

I would rather get his concerns addressed in a new effort to get this code rewritten into containers/image and then vendored into podman, Buildah and CRI-O to do it the same way in all packages.

(BTW don’t expect miracles from this — as https://github.com/containers/libpod/blob/9c1b08fd79012c12d478edb13f6057a0414762db/libpod/image/parts.go#L54 shows, rewrites in c/image won’t free libpod/buildah from making decisions about semantics of the input; if anything, it would make it less avoidable for them to make such decisions.)

@rhatdan rhatdan changed the title Resolve buildah.Pull to use registries.conf Fix pulling of images within buildah Feb 17, 2019
@rhatdan
Copy link
Member Author

rhatdan commented Feb 17, 2019

@mtrmac @nalind
I reworked this PR Heavily to remove the handling of Transports from the clients, and moved it into the library.

I made the Transports private to the library to prevent the client passing in a transport different then the image.

Transport=docker
ImageName=ociarchive:/tmp/foobar

Also added OCI As a valid format.

util.ResolveImage now returns the image name without the transport as well as the transport.

@rhatdan rhatdan force-pushed the pull branch 3 times, most recently from 6ce7646 to 19b3e8d Compare February 17, 2019 23:11
@@ -25,6 +25,9 @@ Multiple transports are supported:
**docker-daemon:**_docker-reference_
An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID).

**oci:**_path_**:**_tag_**
An image tag in a directory compliant with "Open Container Image Layout Specification" at path.
Copy link
Member

Choose a reason for hiding this comment

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

nit, s/path/path/

Copy link
Member

Choose a reason for hiding this comment

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

Ugh love GitHub auto md sometimes

s/path/_path_/

@TomSweeneyRedHat
Copy link
Member

@nalind and/or @vrothberg PTAL

@@ -340,7 +340,7 @@ type BuilderOptions struct {
// needs to be pulled and the image name alone, or the image name and
// the registry together, can not be resolved to a reference to a
// source image. No separator is implicitly added.
Transport string
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering why you switched this to lower case? Also in pull.go. I understand the scoping, but none of the other variables in these structs are lowercase. In some of the code we have a number of variables named transport(s) being used and having this upper case helps it to stand out better.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want callers to use this field. We use it to pass the information around withing buildah library, but specifying transport as well as imagename can cause conflicts.
Bottom line, I only want transport derived in one place and from ImageName. Before we had it being derived in different places,and not the same way.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

I very much like dropping the reliance on setting Transport in the front-end.

This opens up quite a few other opportunities for clean up, mostly non-blocking.

OTOH the AllTags code motivating this PR is still conflicted about handling its input.

buildah.go Outdated Show resolved Hide resolved
cmd/buildah/from.go Show resolved Hide resolved
if len(arr) == 2 {
if iopts.allTags {
return errors.Errorf("tag can't be used with --all-tags")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This check seems useful and worth preserving somewhere (though this implementation did not made little sense). AFAICS util.ResolveNames does not add the implicit :latest tag, so the check could be moved closer to the PullOptions.AllTags implementation .

Copy link
Member Author

Choose a reason for hiding this comment

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

This is tough to check, and seem fairly arbitrary. If I state I want to pull --alltags on alpine:latest, I don't see this as a big conflict.

imagebuildah/build.go Show resolved Hide resolved
util/util.go Outdated Show resolved Hide resolved
pull.go Outdated Show resolved Hide resolved
pull.go Outdated
options.ReportWriter = nil // Turns off logging output
boptions.ReportWriter = nil // Turns off logging output
}
srcRef, transport, img, err := resolveImage(ctx, systemContext, options.Store, boptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Still #1319 (comment) . In addition, this will break for the AllTags case if an image with the :latest tag does not exist.

Maybe the AllTags case should be handled separately, and explicitly hard-code / enforce docker.Transport? See also the earlier question about what AllTags + search means, and others.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I don't test for the conflict of TAG versus all-tag, then the user must specify a legal tag if the :latest does not exist to do a pull-all.

Is that adequate for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least, s/srcRef/destRef/ or s/srcRef/storageRef/ to not be confusing about the semantics of that value, please.


WRT requiring :latest to exist:

Well, it’s a breaking change AFAICS; this used to work. And forcing users to specify a tag would make reintroducing the “--all-tags with a tag is invalid” error another breaking change.

*shrug* I don’t quite understand the utility of --all-tags (let alone search+--all-tags together) in the first place, so I guess it is acceptable.

pull.go Outdated Show resolved Hide resolved
pull.go Show resolved Hide resolved
@@ -215,13 +222,10 @@ func pullImage(ctx context.Context, store storage.Store, imageName string, optio
spec := imageName
srcRef, err := alltransports.ParseImageName(spec)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The two callers of pullImage now explicitly know whether the input should be readable by ParseImageName or whether it needs the transport added (and using the other path can misinterpret the input); it would be nice to make this unambiguous.

pullAndFindImage AFAICS currently always submits input input with the “concatenate options.transport+imageName” format, while the AllTags path in Pull always submits input with the “use ParseImageName(imageName) semantics — so, the concatenation code could be moved to pullAndFindImage (or maybe even higher to resolveImage, and consolidated with the other part there), and pullImage could expect input in the ParseImageName format.

(This is a pre-existing situation, so non-blocking; the changes to ResolveName in this PR now allow making this unambiguous.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets handle this in a separate PR

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably e8d73b2) made this pull request unmergeable. Please resolve the merge conflicts.

util/util.go Outdated Show resolved Hide resolved
pull.go Outdated
options.ReportWriter = nil // Turns off logging output
boptions.ReportWriter = nil // Turns off logging output
}
srcRef, transport, img, err := resolveImage(ctx, systemContext, options.Store, boptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least, s/srcRef/destRef/ or s/srcRef/storageRef/ to not be confusing about the semantics of that value, please.


WRT requiring :latest to exist:

Well, it’s a breaking change AFAICS; this used to work. And forcing users to specify a tag would make reintroducing the “--all-tags with a tag is invalid” error another breaking change.

*shrug* I don’t quite understand the utility of --all-tags (let alone search+--all-tags together) in the first place, so I guess it is acceptable.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Please rename srcRef to not be misleading, that’s the last blocker for me.

The requirement to name an existing tag (or the default :latest) for --all-tags to work is problematic, but obscure enough, and it would require yet another non-trivial modification, that I can live with it.

if options.ReportWriter != nil {
options.ReportWriter.Write([]byte("Pulling " + name + "\n"))
}
ref, err := pullImage(ctx, options.Store, transport, name, options, systemContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:

For consistency with the pullAndFindImage caller, it would be nice if name here did not start with transport:

repoName := whateverSrcRefIsRenamedTo.DockerReference().Name()
srcRef, err := alltransports.ParseImageName(transport+repoName)
// or srcRef, err := c/image/docker.NewReference(srcRef.DockerReference())name = repoName + ":" + tag

or so.

Change references to Transfer to transfer to make it internal only.
It should be determined from the image specification and only determined
in one place.

Make buildah.Pull use registries.conf

Currently buildah pull does not resolve images based on registries.conf
This does not match the behaviour of buildah from or buildah bud

Signed-off-by: Daniel J Walsh <[email protected]>
Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Member Author

rhatdan commented Feb 20, 2019

@mtrmac Ready to merge. I will open another PR to further clean this up and eventually get it into podman and maybe add the functions to containers/image

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit ea5f858 has been approved by rhatdan

@mtrmac
Copy link
Contributor

mtrmac commented Feb 20, 2019

CK. Thanks!

@mtrmac
Copy link
Contributor

mtrmac commented Feb 20, 2019

ACK, that is.

rh-atomic-bot pushed a commit that referenced this pull request Feb 20, 2019
Signed-off-by: Daniel J Walsh <[email protected]>

Closes: #1319
Approved by: rhatdan
@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit ea5f858 with merge 3531a2d...

rh-atomic-bot pushed a commit that referenced this pull request Feb 20, 2019
Signed-off-by: Daniel J Walsh <[email protected]>

Closes: #1319
Approved by: rhatdan
rh-atomic-bot pushed a commit that referenced this pull request Feb 20, 2019
Signed-off-by: Daniel J Walsh <[email protected]>

Closes: #1319
Approved by: rhatdan
@rh-atomic-bot
Copy link
Collaborator

☀️ Test successful - status-papr, status-travis
Approved by: rhatdan
Pushing 3531a2d to master...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants