docker / docker/cli

Service update ignores existing log-driver when setting log-opt

Open
#1,942 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/swarm kind/bug
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

as reported in https://github.com/docker/docker.github.io/issues/8745 by @Tomcat-Engineering

When updating a service (docker service update), any log-opt specified is ignored unless a log-driver is also set when updating.

this looks to be a combination of something that's by design, and (what I think is) a bug in the docker service update logic; docker service create and update should follow slightly different logic (and I think they currently use the same).

  • expected: setting log-opt for a service that does not have a logging-driver configured isn't supported
  • t.b.d.: creating a service with a log-opt set, but no logging driver silently ignores the option
    • should it produce an error? a warning?
  • bug: setting log-opt for a service that has a logging driver configured (when created), but without specifying that driver during update is silently ignored.
    • when updating a service, the CLI should take the existing logging-driver, and update the options

Taking a full example;

docker service create --log-driver=json-file --log-opt max-file=5 --name loggie nginx:alpine
docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
{"Name":"json-file","Options":{"max-file":"5"}}

Updating without logging-driver set doesn't take effect. IMO this should work, given that the service already had a logging-driver configured. It should still fail (or warn) if no logging-driver was configured yet on the service.

docker service update --log-opt max-file=15 loggie
docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
{"Name":"json-file","Options":{"max-file":"5"}}

Updating with a logging driver specified does;

docker service update --log-driver=json-file --log-opt max-file=15 loggie
docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
{"Name":"json-file","Options":{"max-file":"15"}}

We should fix the update case:

  • if a logging-driver is set on the service, keep that driver and set the log-opts
  • if no logging-driver is set, and none is specified when updating; produce a warning (or error)
    • this validation should be handled daemon-side
  • when creating a service; produce a warning (or error) if a log-opt is set, but no log-driver
    • this validation should be handled daemon-side

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the docker service update and docker service create entry points and reproduce the commands in the issue, then inspect how log-driver and log-opt values are assembled. Compare the update behavior with the existing service specification. Done means existing drivers are preserved during option-only updates and the unspecified create/update validation behavior is implemented consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.