Skip to content

Conversation

@JirkaChadima
Copy link
Contributor

This is part of an containers/skopeo#790 and improves the ChooseImage method so that it respects the variant field which is used on ARM architecture. It also exposes the VariantChoice to 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.

@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch from 90fbb2c to e39e4b4 Compare January 2, 2020 15:07
@rhatdan
Copy link
Member

rhatdan commented Jan 2, 2020

LGTM
But we need @mtrmac and @vrothberg to review.

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.

Thanks!

See the pre-existing discussion in #753, especially #753 (review) .

@JirkaChadima
Copy link
Contributor Author

Thanks for pointing out #753, I will check that out. Do you have any experience with GOARM? That might be used for default detection.

@mtrmac
Copy link
Collaborator

mtrmac commented Jan 3, 2020

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

@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch from e39e4b4 to 50c993c Compare January 6, 2020 10:02
@JirkaChadima
Copy link
Contributor Author

JirkaChadima commented Jan 6, 2020

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 /proc/cpuinfo. The whole approach is discussed in great detail in this presentation from ARM.

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.

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.

Thanks!

(Not a full review, just pointing out some structural aspects in the meantime.)

@JirkaChadima
Copy link
Contributor Author

One thing I'm still not sure about is copy.CheckImageDestinationForCurrentRuntime. What does it do exactly? I wasn't able to get the Variant field out from the Image so I have nothing to compare it to, but maybe I was just looking in the wrong place.

@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch 2 times, most recently from e04febb to 84e09f6 Compare January 7, 2020 11:29
@mtrmac
Copy link
Collaborator

mtrmac commented Jan 8, 2020

One thing I'm still not sure about is copy.CheckImageDestinationForCurrentRuntime. What does it do exactly?

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 podman pull ARM-only-image or podman pull Windows-only-image fail on an x86 Linux.

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.

I wasn't able to get the Variant field out from the Image so I have nothing to compare it to, but maybe I was just looking in the wrong place.

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.

@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch from 7f50fa8 to c361ecf Compare January 9, 2020 12:07
@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch from c361ecf to d9fdc58 Compare January 9, 2020 13:02
@JirkaChadima JirkaChadima force-pushed the feat-override-variant branch from d9fdc58 to fc304bb Compare January 9, 2020 14:08
@JirkaChadima
Copy link
Contributor Author

Until that lands (and images start using it), I suppose missing image variant has to be treated as “unknown, assumed compatible” in that code.

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.

@JirkaChadima
Copy link
Contributor Author

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!

@mtrmac
Copy link
Collaborator

mtrmac commented Jan 16, 2020

Don’t worry, the comment is perfectly fine; I’m afraid I just got busy with other work.

@mtrmac
Copy link
Collaborator

mtrmac commented Jan 23, 2020

FWIW there were a few user reports of broken user cases by the architecture check in checkImageDestinationForCurrentRuntime, so we are going to remove it again.

@rhatdan
Copy link
Member

rhatdan commented Jan 28, 2020

@mtrmac Whats the scoop on this one?

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.

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)
Copy link
Collaborator

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) {
Copy link
Collaborator

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)
Copy link
Collaborator

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.

@JirkaChadima
Copy link
Contributor Author

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

@mtrmac
Copy link
Collaborator

mtrmac commented Mar 17, 2020

Updated in #854. Thanks again!

@mtrmac mtrmac closed this Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants