Uh oh!
There was an error while loading. Please reload this page.
Add --init option to docker service create - #479
Conversation
thaJeztah
left a comment
There was a problem hiding this comment.
I gave this a spin against a docker 17.09-rc2 daemon (which should have the SwarmKit changes), but it didn't seem to work;
Creating a service with --init looks to create the right request:
docker service create --init --name initservice nginx:alpine
Sep 20 10:29:30 moby root: time="2017-09-20T10:29:30.328450671Z" level=debug msg="Calling POST /v1.31/services/create"
Sep 20 10:29:30 moby root: time="2017-09-20T10:29:30.328573170Z" level=debug msg="form data: {\"EndpointSpec\":{\"Mode\":\"vip\"},\"Labels\":{},\"Mode\":{\"Replicated\":{}},\"Name\":\"initservice\",\"TaskTemplate\":{\"ContainerSpec\":{\"DNSConfig\":{},\"Image\":\"nginx:alpine@sha256:83f10f82722087e6944e0348b2e64a95baf247135de7c237f4dec7729a386d7f\",\"Init\":true},\"ForceUpdate\":0,\"Placement\":{\"Platforms\":[{\"Architecture\":\"amd64\",\"OS\":\"linux\"}]},\"Resources\":{\"Limits\":{},\"Reservations\":{}}}}"
(formatted for readability): I can see the Init to be passed to the daemon;
{
"EndpointSpec": {
"Mode": "vip"
},
"Labels": {
},
"Mode": {
"Replicated": {
}
},
"Name": "initservice",
"TaskTemplate": {
"ContainerSpec": {
"DNSConfig": {
},
"Image": "nginx:alpine@sha256:83f10f82722087e6944e0348b2e64a95baf247135de7c237f4dec7729a386d7f",
"Init": true
},
"ForceUpdate": 0,
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"Resources": {
"Limits": {
},
"Reservations": {
}
}
}
}However, I don't see the Init option set for the task backing the container:
docker container inspect initservice.1.xsbsrewdxj0eq9sg2sa51p3im | grep Init
(no response)Inspecting the service also does not show this information, which may be either because there's an issue there, or because docker service inspect does not show all information;
[
{
"ID": "3kju7dy0b7gz0hl8mf5yy93ub",
"Version": {
"Index": 90211
},
"CreatedAt": "2017-09-20T10:29:30.329124642Z",
"UpdatedAt": "2017-09-20T10:29:30.329124642Z",
"Spec": {
"Name": "initservice",
"Labels": {},
"TaskTemplate": {
"ContainerSpec": {
"Image": "nginx:alpine@sha256:83f10f82722087e6944e0348b2e64a95baf247135de7c237f4dec7729a386d7f",
"StopGracePeriod": 10000000000,
"DNSConfig": {}
},
"Resources": {
"Limits": {},
"Reservations": {}
},
"RestartPolicy": {
"Condition": "any",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 1
}
},
"UpdateConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"RollbackConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"EndpointSpec": {
"Mode": "vip"
}
},
"Endpoint": {
"Spec": {}
}
}
]| flags.Var(&opts.hosts, flagHost, "Set one or more custom host-to-IP mappings (host:ip)") | ||
| flags.SetAnnotation(flagHost, "version", []string{"1.25"}) | ||
| flags.BoolVar(&opts.init, flagInit, false, "Use an init inside each service container to forward signals and reap processes") | ||
| flags.SetAnnotation(flagInit, "version", []string{"1.30"}) |
There was a problem hiding this comment.
This will probably need to be bumped to 1.33 (1.32 has shipped in a release)
| User string `json:",omitempty"` | ||
| Groups []string `json:",omitempty"` | ||
| Privileges *Privileges `json:",omitempty"` | ||
| Init bool `json:",omitempty"` |
There was a problem hiding this comment.
As commented in moby/moby#34529 (comment) - SwarmKit changes are merged in moby/moby, so can you open a pull request there to make the required changes in moby/moby?
thaJeztah
commented
Sep 20, 2017
Actually, nevermind, the daemon API of course doesn't yet put this property forward, so that's expected that it's non functional yet. 😅 |
thaJeztah
commented
Nov 8, 2017
Bumping moby/moby in #679, which should bring in the required changes |
leshik
commented
Mar 23, 2018
Any chances we'll see this feature in near future? |
Codecov Report
@@ Coverage Diff @@## master #479 +/- ##
=========================================
Coverage ? 48.52% =========================================
Files ? 199 Lines ? 16409 Branches ? 0 =========================================
Hits ? 7962 Misses ? 8033 Partials ? 414 |
vdemeester
commented
May 31, 2018
I am carrying this PR, opened upstream PR on moby and swarmkit |
vdemeester
commented
May 31, 2018
btw, design LGTM 👼 |
thaJeztah
commented
May 31, 2018
Just so that I don't forget;
|
b4d89ba to
cbaf7d9Comparevdemeester
commented
May 31, 2018
|
thaJeztah
commented
Jun 7, 2018
Oh, last two bullets;
|
| } | ||
| cspec := spec.TaskTemplate.ContainerSpec | ||
| // Update with --stop-signal=SIGUSR1 |
There was a problem hiding this comment.
s/--stop-signal=SIGUSR1/--init=true/
| updateService(nil, nil, flags, spec) | ||
| assert.Check(t, is.Equal(true, cspec.Init)) | ||
| // Update without --stop-signal, no change |
| updateService(nil, nil, flags, spec) | ||
| assert.Check(t, is.Equal(true, cspec.Init)) | ||
| // Update with --stop-signal=SIGWINCH |
There was a problem hiding this comment.
s/--stop-signal= SIGWINCH/--init=false/
silvin-lubecki
commented
Jun 8, 2018
Validate is complaining: |
vdemeester
commented
Jun 8, 2018
@thaJeztah actually there is quite some field from the ContainerSpec that are not showed in the |
thaJeztah
commented
Jun 9, 2018
We should probably add more of those yes; but it's a good start to make sure that new fields are not missed Moby vendoring was updated in another PR, so looks like we can continue on this one 👍 |
docker service createdocker service createsilvin-lubecki
commented
Jun 11, 2018
test is complaining 😂 |
| --container-label-add list Add or update a container label | ||
| --container-label-rm list Remove a container label by its key | ||
| --credential-spec credential-spec Credential spec for managed service account (Windows only) | ||
| --args command Service command args |
There was a problem hiding this comment.
Looks like this whole file changed from using spaces to tabs; can you revert that change?
silvin-lubecki
commented
Jun 13, 2018
A test is failing: |
Signed-off-by: Timothy Higinbottom <timhigins@gmail.com> Signed-off-by: Vincent Demeester <vincent@sbr.pm>
thaJeztah
commented
Jun 23, 2018
Follow up for the compose-file format; #1129 |
Helps #51, but requires more work to add stack/compose v3 file support.
See moby/swarmkit#2350, and moby/moby#34529. We've got it all set in swarmkit, this should finish the CLI, and we're waiting on the final pieces in moby.
- What I did
Added a
--initoption todocker service create- How I did it
Added an options string (
flagInit), the swarm api field inopts.ToService(), and a boolean flag innewCreateCommand()I also changed a line in the vendor code to add the
Initoption to the swarm container api. I understand I'm not supposed to do this, but I'll wait till they get a PR into moby/moby, and then do the vendoring properly.- How to verify it
Run the tests for the
servicesubcommand. Since the daemon doesn't supportinitfor swarm yet, it won't actually do anything.- Description for the changelog
Add --init option to
docker service createWaiting for the following PR to get merged
deepcopy.Copypanicing with BoolValue moby/swarmkit#2652initon services moby/moby#37183