-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support OS version in platform string #5614
Conversation
688785a
to
171ad5b
Compare
a881f71
to
33ecd88
Compare
@cpuguy83 Added this to v0.19 , RC planned for 01/10 |
1646474
to
212a947
Compare
Upstreaming those vendor changes at containerd/platforms#22 |
212a947
to
3713196
Compare
71274ac
to
eadb841
Compare
I have updated this to use the new containerd/platforms module version which made the platform matchers for Windows available on non-Windows platforms so that the test can do the version comparisons. This should be ready for a full review. |
Short: []byte(fmt.Sprintf("Requested platform %q does not match result platform %q", req.Platforms[0], platforms.Format(pp))), | ||
}}, nil | ||
if _, ok := reqMap[platforms.FormatAll(pp)]; !ok { | ||
// The requested platform will often not have an OSVersion on it, but the |
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 was a little janky.
When the platform string is not exactly what was requested (i.e. no OS version) then the returned result which has the OS Version will trigger a warning.
eadb841
to
357fa67
Compare
Looks like linter test is failing now with updated platforms package. |
Error message change
|
357fa67
to
db512d6
Compare
|
||
dockerfile := []byte(` | ||
ARG TARGETOS TARGETOSVERSION TARGETARCH | ||
FROM --platform=${TARGETOS}(${TARGETOSVERSION})/${TARGETARCH} ` + target + ` AS reg |
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 platform flag in here shouldn't be needed for functionality as the default should work the same. FROM --platform=$TARGETPLATFORM
should also work the same.
If you want to check that the parser works in these cases then maybe add other stages for different variants (reg1, reg2, reg3) and build all in a loop.
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.
Your right no need for setting anything here.
Since you brought it up, I did not change TARGETPLATFORM
or BUILDPLATFORM
to use FormatAll
for fear of breaking things.
I guess TARGETPLATFORM
shouldn't be a big deal since it'd just be what the user specified.
BUILDPLATFORM
would be different... at least on Windows... which maybe isn't a big deal since its experimental?
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.
Yeah, I think TARGETPLATFORM
is fine. BUILDPLATFORM
maybe indeed shouldn't set OSVersion
. This would be different if there would be "default" osversion and different DefaultSpec()
and MaximumSpec()
. Eg. in linux/amd64
, DefaultSpec()
variant is always v1
, doesn't matter if the machine actually supports higher versions. In OSVersion
this concept doesn't seem to exist and it goes to syscall https://github.com/containerd/platforms/blob/main/defaults_windows.go#L29C33-L29C55 . It's possible we need to define our own DefaultSpec
in the follow-up.
|
||
dt, err = os.ReadFile(filepath.Join(destDir, "osversion")) | ||
require.NoError(t, err) | ||
require.Equal(t, p2.OSVersion+"\n", string(dt)) |
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.
Should we check that the correct OSVersion
is set in the image config, or is this already covered somewhere?
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.
As a note: We discussed this on Slack and will follow-up with this after merge.
@cpuguy83 Containerd v2 was merged so this needs rebase for the platforms pkg vendor. |
This allows platforms following the new `platforms.FormatAll` function, which allows for setting the `OSVersion` field of the platform with `<os>(<ver>)/<arch>`. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
db512d6
to
94ddeb7
Compare
This allows platforms following the new
platforms.FormatAll
function, which allows for setting theOSVersion
field of the platform with<os>(<ver>)/<arch>
.Closes #5115
Note: In order to make
FROM <img>
match the correct OS version with the new platform format some changes need to be made to containerd/platforms (see vendor/ changes).