Proposal: Add label support to update command#18958
Proposal: Add label support to update command#18958vdemeester wants to merge 2 commits intomoby:masterfrom
Conversation
2e8c90f to
5b703b3
Compare
|
I like the current design. I think that if the label does not exist it should create it but updating one label should not be allowed to remove others. However adding the option to remove and not have an option to add would be a bit confusing, at least for me. |
|
Some quick thoughts;
I think eventually we should support that. I can imagine some system generating the label files, and the user wants to update the container accordingly. Should a label-file automatically replace all existing labels?
I'm for add/remove labels. I think Removing is more tricky, I'm not sure I like
I think we should do that client-side, and only send to the server what it needs to "set". i.e., server-side it's always a replace of all existing labels. Obviously, this could lead to a race condition if the data that the client is using is out of date (e.g. the container has been updated in the mean time). Not sure we should be worrying about that though.
That's what I had in mind, yes. As you described, the "Config" labels are what's in the image, and the "RunConfig" is what is set/overridden at runtime. Just my 0.02c though :-) |
|
Note that moving the labels to |
|
Is docker going to emit an event on a (label) update? |
|
@rade the current |
It does? I was looking at #15078 and couldn't find any changes to events. e.g. https://github.com/docker/docker/blob/master/docs/reference/commandline/events.md hasn't been touched. |
|
If I restart the machine, is the label still there? |
|
@hacpai that's part of the design review and process to decide if it will or not yeah 😉. |
Surely the answer is the same as for resource configs (the only other setting that |
I think it should be persisted, yes; just like we do for updating resources. |
bbac900 to
5f67732
Compare
|
Ping @vdemeester @thaJeztah: this seems terribly stalled... What are the next steps? |
|
@icecrime I need to rebase it and then we should first see if UX wise the proposition make sence, i.e. Current design is : $ docker inspect --format="{{json .Config.Labels}}" d61
{}
$ docker update --add-label=foo=bar --add-label=bar=foo d61
d61
$ docker inspect --format="{{json .Config.Labels}}" d61
{"bar":"foo","foo":"bar"}
$ docker update --remove-label=bar d61
d61
$ docker inspect --format="{{json .Config.Labels}}" d61
{"foo":"bar"}It is possible to do From there, I'll make a PR in engine-api and things will follow :wink: |
|
Just discussed with @tiborvass - we should decide what happens if you commit the container; should the old labels be used, or the new labels? Given that there's |
|
@thaJeztah oh good point. On the first though I would also think it should not be commited, as the |
|
@vdemeester true, so the "config" labels are copied to "runconfig", and those are the ones we modify, right? And "config" is never changed, so committing will not save those changes. |
|
@thaJeztah not in the current naive implementation, but ideally (and in the end) that would be the case 😉. |
02e0d7e to
1b68398
Compare
|
Agree with @bboreham and @astrostl. The ability to set metadata on the container allows tools working along Docker to function yet still keep Docker at the center for the "source of truth". As @astrostl said, you could have a separate datastore for this but keeping in sync is not trivial and does not play well with other systems. |
b24685d to
a5ed20d
Compare
|
I've update the PR according to some decision (on the cli side): Client side, flags are API side, it's just a new On the daemon side, I do agree with @cpuguy83, it's confusing to have $ docker run -itd --label foo=bar --name ohmylabel busybox top
$ docker commit ohmylabel myimage
$ docker inspect --format "{{ json .Config.Labels }}" myimage
{"foo":"bar"}
$ docker inspect --format "{{ json .Config.Labels }}" myimage
{"foo":"bar"}I think it would make sense (and consistent) for with an So for now, it is updating Note this design is probably the most simpler to implement (no changes in other commands, less potential side effects) too. 🐸 |
|
Is there a PR for the CLI changes? |
|
Cli, and daemon side 😉 (api changes ar on docker-archive-public/docker.engine-api#129) |
DO NOT MERGE WITH THIS Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
a5ed20d to
8e1e5ea
Compare
Just to be clear, the |
|
So one blocker on this PR is the fact that labels are not container-specific and we should take the pain of making sure the UX for updating labels is universal across labelable resources. Please read my comment about update label UX: #20356 (comment) (which turned out to be out of scope for that issue, but it's relevant for the discussion in this PR) Until we can figure out the right UX this PR is kind-of blocked :( |
|
@tiborvass yep, I'll close for now I think :-) |
|
Blocked tickets are closed as a matter of practice here? |
|
@astrostl Let say that I'm not keeping my PR open as it has become outdate, given the changes in the code since the last time and given the fact that now labels are available for other objects and thus this might need an overall rethink. I've opened an issue to discuss it (here : #21721), but no matter what, this PR is stalled and outdated, thus I prefer to close it 😉 |
|
@dnephin I can immagine a lot of use cases focused into interoperability between containers. Probably it can be the foundation to implement features similar to kubernetes replication controllers. rolling updates behind a load-balancerImagine loadbalancer is https://github.com/docker/dockercloud-haproxy but in addition it can dynamically include/exclude containers depending on the presence of a label, say Graceful update can be achieved as follows:
Keep alive a number of containers across all clusterOn scaling a container all the containers of the same service can be marked with the desired replica number. Ie. running: docker-compose scale web=2 may cause all the containers for service web to be tagged with `replicas=2`` A supervisor can then monitor the cluster and ensure that exactly 2 instances of the service are always running. Thanks. |
Now that we have the
updatecommand that allow us to update resources of already created containers (see #15078), the second use case we saw and hear about were about labels. 🐠This adds support for labels on the
updatecommand. It's not mergeable for now as a PR is needed inengine-apiif we agree on the API changes.Current design and ideas 🐟
Support
--labeland--label-fileas theruncommand. The API (changes) are thus kept pretty simple.On the daemon side, the labels updated are on
Config, this means the updated labels will be commited whendocker commitis called – which I'm not sure we want.Config(simple, obvious) orHostConfig(trickier and way more changes – on ps filters and such for example).For archive :
Discussions 🐚
There is three part to discuss on this proposal : the
cliside, theapiside and the behind the scene side.CLI
label-fileas we do onrun? (it might be too quick to think of that but…) — I think we should not (at first), if there is a need for it, we can add it later.--add-label=foo=barand--remove-label=foo.--update-label=+foo=bar,--update-label=-foo.--remove-label=idontexists), should it fail or just put a warning (or even nothing at all) ?API
The current
updateimplementation sends theHostConfigstruct as body ; Labels are currently inConfigstruct (see "Behind the Scene").- Would we sendConfigandHostConfiglike it's done with this naive implementation (usingconfigWrapperfrom thecreatecommand) ?- Or should we just send the map ofLabels? That would mean we should only send theResourcesinstead ofHostConfigtoo (might need to be done in another PR, see issue #18957).- Do we want to merge the labels client-side or server-side ? This will have impact on what we are sending — it's going to be a little complicated to useConfigto send labels if we want to do the merge server-side.I would definitely vote for merging labels server-side and not usingHostConfigorConfigstruct on the client side, but more specific sturct (otherwise we are opening the pandora box big time).Behind the Scene 🐙
This is probably where we need to discuss the most. The
updatecommand currently only updatesResourcesthat are onHostConfig. The idea behind it is,updateis currently only allowed to update stuff that are inResources(meaning onlycgroupsright now).For
Labelsit's a little different and maybe a little bit trickier :Labelsare in theConfigstruct, which is something we were thinking as immutable when we discuss #15078.LabelstoHostConfig? It feels a little weird, becauseConfig"should hold only portable information about the container" andHostConfig"should hold the non-portable Config structure of a container" — so it makes sence to haveLabelsinConfig; they are portable.LabelstoHostConfigat start/creation and update those ones ? It also feels a little bit weird, we would have twoLabelsoninspect, and they could differ… plus, does it make sence to keep the labels that were set at creation ? If they comes from the images, then they are still there and immutable there so it's somehow possible to track back which one were there at start.Config.Labelslike currently done on this PR or should we have someMutableConfigsturct to hold stuff we can change ? (and then, shouldResourcesbe in thisMutableConfigsturct or not ?)I'm mostly thinking out loud but it should bring water to your mill (not sure if it's a valid sentence in english but meh 😝).
Waiting for your inputs now 😉.
🐸
/cc @icecrime @ehazlett @thaJeztah @runcom @tiborvass @unclejack
Signed-off-by: Vincent Demeester vincent@sbr.pm