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 pull image that includes a sha #1085

Closed
wants to merge 1 commit into from
Closed

Conversation

baude
Copy link
Member

@baude baude commented Jul 12, 2018

when pulling an image that includes a sha such as:

centos/nginx-112-centos7@sha256:42330f7f29ba1ad67819f4ff3ae2472f62de13a827a74736a5098728462212e7

the final image name in libpod should not contain portions of the sha itself nor the sha
identifier. and like docker, we provide a 'none' tag as well.

this should fix #877

Signed-off-by: baude [email protected]

@baude baude force-pushed the shapull branch 2 times, most recently from 9d90db4 to a1944cc Compare July 12, 2018 21:19
when pulling an image that includes a sha such as:

centos/nginx-112-centos7@sha256:42330f7f29ba1ad67819f4ff3ae2472f62de13a827a74736a5098728462212e7

the final image name in libpod should not contain portions of the sha itself nor the sha
identifier.  and like docker, we provide a 'none' tag as well.

this should fix containers#877

Signed-off-by: baude <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2018

Can you add some tests?

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2018

Might want to make this a second PR since we want to get this into the release today, if you don't have time.

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2018

Other then the tests, this LGTM

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2018

@mheon @giuseppe @mtrmac @umohnani8 PTAL

@baude
Copy link
Member Author

baude commented Jul 13, 2018

@rhatdan there is a good test already for non fully qualified image pull by sha.

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2018

Ok great.

@umohnani8
Copy link
Member

LGTM

@mheon
Copy link
Member

mheon commented Jul 13, 2018

LGTM
@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 5e08f8d has been approved by mheon

@rh-atomic-bot
Copy link
Collaborator

⚡ Test exempted: merge already tested.

@mtrmac
Copy link
Collaborator

mtrmac commented Jul 13, 2018

and like docker, we provide a 'none' tag as well.

Which part of Docker does that? I see

# docker pull alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30c6c93be117e430

Status: Downloaded newer image for docker.io/alpine@sha256:7043076348bf5040220df6ad703798fd8593a0918d06d3ce30c6c93be117e430
[root@f28 ~]# docker images
REPOSITORY          TAG                    IMAGE ID            CREATED             SIZE
docker.io/alpine    <none>                 11cd0b38bc3c        7 days ago          4.41 MB

where the <none> is a placeholder for “nothing”, not an actual tag value.

Copy link
Collaborator

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

Can this be revisited? I may be missing some wider context, but this adds quite a few confusing conditionals in places which should EDIT not need to care.

if i.HasShaInInputName() {
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, i.InputName)
} else {
imageName = decomposedImage.assembleWithTransport()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks horribly irregular. Why not teach imageParts to actually support digest references fully?

if err != nil {
return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName)
}
ps := pullStruct{
image: i.InputName,
srcRef: srcRef,
}
if i.HasShaInInputName() {
ps.shaPullName = decomposedImage.assemble()
Copy link
Collaborator

Choose a reason for hiding this comment

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

So, shaPullName actually means “a name which has no digest at all?! That’s very confusing.

@@ -33,6 +34,9 @@ func decompose(input string) (imageParts, error) {
}
if !isTagged {
tag = "latest"
if strings.Contains(input, "@sha256:") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why hard-code sha256 here and not support all digests? And the parse called just above already knows the information, no need to touch string contents at all:

if _, ok := imgRef.(reference.Digested); ok {

And, more importantly, reference.Parse accepts name:tag@digest input; so “has a digest” does not mean “does not have a tag”.

Overall, as I mentioned earlier , the tag = "none" behavior seems to have no precedent and seems entirely unnecessary to me.

srcRef, err := alltransports.ParseImageName(decomposedImage.assembleWithTransport())
imageName := decomposedImage.assembleWithTransport()
if i.HasShaInInputName() {
imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, i.InputName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are exactly two callers to assembleWithTransport, and both are now conditionalized with HasShaInInputName.

I think this very clearly shows that the digests should be the responsibility of the decompose().assembleWithTransport() function pair, and should be fixed in there instead of the callers fixing this up after them.

destRef, err := is.Transport.ParseStoreReference(i.imageruntime.store, pStruct.image)
dstName := pStruct.image
if pStruct.shaPullName != "" {
dstName = pStruct.shaPullName
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will cause the containers-storage: destination to not be marked with the digest. Why is that desirable?

@baude baude deleted the shapull branch December 22, 2019 19:12
@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 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

pulling image via SHA results in problems
6 participants