Skip to content

Add missing annotations map to Descriptor for gRPC transfer#3000

Merged
crosbymichael merged 6 commits intocontainerd:masterfrom
stefanberger:descriptor_annotations.pr
Mar 22, 2019
Merged

Add missing annotations map to Descriptor for gRPC transfer#3000
crosbymichael merged 6 commits intocontainerd:masterfrom
stefanberger:descriptor_annotations.pr

Conversation

@stefanberger
Copy link
Contributor

@stefanberger stefanberger commented Feb 11, 2019

Add the annotations map to the gRPC Descriptor message.

For the container image encryption we intend to use the annotations map to temporarily store the image decryption parameters ('dcparameters'), which are primarily keys, in form of a JSON document under the map key '_dcparameters', and pass them to the applier's Apply() method. This helps us to access decryption keys and start the pipeline with the layer decryption before the layer data are unzipped and untarred. This map key '_dcparameters' will be removed from the annotations map. Using this 'trick' we avoid having to extend the Apply() method's signature with another parameter.

Signed-off-by: Stefan Berger stefanb@linux.ibm.com
Signed-off-by: Brandon Lum lumjjb@gmail.com
Signed-off-by: Harshal Patil harshal.patil@in.ibm.com

@codecov-io
Copy link

codecov-io commented Feb 12, 2019

Codecov Report

Merging #3000 into master will increase coverage by <.01%.
The diff coverage is 43.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3000      +/-   ##
==========================================
+ Coverage   43.54%   43.54%   +<.01%     
==========================================
  Files         103      103              
  Lines       11015    11031      +16     
==========================================
+ Hits         4796     4803       +7     
- Misses       5483     5489       +6     
- Partials      736      739       +3
Flag Coverage Δ
#linux 47.53% <53.84%> (ø) ⬆️
#windows 40.37% <43.75%> (ø) ⬆️
Impacted Files Coverage Δ
metadata/images.go 57.57% <43.75%> (-0.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa328df...09cf2a6. Read the comment docs.

@stefanberger
Copy link
Contributor Author

@justincormack @dmcgowan

Copy link
Member

Choose a reason for hiding this comment

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

This is very minor but I think annotations should be 5 to match the OCI Descriptor object which has URLs as the 4th type. We don't need to add URLs now but if we do in the future it would be nice if the structures were ordered similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted.

@dmcgowan
Copy link
Member

I agree we should add this to the API now to be more consistent with descriptor type used on the client and server, @stevvooe wdyt?

@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from 35543b0 to b2979cb Compare February 27, 2019 15:40
Add the annotations map to the gRPC Descriptor message.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
Signed-off-by: Harshal Patil <harshal.patil@in.ibm.com>
@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from b2979cb to c6703d4 Compare February 27, 2019 15:41
Copy link
Member

@stevvooe stevvooe left a comment

Choose a reason for hiding this comment

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

LGTM

We probably need some tests to make sure the field is stored properly.

@stevvooe
Copy link
Member

stevvooe commented Mar 6, 2019

Revoking my lgtm.

Turns out, the intent is not to store this field and they just want to stuff data here to feed diff options. Please don’t add fields that only hit your use case, leaving others to clean up your mess later.

If you want options on a diff call, add them to that specific endpoint.

If you want to add this field correctly, please update the pr.

Copy link
Member

@stevvooe stevvooe left a comment

Choose a reason for hiding this comment

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

See comment above.

Make sure that the newly added annotations are copied around appropriately.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from fc459eb to 0b711d6 Compare March 6, 2019 17:26
@stefanberger
Copy link
Contributor Author

@stevvooe Added a patch: 0b711d6

@stevvooe
Copy link
Member

stevvooe commented Mar 6, 2019

@stefanberger do we have a few tests to make sure this is being propagated to the image store?

@stefanberger
Copy link
Contributor Author

[00:13:28] --- FAIL: TestImagePull (12.04s)
[00:13:28]     client_test.go:208: failed to resolve reference "docker.io/microsoft/nanoserver:latest": failed to do request: Head https://registry-1.docker.io/v2/microsoft/nanoserver/manifests/latest: dial tcp: lookup registry-1.docker.io: no such host

@stefanberger
Copy link
Contributor Author

@stevvooe Should be possible to extend some existing tests with annotations ... let me see.

@stefanberger
Copy link
Contributor Author

@stevvooe Would content/local/store_test.go the right file to add a test case to ?

@stevvooe
Copy link
Member

stevvooe commented Mar 6, 2019

@stefanberger I don't think we use descriptors on the content store. content.Info is a different datastructure from descriptor. A descriptor identifies and annotates the content in an OCI image, where as the content.Info is just basic sizing and labeling. I think it would be best to start in https://github.com/containerd/containerd/blob/master/metadata/images_test.go. From there, I would also checkout any where github.com/containerd/containerd/api/types/descriptor.proto is used (github search or a grep would be fine: https://github.com/containerd/containerd/search?q=github.com%2Fcontainerd%2Fcontainerd%2Fapi%2Ftypes%2Fdescriptor.proto&unscoped_q=github.com%2Fcontainerd%2Fcontainerd%2Fapi%2Ftypes%2Fdescriptor.proto).

@stefanberger
Copy link
Contributor Author

@stevvooe What is a valid test case? Do any existing images have Annotations that we can read back? Or just create a ocispec.Descriptor{} with an Annotations field and write the JSON into the store and read it back after?

import_test.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

checkManifest is just for quick validation of the manifest. If you want to compare it with something, construct an "expected" manifest and compare the results.

@stevvooe
Copy link
Member

stevvooe commented Mar 6, 2019

@stefanberger I would recommend reading through the test cases and identifying areas where we would expect it to round trip, making sure that the value is correct. Yes, just put data on the Annotations field and make sure its not corrupted when landing in the database. Also, make sure that the field path is working correctly, so we can list images by annotation.

@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from 2725140 to 194635a Compare March 6, 2019 21:58
Make sure that Annotations we write into ocispec.Descriptors are
written into the store and can be read back.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from 194635a to 79248fe Compare March 6, 2019 22:00
@stefanberger
Copy link
Contributor Author

@stevvooe What is 'field path' and which command is relevant for listing images by annotation?

Refactor the code so that another function can also read and write maps
into the bolt db.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger
Copy link
Contributor Author

@stevvooe Please have a look at the patches I just added. Also, I am not sure whether fieldpaths are now sufficiently support with just these changes?

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
@stefanberger stefanberger force-pushed the descriptor_annotations.pr branch from f6e15d5 to 09cf2a6 Compare March 7, 2019 19:22
@stevvooe
Copy link
Member

LGTM

I think this mostly hits everything required to add this field but need a second set of eyes to ensure its consistent with other image fields.

As for the approach for adding encryption parameters, after some thought, it would be best to add key id and other public parameters on this descriptor, that will become part of the image store. For the private key, however, that should come through as an option which is dumped after use. We don't want to risk storing an encryption key in the containerd database or logs.

@crosbymichael
Copy link
Member

LGTM

@crosbymichael crosbymichael merged commit 9b882c4 into containerd:master Mar 22, 2019
@jcordasc
Copy link

Just ran into this as well. Any chance this (and #3121) could be considered for backport to 1.2.x? I'd be happy to put together the PR if so.

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.

6 participants