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

Add platform to manifest descriptor in metadata. #2993

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

cpuguy83
Copy link
Member

@cpuguy83 cpuguy83 commented Aug 1, 2022

This just make it simpler to determine the output image's platform.
Today we inject this into the metadata after the build (when we can)
which causes some headache in our build pipelines.

@tonistiigi
Copy link
Member

Doesn't this revert #1985 ?

@cpuguy83
Copy link
Member Author

cpuguy83 commented Aug 2, 2022

@tonistiigi As far as I can tell, there is no effect except that the descriptor returned includes the platform.
There's no change to the index or manifest at all, no change to results of pushes, no change to filesystem layout when exporting.

@@ -57,6 +57,13 @@ func (ic *ImageWriter) Commit(ctx context.Context, inp exporter.Source, sessionI
return nil, errors.Errorf("unable to export multiple refs, missing platforms mapping")
}

var p exptypes.Platforms
if ok {
if err := json.Unmarshal(platformsBytes, &p); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be backward compatible. The case is when new daemon(exporter) is used with an old frontend that doesn't set this key(because it is not exporting a manifest list).

Copy link
Member Author

Choose a reason for hiding this comment

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

Would a length check here satisfy this concern? It's already not doing this unmarshal if the metadata is missing entirely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to include that, also tested against some already released docker/dockerfile versions as the frontend, seems to be ok.

@@ -517,17 +517,22 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) {
return errors.Wrapf(err, "failed to marshal build info")
}

p := platforms.DefaultSpec()
Copy link
Member

Choose a reason for hiding this comment

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

Not new code but these need Normalize() calls as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added.

This just make it simpler to determine the output image's platform.
Today we inject this into the metadata after the build (when we can)
which causes some headache in our build pipelines.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@tonistiigi tonistiigi merged commit d7788f3 into moby:master Aug 8, 2022
@cpuguy83 cpuguy83 deleted the metadata_target_platform branch August 9, 2022 16:44
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.

None yet

2 participants