-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Integrated Generic resource in service create #429
Conversation
ef12709
to
72184fd
Compare
Codecov Report
@@ Coverage Diff @@
## master #429 +/- ##
==========================================
+ Coverage 51.42% 51.64% +0.21%
==========================================
Files 215 216 +1
Lines 17716 17860 +144
==========================================
+ Hits 9111 9223 +112
- Misses 8138 8161 +23
- Partials 467 476 +9 |
72184fd
to
80c7d2a
Compare
80c7d2a
to
e665e8a
Compare
e665e8a
to
26f5899
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for using a new microformat (key=value;key=value
) instead of using either the CSV format (as we use for --mount
), or allowing the flag to be set multiple times (--generic-resources foo=bar
----generic-resources bar=baz
)? The latter would also allow, for example to --generic-resources-add foo=bar
/ --generic-resources-rm foo=bar
.
I noticed this PR only handles DiscreteResourceSpec
, whereas the API also supports NamedResourceSpec
; could these be ambiguous? If so, perhaps the flag should take that into account ----generic-resources type=discrete,foo=bar
.
If they are not abigious; does the API actually need two separate types?
Generic Resources are used in two ways for this new feature:
You are raising a pretty good point here. I actually considered using this in the original smarmkit PR. Though @thaJeztah I'm not sure what --generic-resources-add and --generic-resources-rm are supposed to do ?
That would be a different format right ? |
The $ docker service create --name myservice --label hello=world --label foo=bar busybox top
$ docker service inspect --format '{{ json .Spec.Labels}}' myservice | jq .
{
"foo": "bar",
"hello": "world"
} For example, remove the $ docker service update --label-rm foo myservice
$ docker service inspect --format '{{ json .Spec.Labels}}' myservice | jq .
{
"hello": "world"
} Or replace the $ docker service update --label-rm hello --label-add new=sparkly myservice
$ docker service inspect --format '{{ json .Spec.Labels}}' myservice | jq .
{
"new": "sparkly"
}
Ah, yes. The swarmkit CLI is primarily for testing / development; I don't think we have to make the same choice here; basically, trying to keep a consistent UX with other options (but I'm not too familiar with this feature, so we can adjust where needed). Main thing that stood out to me is the use of a semicolon as separator (which is not used in any other flag currently to my knowledge) To get a better understanding of the functionality; would:
Be any different than:
It's a good intent 😄 Overall there's already a lot of flags, and when defining a service it's likely people already have to set many options. Having a Using the docker service create --generic-resources GPU=UUID1, GPU=UUID2 Followed by docker service update --generic-resources-rm GPU Would remove both Whereas: docker service update --generic-resources-rm GPU=UUID2 Would only remove
If
Given that I was not in the review of the pull request for the daemon (moby/moby#33440), let me ping @stevvooe @aaronlehmann @cpuguy83 as well, in case there's things I'm overlooking. Also, if it's decided to change the format, I think it would be good to update the format as used for the daemon flag consistent. |
Ok I understand the The ---add / ---rm flags :) And in general I like the idea of being able to remove/add Generic Resources.
Overall I do like the usage of the CSV without having to repeat the flag.
In the case of service create, we don't expect people to use NamedResources. |
The "diff-ing" is a pure client-side implementation; the client takes the existing service-spec, applies the Aany change in the service spec would trigger a re-create of the service's tasks (containers), so when removing a generic resource, the existing containers are stopped and new containers created to take their place.
For moby; yes, if we agree the CSV notation is what we think is best and we want to keep the daemon flag the consistent. For Swarm, that's a "nice to have", but also probably good to stay consistent. All of course if we agree the CSV notation works 😅 |
Bumping moby/moby in #679, which should bring in the required changes |
26f5899
to
36a8894
Compare
Please sign your commits following these rules: $ git clone -b "generic-resource" [email protected]:RenaudWasTaken/cli.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353949704
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f Amending updates the existing PR. You DO NOT need to open a new one. |
8daf7e8
to
740b0ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple doc fixes
### Create services requesting Generic Resources | ||
|
||
You can narrow the kind of nodes your task can land on through the using the | ||
`--generic-resources` flag (if the nodes advertise these resources): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/generic-resources/generic-resource/
also 2 instances in the example below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, also fixed in --generic-resources-add
and --generic-resources-rm
to --generic-resource-add` and
--generic-resource-rm`
740b0ab
to
23adc80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @dnephin ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐸
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
Signed-off-by: Renaud Gaubert <[email protected]>
23adc80
to
1ff73f8
Compare
Rebased! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
We'll probably need a follow-up for the compose-file docs; https://github.com/docker/docker.github.io/blob/master/compose/compose-file/index.md Also @RenaudWasTaken this only annotates what's available on the host, but it will still require the nvidia tooling to setup those resources inside the container, correct? What steps would be needed to support this without? |
@thaJeztah Correct, it should work out of the box with nvidia-docker 2.0 set as the default runtime on your swarm. |
Thanks a lot @thaJeztah ! |
Notes for reviewers
First contribution submitted to the repo, please advise if something's not right with the format or procedure, etc.
- What I did
I integrated Generic Resources in
docker service create
.- How I did it
This work is based on #424 so, will need to be updated once it is merged.
- How to verify it
This command should not schedule the task if no resources are advertised on any nodes.
If you want to advertise resources, these should be declared in the daemon.json or on the dockerd command line (i.e.:
dockerd ... --generic-resources "banana=6;apple=4
).Note: Some tests will be added to the current.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
