-
Notifications
You must be signed in to change notification settings - Fork 395
Adds the possibility to choose the image by the variant field in a manifest #786
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
Adds the possibility to choose the image by the variant field in a manifest #786
Conversation
4676ebe to
90fbb2c
Compare
90fbb2c to
e39e4b4
Compare
|
LGTM |
mtrmac
left a comment
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!
See the pre-existing discussion in #753, especially #753 (review) .
|
#753 does point at some pre-existing implementations; at this point, I’m happy to defer to ARM experts as long as the proposed mechanism is not excessively invasive and minimally plausible. We can always improve on the detection if there is interest. |
e39e4b4 to
50c993c
Compare
|
I did some digging around. The GOARM seems to be primarily used when compiling GO programs and is a little controversial, so I would not use it at all, the support table refers to the ability to compile GO programs for those architectures/variants. And from my tests on RPi, it is not even a public property during runtime. The go to option seems to be the parsing of So I'm going to try to port the containerd code while taking a look into moby/moby as well. This is apparently not an easy problem. |
mtrmac
left a comment
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!
(Not a full review, just pointing out some structural aspects in the meantime.)
|
One thing I'm still not sure about is |
e04febb to
84e09f6
Compare
This exists so that copies of images that are intended to be run (e.g. “pulls” from remote registries to the local filesystem, as opposed to copies of images from one registry to another, without intending to directly run the image) fail early, i.e. that Without this check, it’s perfectly possible to download images and extract them to a filesystem, it would only be running containers from such images that would fail. This allows alerting the user to this earlier, when it’s easy to detect and it can avoid costly/long pulls of unusable data.
Indeed; see opencontainers/image-spec#777 . Until that lands (and images start using it), I suppose missing image variant has to be treated as “unknown, assumed compatible” in that code. |
7f50fa8 to
c361ecf
Compare
…nifest Signed-off-by: Jirka Chadima <[email protected]>
Largely based on https://github.com/moby/moby/blob/bc846d2e8fe5538220e0c31e9d0e8446f6fbc022/distribution/cpuinfo_unix.go https://github.com/containerd/containerd/blob/726dcaea50883e51b2ec6db13caff0e7936b711d/platforms/cpuinfo.go Signed-off-by: Jirka Chadima <[email protected]>
…ate image Signed-off-by: Jirka Chadima <[email protected]>
Signed-off-by: Jirka Chadima <[email protected]>
Signed-off-by: Jirka Chadima <[email protected]>
Signed-off-by: Jirka Chadima <[email protected]>
c361ecf to
d9fdc58
Compare
Signed-off-by: Jirka Chadima <[email protected]>
d9fdc58 to
fc304bb
Compare
I've added the code, but it's commented out. I'm not sure if there is another way in a typed language. Otherwise I think it's doing what it should be and I've hopefully addressed all of the (very helpful!) remarks. I'm pretty sure there is still some code that's not very go-like, so let me know what to change. Thanks for your feedback, it's great to contribute to a project with such kind and welcoming maintainers. |
|
I'm sorry if my last comment sounded definitive. Is there anything else I can do to push this closer to being merged? If not, is there any kind of timeline for this being merged and/or released? Thanks! |
|
Don’t worry, the comment is perfectly fine; I’m afraid I just got busy with other work. |
|
FWIW there were a few user reports of broken user cases by the architecture check in |
|
@mtrmac Whats the scoop on this one? |
mtrmac
left a comment
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’m sorry it took so long to get back to you.
Do you want to update this, or shall I take the work over and finish it?
| } | ||
| } | ||
| return "", fmt.Errorf("no image found in image index for architecture %s, OS %s", wantedArch, wantedOS) | ||
| return "", fmt.Errorf("no image found in manifest list for architecture %s, variant %s, OS %s", wantedPlatforms[0].Architecture, wantedPlatforms[0].Variant, wantedPlatforms[0].OS) |
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.
“image index” is the OCI terminology, and should be preserved.
| // Returns all compatible platforms with the platform specifics possibly overriden by user, | ||
| // the most compatible platform is first. | ||
| // If some option (arch, os, variant) is not present, a value from current platform is detected. | ||
| func WantedPlatforms(ctx *types.SystemContext) ([]imgspecv1.Platform, 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.
Non-blocking: This can currently never fail, and it’s an internal API. The error return value could be dropped, which would simplify callers a bit.
| return fmt.Errorf("Image operating system mismatch: image uses %q, expecting %q", c.OS, wantedPlatform.OS) | ||
| } | ||
| if wantedPlatform.Architecture != c.Architecture { | ||
| return fmt.Errorf("Image architecture mismatch: image uses %q, expecting %q", c.Architecture, wantedPlatform.Architecture) |
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 now needs to just use logrus.Infof instead of failing.
|
@mtrmac I think it would be more efficient if you take over. I don't remember much about this anymore TBH. And I wasn't following any other changes here, so I'm totally out of context anyway. |
|
Updated in #854. Thanks again! |
This is part of an containers/skopeo#790 and improves the
ChooseImagemethod so that it respects thevariantfield which is used on ARM architecture. It also exposes theVariantChoiceto the outside world, so it can be passed as a command line argument.I'm not a Golang person, so it might be a little rusty. I intentionally kept the original behaviour that when there is no match for Variant, the first record matching the platform and architecture is returned. It might be more transparent to fail in that case though.