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

ostree, src: support copy of compressed layers #392

Merged
merged 5 commits into from
Feb 22, 2018

Conversation

giuseppe
Copy link
Member

add implementation for LayerInfosForCopy so we can provide a modified manifest to be used for copy

@runcom
Copy link
Member

runcom commented Dec 15, 2017

Looks ok, @mtrmac wdyt?

@giuseppe
Copy link
Member Author

ping

@giuseppe
Copy link
Member Author

cc @nalind

@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch 2 times, most recently from 5987770 to 5f2b693 Compare January 15, 2018 09:51
digester := digest.Canonical.Digester()
tee := io.TeeReader(its, digester.Hash())

written, err := io.Copy(ioutil.Discard, tee)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn’t this basically io.Copy(digester, its)?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct, thanks for finding it. Fixed it in a newer version

}

var schema manifestSchema
if err := json.Unmarshal(manifestBlob, &schema); err != nil {
Copy link
Collaborator

@mtrmac mtrmac Jan 16, 2018

Choose a reason for hiding this comment

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

Please use the containers/image/manifest package (manifest.FromBlob), both for manifest types and for manifest parsing.

This doesn't work as expected because LayersDescriptors and FSLayers list layers in the opposite directions; besides, the manifestSchema franken-type containing a subset of both schema1 and schema2, and undocumented, is pretty surprising.

Copy link
Member Author

Choose a reason for hiding this comment

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

missed this comment in the last revision. Going to address it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

done now

ref ostreeReference
tmpDir string
repo *C.struct_OstreeRepo
compressed map[digest.Digest]digest.Digest
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please at least add a comment here saying what is the key and what is the value of the map. (Ideally the field name would be self-explanatory, but that seems difficult.)

blob := info.Digest.Hex()
compressedBlob, found := s.compressed[info.Digest]
Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s not in general guaranteed that LayerInfosForCopy will be called before GetBlob; if GetBlob depends on this map, it may need to build it on demand.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, I've modified it to check if compressed is initialized, and use LayerInfosForCopy when it is nil

@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch 7 times, most recently from 5790ef7 to 961bfca Compare January 19, 2018 12:54
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.

LGTM otherwise.

MediaType: layerBlob.MediaType,
}
s.compressed[uncompressedDigest] = layerBlob.Digest
updatedBlobInfos = append([]types.BlobInfo{blobInfo}, updatedBlobInfos...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

LayerInfosForCopy should return layers in the order of man.LayerInfos, not reversed.

updatedBlobInfos := []types.BlobInfo{}
manifestBlob, manifestType, err := s.GetManifest(nil)
if err != nil {
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about some other cases, but at least in this one it seems clear that err shouldn’t be thrown away; can you add an error return value to LayerInfosForCopy?

Copy link
Member Author

@giuseppe giuseppe Jan 20, 2018

Choose a reason for hiding this comment

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

this is the signature from the ImageSource interface. The only user of this function in ostree_src is GetBlob and I handle there the nil return, which is considered an error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right; please change the interface. c/i/copy/imageCopier.copyLayers should be able to tell the difference between “no changes needed” and “reading manifest failed” / ”manifest invalid”.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've pushed a new change to change the interface

@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch 8 times, most recently from 975896a to d80ea35 Compare January 23, 2018 14:38
uncompressedSize, err := strconv.ParseInt(uncompressedSizeStr, 10, 64)
if err != nil {
return nil, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it reasonable to ignore the above errors? At least the last one seems potentially worth failing on.

Up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, I've changed that to return an error. Also, I have added a patch that will trigger the layer to be pulled if this metadata is missing.

@@ -177,18 +177,18 @@ func (s *storageImageSource) GetManifest(instanceDigest *digest.Digest) (manifes

// LayerInfosForCopy() returns the list of layer blobs that make up the root filesystem of
// the image, after they've been decompressed.
func (s *storageImageSource) LayerInfosForCopy() []types.BlobInfo {
func (s *storageImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

At least some of the errors in here should probably cause copy.Image to fail.

Cc: @nalind

Copy link
Member Author

Choose a reason for hiding this comment

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

I preferred to not touch this part as I am not really familiar with it. I can change it if it is required for this PR

Copy link
Member

Choose a reason for hiding this comment

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

Generally, if storageImageSource.LayerInfosForCopy() is returning nil, the copy attempt is going to fail later on when the digests don't match, since I think the majority of images use compressed layers. So yeah, pretty much anywhere we return nil from there, we should start returning the error value that caused us to do so.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a patch that changes LayerInfosForCopy in storage/storage_image.go to propagate the errors.

@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch from d80ea35 to 0d3a4d0 Compare January 24, 2018 08:53
@mtrmac
Copy link
Collaborator

mtrmac commented Jan 24, 2018

Thanks!

LGTM, will wait a bit to give @nalind time to comment on storageImageSource.LayerInfosForCopy

Approved with PullApprove

@mtrmac
Copy link
Collaborator

mtrmac commented Jan 26, 2018

👍 for the record; let’s at least track storageImageSource.LayerInfosForCopy in an issue.

@rhatdan
Copy link
Member

rhatdan commented Jan 29, 2018

@runcom PTAL

@runcom
Copy link
Member

runcom commented Jan 30, 2018

@runcom PTAL

I'm waiting on #392 (comment)

@giuseppe
Copy link
Member Author

giuseppe commented Feb 1, 2018

I took care of the last comment I got on this PR

@rhatdan
Copy link
Member

rhatdan commented Feb 2, 2018

@runcom PTAL

@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch from 0f47cc9 to 1562f1c Compare February 6, 2018 10:24
@giuseppe
Copy link
Member Author

giuseppe commented Feb 6, 2018

rebased ⬆️

we will use it later for LayerInfosForCopy

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
it enables the copy of compressed images.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe giuseppe force-pushed the ostree-support-copy-layer-infos branch from a4df631 to 755cd3f Compare February 21, 2018 12:03
@giuseppe
Copy link
Member Author

rebased again. Could we please move this forward?

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 21, 2018

@runcom ping

@runcom
Copy link
Member

runcom commented Feb 22, 2018

LGTM

Approved with PullApprove

@runcom runcom merged commit b44c527 into containers:master Feb 22, 2018
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.

5 participants