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

dockerfile: maintain osversion/variant from the base image #5714

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

tonistiigi
Copy link
Member

Restores the behavior from v0.12.

fix #5713

@TBBle @cpuguy83

Signef-off-by: Tonis Tiigi [email protected]

}
if platformOpt.targetPlatform.OSVersion != "" || !sameOsArch {
target.image.OSVersion = platformOpt.targetPlatform.OSVersion
}
if platformOpt.targetPlatform.OSFeatures != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

This OSFeatures line doesn't make much sense to me either as it can create duplicates and if !sameOsArch then probably should not be merged. Shouldn't be impactful as OSFeatures can't be passed via opt atm. but that will change. I opened containerd/platforms#23 as I think some of it should be handled in upstream platforms pkg.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't merging the OSFeatures, it's replacing them, so I don't understand where duplicates would come from? It should just be a straight-up copy of platformOpt.targetPlatform.OSFeatures.

It probably should have had the same !sameOsArch check added though. Not particularly impactful, last time I looked into it, OSFeatures was 100% unused and the OCI Working Group that might want it for future use didn't seem interested in it, in favour of a separate artifact that covered its use-cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't merging the OSFeatures, it's replacing them

Ah, yeah. I guess I looked that it was appending to the old OSFeatures, but it is appending to empty array (slices.Clone)

Copy link
Collaborator

@TBBle TBBle Feb 19, 2025

Choose a reason for hiding this comment

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

Yeah, I had to open-code slices.Clone in the original PR because it wasn't available until Go 1.21 and we were declaring Go 1.20 as supported at that time.

That's no longer the case so we could clean that up for readability now.

Restores the behavior from v0.12.

Signed-off-by: Tonis Tiigi <[email protected]>
@tonistiigi tonistiigi added this to the v0.20.0 milestone Feb 11, 2025
target.image.OS = platformOpt.targetPlatform.OS
target.image.Architecture = platformOpt.targetPlatform.Architecture
target.image.Variant = platformOpt.targetPlatform.Variant
target.image.OSVersion = platformOpt.targetPlatform.OSVersion
if platformOpt.targetPlatform.Variant != "" || !sameOsArch {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure i understand the sameOsArch check here.
Also the test does not cover it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The meaning of this section seems to be that if explicit platform was set then it rewrites the one in the loaded base image. I guess it is mainly related to the case where single arch image is loaded with FROM even if it is for a wrong arch. I don't set the variant/osversion in this case to avoid cases where --platform linux/* build would get osversion(or wrong variant) from the base image.

@tonistiigi tonistiigi merged commit f418abb into moby:master Feb 11, 2025
104 checks passed
Copy link
Collaborator

@TBBle TBBle left a comment

Choose a reason for hiding this comment

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

I apologise for the late response, but the change makes sense to me. This was working before #4387 by default, as these two fields were unconditionally inherited from the base, so this fix, including the sameOSArch check, seems fine to me.

}
if platformOpt.targetPlatform.OSVersion != "" || !sameOsArch {
target.image.OSVersion = platformOpt.targetPlatform.OSVersion
}
if platformOpt.targetPlatform.OSFeatures != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't merging the OSFeatures, it's replacing them, so I don't understand where duplicates would come from? It should just be a straight-up copy of platformOpt.targetPlatform.OSFeatures.

It probably should have had the same !sameOsArch check added though. Not particularly impactful, last time I looked into it, OSFeatures was 100% unused and the OCI Working Group that might want it for future use didn't seem interested in it, in favour of a separate artifact that covered its use-cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[regression] OS.Version is not propagated from base image
4 participants