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

Fix manifest lists to always use correct size #1156

Merged
merged 1 commit into from
Jul 3, 2018

Conversation

dmcgowan
Copy link
Contributor

@dmcgowan dmcgowan commented Jun 29, 2018

Stores complete OCI descriptor instead of digest and platform fields. This includes the size which was getting lost by not storing the original manifest bytes.

Attempt to support existing cached files, if the original byte content cannot be retrieved output the filename with the incorrect content. This allows the user to remove the file and re-attempt to create their manifest list.

Note: I think before taking this out of experimental we should just update this tool to either use containerd or the content/image store from containerd.

Fixes #1135
Replaces #1144

ping @flx42 @clnperez

blobReqs = append(blobReqs, manifestBlob{canonical: canonical, os: imageManifest.Platform.OS})
var os string
if imageManifest.Descriptor.Platform != nil {
os = imageManifest.Descriptor.Platform.OS
Copy link
Member

Choose a reason for hiding this comment

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

nit: this would be better as requireMount bool

img := &Image{}
if err := json.Unmarshal(src, img); err != nil {
// PlatformFromJSON returns an OCI platform from formatted JSON bytes
func PlatformFromJSON(src []byte) (*ocispec.Platform, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: no need for this function if called only once

Stores complete OCI descriptor instead of digest and platform
fields. This includes the size which was getting lost by not
storing the original manifest bytes.

Attempt to support existing cached files, if not output
the filename with the incorrect content.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸

Copy link
Contributor

@clnperez clnperez left a comment

Choose a reason for hiding this comment

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

everything looks good and seem to work fine

@@ -195,7 +199,11 @@ func buildBlobRequestList(imageManifest types.ImageManifest, repoName reference.
if err != nil {
return nil, err
}
blobReqs = append(blobReqs, manifestBlob{canonical: canonical, os: imageManifest.Platform.OS})
var os string
if imageManifest.Descriptor.Platform != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is called after buildManifestList, this should never be nil

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

left some questions / notes, and saw there were some outstanding nits; I'm ok with doing those in a follow up though

LGTM

if imageManifest.Platform.Architecture == "" || imageManifest.Platform.OS == "" {
if imageManifest.Descriptor.Platform == nil ||
imageManifest.Descriptor.Platform.Architecture == "" ||
imageManifest.Descriptor.Platform.OS == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if this validation should be inside buildManifestDescriptor(), but I assume we can't move it there because that's also used by manifest inspect?

}

// Compatibility with image manifests created before
// descriptor, newer versions omit Digest and Platform
Copy link
Member

Choose a reason for hiding this comment

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

Compatibility here is only for the manifests created by earlier versions of docker manifest ("experimental") correct?

If so, we should probably add a TODO to remove this code at some point

}
}

// PlatformSpecFromOCI creates a platform spec from OCI platform
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we somehow can get rid of having both types (given that they're effectively the same)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the containerd code instead of the distribution code would effectively get rid of this.

@andrewhsu
Copy link
Contributor

cc @corbin-coleman

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.

7 participants