Skip to content

Add Container field to store client-defined data#1378

Merged
mlaventure merged 2 commits intocontainerd:masterfrom
cpuguy83:container_store_extra_data
Sep 18, 2017
Merged

Add Container field to store client-defined data#1378
mlaventure merged 2 commits intocontainerd:masterfrom
cpuguy83:container_store_extra_data

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

This field allows a client to store specialized information in the
container metadata rather than having to store this itself and keep
the data in sync with containerd.

@mlaventure
Copy link
Copy Markdown
Contributor

aren't labels sufficient for this?

@cpuguy83
Copy link
Copy Markdown
Member Author

I don't think map<string,string> would work well for this.

@stevvooe
Copy link
Copy Markdown
Member

I think extensions would be okay,

Comment thread api/next.pb.txt Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dmcgowan Any reason these weren't a part of the previous PR? Did we have a bad merge? Basically, it looks like we merged around the same time and missed fields.

@cpuguy83 I'm going to update these in a separate PR.

@Random-Liu
Copy link
Copy Markdown
Member

@cpuguy83 What kind of data in your mind could not put into label? Could you give an example? Thanks! :)

@cpuguy83
Copy link
Copy Markdown
Member Author

@cpuguy83
Copy link
Copy Markdown
Member Author

Mainly it allows us to store the spec that we created the container from (e.g. docker API) directly with the container in containerd rather than having this split up in multiple metadata stores.

@Random-Liu
Copy link
Copy Markdown
Member

Random-Liu commented Aug 18, 2017

@cpuguy83 In Kubernetes containerd integration, we also need to put stuff (CRI container config etc.) inside container metadata store. Currently our plan is to serialize them and put them inside a label. :p

Won't that work?

@cpuguy83
Copy link
Copy Markdown
Member Author

I would like to not lose type information, especially since we may (definitely) want to update this.
Serializing and throwing into a string field doesn't seem very elegant. Honestly I think I'd prefer to manage a separate store in that case.

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from 2b014cc to b8e8884 Compare August 18, 2017 00:42
@Random-Liu
Copy link
Copy Markdown
Member

Random-Liu commented Aug 18, 2017

I would like to not lose type information, especially since we may (definitely) want to update this.

@cpuguy83 Do you mean that you'll update it after creating container? Or the spec will be updated across releases?

Serializing and throwing into a string field doesn't seem very elegant. Honestly I think I'd prefer to manage a separate store in that case.

We were planning to do that because we don't have other options at that time. :) Actually this also benefits us.

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from b8e8884 to 84dc48a Compare August 18, 2017 00:51
@cpuguy83
Copy link
Copy Markdown
Member Author

@cpuguy83 Do you mean that you'll update it after creating container? Or the spec will be updated across version?

Between versions.

We were planning to do that because we don't have other options at that time. :) Actually this also benefits us.

👍 Totally it seems worth while to do something here to reduce the burden for implementers.

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch 2 times, most recently from 5fa1f4b to 761841c Compare August 18, 2017 00:56
@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from 761841c to e73cabb Compare August 18, 2017 13:19
@cpuguy83
Copy link
Copy Markdown
Member Author

Updated to use extensions.
Looks like the test suite timed out, though.

@mlaventure
Copy link
Copy Markdown
Contributor

It looks like there's a deadlock in the linux runtime, those 4 tests are stuck on a call to the task service:

  • TestContainerExecNoBinaryExists
  • TestContainerKill
  • TestUserNamespaces
  • TestContainerExec

@crosbymichael
Copy link
Copy Markdown
Member

Can you rebase on master to pick up the fix?

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from e73cabb to fe2af86 Compare August 18, 2017 20:58
@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 18, 2017

Codecov Report

Merging #1378 into master will increase coverage by 0.03%.
The diff coverage is 44.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1378      +/-   ##
==========================================
+ Coverage   40.82%   40.85%   +0.03%     
==========================================
  Files          23       23              
  Lines        2920     2964      +44     
==========================================
+ Hits         1192     1211      +19     
- Misses       1451     1466      +15     
- Partials      277      287      +10
Impacted Files Coverage Δ
metadata/buckets.go 46.66% <ø> (ø) ⬆️
metadata/containers.go 46.59% <44.44%> (-0.61%) ⬇️

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 52fbc5f...f7d31e2. Read the comment docs.

@cpuguy83
Copy link
Copy Markdown
Member Author

Would it make sense to have this for Image as well?

@mlaventure
Copy link
Copy Markdown
Contributor

This is missing the code in the metadata snapshotter to actually store the data in extension 😇

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from fe2af86 to 870efa3 Compare August 21, 2017 16:49
@cpuguy83
Copy link
Copy Markdown
Member Author

My mistake, assumed it was using the proto.
I've updated with I think everything that's needed, added a test for it.

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch 3 times, most recently from 283f8fc to 8c67de5 Compare August 21, 2017 17:04
Comment thread container_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you also add a a test where you load the container and check if the data is correctly sent back?

Also, don't forget to clean up after the test, this need a container.Delete() call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NOTE: just do it within that same test, no need for a new one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be repeated.

Comment thread container_opts.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Extension"

@stevvooe stevvooe modified the milestones: containerd beta, containerd 1.0.0 Sep 6, 2017
@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch 3 times, most recently from 55bd94d to 7e17e0b Compare September 7, 2017 14:00
@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Sep 7, 2017

Ok, this is updated.
Please take a look at how I'm encoding/decoding the []types.Any in the store.

Comment thread container_opts.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could this take an interface and we do the any marshal in the opt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from 7e17e0b to 94f9575 Compare September 7, 2017 16:07
Comment thread container_opts.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will require the urls to be registered with typeurl.Register unless they are proto messages. May want to specify so in the godoc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

This field allows a client to store specialized information in the
container metadata rather than having to store this itself and keep
the data in sync with containerd.

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the container_store_extra_data branch from 94f9575 to 3552ce5 Compare September 7, 2017 20:54
Comment thread container_opts.go
// Use this to decorate the container object with additional data for the client
// integration.
//
// Make sure to register the type of `extension` in the typeurl package via
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I should have been more clear 😅

If the url was not registered via typeurl.Register and the message doesn't implement protobuf/proto.Message this will error out :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably be able to support json here, as well.

@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Sep 7, 2017

I think this design is fine, but I'm worried that we are going to make it hard to manage updates that involve more than one extensions (I know, my fault for suggesting repeated... ;) ). The problem here is that one needs to read all the extensions, then make the modification for their extension, then send back all the extensions. This model will also allow for duplicates.

Would it be better to have a map where one can update only the extension they care about by specifying the key for the fieldpath? For example, you could update the extensions.docker fieldpath without affecting other extensions.

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Sep 7, 2017

I think a map is a good idea. It also lets us treat the extensions like fields and will be more straight forward to encode in the store.

@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Sep 8, 2017

Moved this to a map type. PTAL

@stevvooe stevvooe force-pushed the container_store_extra_data branch from c35e3c6 to eaf4140 Compare September 9, 2017 02:20
To allow for updating extensions without collisions, we have moved to
using a map type that can be explicitly selected via the field path for
updates. This ensures that multiple parties can operate on their
extensions without stepping on each other's toes or incurring an
inordinate number of round trips.

Signed-off-by: Stephen J Day <[email protected]>
@stevvooe stevvooe force-pushed the container_store_extra_data branch from eaf4140 to f7d31e2 Compare September 9, 2017 02:34
@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@Random-Liu
Copy link
Copy Markdown
Member

@crosbymichael @stevvooe Can we get this in before the end of September (our 1.0.0-alpha.0 release)? We want to switch to Extension before that to avoid backward compatibility issue in the future. :)

Copy link
Copy Markdown
Contributor

@mlaventure mlaventure left a comment

Choose a reason for hiding this comment

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

LGTM

@mlaventure mlaventure merged commit e517952 into containerd:master Sep 18, 2017
@cpuguy83 cpuguy83 deleted the container_store_extra_data branch September 18, 2017 14:37
@cpuguy83
Copy link
Copy Markdown
Member Author

Sweet, thanks for carrying this through!

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