-
Notifications
You must be signed in to change notification settings - Fork 788
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
Conversation
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) |
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.
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
?
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.
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.
Fixes #1316 |
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. |
When an image is pulled, the imageID is not being printed with this patch as it had been prior.
|
Not only no imageId at the end, but no progress bars. |
Fixed imageid and progress problems. |
@TomSweeneyRedHat Could you merge this one. |
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. |
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. |
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. |
📌 Commit 73361eb has been approved by |
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
💔 Test failed - status-travis |
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 On a more conceptual level, does it even make much sense to So, maybe, at the highest level, there should be a separate OTOH doing that the easy way would cause |
(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.) |
@mtrmac @nalind I made the Transports private to the library to prevent the client passing in a transport different then the image. Transport=docker Also added OCI As a valid format. util.ResolveImage now returns the image name without the transport as well as the transport. |
6ce7646
to
19b3e8d
Compare
docs/buildah-pull.md
Outdated
@@ -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. |
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, s/path/path/
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.
Ugh love GitHub auto md sometimes
s/path/_path_/
@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 |
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.
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.
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 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.
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 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.
if len(arr) == 2 { | ||
if iopts.allTags { | ||
return errors.Errorf("tag can't be used with --all-tags") | ||
} |
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 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 .
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 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.
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) |
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.
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.
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 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.
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.
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.
@@ -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 { |
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.
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.)
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.
Lets handle this in a separate PR
☔ The latest upstream changes (presumably e8d73b2) made this pull request unmergeable. Please resolve the merge conflicts. |
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) |
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.
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.
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.
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) |
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.
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]>
Signed-off-by: Daniel J Walsh <[email protected]>
Signed-off-by: Daniel J Walsh <[email protected]>
@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 |
📌 Commit ea5f858 has been approved by |
CK. Thanks! |
ACK, that is. |
Signed-off-by: Daniel J Walsh <[email protected]> Closes: #1319 Approved by: rhatdan
Signed-off-by: Daniel J Walsh <[email protected]> Closes: #1319 Approved by: rhatdan
Signed-off-by: Daniel J Walsh <[email protected]> Closes: #1319 Approved by: rhatdan
☀️ Test successful - status-papr, status-travis |
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]