containrrr/shepherd

Syntax around FILTER_SERVICES

pascalandy opened this issue · 2 comments

Hi,

I want to have shepherd to update only two services. I don't understand the syntax around label for shepherd. I do use labels as you can see.

I think the docs should be more specific around this.
Thank you!

cmd for shepherd

docker service create \
  --name "$CTN_shepherd" --hostname "$CTN_shepherd" \
  --replicas "1" \
  --constraint "node.role==manager" \
  --restart-condition "on-failure" \
  --limit-cpu "0.1" \
  --limit-memory "16M" \
  --env SLEEP_TIME="1m" \
  --env FILTER_SERVICES="10000013-edge-ghost,10000014-stable-ghost" \
  --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \
  --mount type=bind,source=/root/.docker/config.json,target=/root/.docker/config.json,ro \
  ${IMG_shepherd}

error for shepherd

root@hulu1:~/deploy-setup# docker service logs -f tool-shepherd
tool-shepherd.1.nbh559jelcqo@hulu2    | Wed Dec 16 10:15:39 EST 2020 Timezone set to US/Eastern
tool-shepherd.1.nbh559jelcqo@hulu2    | Wed Dec 16 10:15:46 EST 2020 Enabling synchronous service updates
tool-shepherd.1.nbh559jelcqo@hulu2    | invalid argument "10000013-edge-ghost,10000014-stable-ghost" for "-f, --filter" flag: bad format of filter (expected name=value)
tool-shepherd.1.nbh559jelcqo@hulu2    | See 'docker service ls --help'.
tool-shepherd.1.nbh559jelcqo@hulu2    | Wed Dec 16 10:15:55 EST 2020 Sleeping 1m before next update

inspect my app

docker service inspect --pretty 10000013-edge-ghost

(...)
ID:		3vgh3inten0myykdlgfkbbkx3
Name:		10000013-edge-ghost
Labels:
 traefik.backend=10000013-edge-ghost
 traefik.backend.loadbalancer.method=drr
 traefik.backend.loadbalancer.swarm=true
 traefik.docker.network=ntw_front
 traefik.enable=true
 traefik.frontend.entryPoints=http,https
 traefik.frontend.priority=100
 traefik.frontend.redirect.entryPoint=https
 traefik.frontend.redirect.permanent=true
 traefik.frontend.rule=Host:trial.firepress.link;PathPrefix:/edge
 traefik.passHostHeader=true
 traefik.port=2368
 traefik.weight=10
Service Mode:	Replicated
 Replicas:	1
 
(...)

Well, the syntax is that of a single filter option for docker service ls.

That means in your case you could use FILTER_SERVICES=label=traefik.backend=10000013-edge-ghost in order to match one of the services.

Adding multiple filters is currently not supported. As a workaround, you could add an additional label to each of those services called shepherd=1 (or similar) and then use FILTER_SERVICES=label=shepherd in order to match all of them.

You are right the documentation should be improved here.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.