3

I'm quite new to this systemd topic. I have some Units with varios Requires, After and Before. On some Units I got messages like:

tinc.service: Job tinc.service/start failed with result 'dependency'.

But which dependency in detail? This is how I tried to drill down to the problem:

core@chimp ~ $ systemctl status tinc.service
● tinc.service - Tinc VPN Service
   Loaded: loaded (/etc/systemd/system/tinc.service; static; vendor preset: disabled)
   Active: inactive (dead)

May 04 18:09:18 chimp systemd[1]: Dependency failed for Tinc VPN Service.
May 04 18:09:18 chimp systemd[1]: tinc.service: Job tinc.service/start failed with result 'dependency'.

Take a look which service is required...

core@chimp ~ $ cat /etc/systemd/system/tinc.service
[Unit]
Description=Tinc VPN Service
Requires=flannel-wait.service
After=flanneld.service tinc-env.service flannel-wait.service

#Before=early-docker.target

[Service]
Restart=always
RestartSec=3
Environment="DOCKER_HOST=unix:///var/run/early-docker.sock"
EnvironmentFile=/etc/tinc-env

EnvironmentFile=/etc/environment


ExecStartPre=/usr/bin/docker pull jenserat/tinc
ExecStartPre=/usr/bin/rm -rf /srv/tinc
ExecStartPre=/usr/bin/mkdir -p /srv/tinc
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc  jenserat/tinc init $TINC_HOSTNAME"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc  jenserat/tinc add Address = $COREOS_PUBLIC_IPV4"
EnvironmentFile=/run/flannel/subnet.env
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc  jenserat/tinc add Subnet = `echo $FLANNEL_SUBNET | sed -e 's/1\\/24/0\\/24/'`"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc  jenserat/tinc add Mode = switch"
ExecStartPre=/bin/sh -c "/usr/bin/docker run --rm --volume /srv/tinc:/etc/tinc  jenserat/tinc add DeviceType = tap"
ExecStartPre=-/usr/bin/docker rm -f tinc
ExecStartPre=/usr/bin/docker run --name tinc  -d --volume /srv/tinc:/etc/tinc --net=host --device=/dev/net/tun --cap-add NET_ADMIN jenserat/tinc start  -D

ExecStart=/bin/sh -c "while true; do etcdctl set /services/tinc/$TINC_HOSTNAME  \"\\\"` cat /srv/tinc/hosts/$TINC_HOSTNAME `\"\\\" --ttl 60;sleep 45;done"

#ExecStop=/usr/bin/docker rm -f tinc
ExecStopPost=/bin/sh -c  "etcdctl rm /services/tinc/$TINC_HOSTNAME"

Move on to flannel-wait.service:

core@chimp ~ $ systemctl status flannel-wait.service
● flannel-wait.service - Wait For Flannel
   Loaded: loaded (/etc/systemd/system/flannel-wait.service; static; vendor preset: disabled)
   Active: inactive (dead)

May 04 18:09:18 chimp systemd[1]: Dependency failed for Wait For Flannel.
May 04 18:09:18 chimp systemd[1]: flannel-wait.service: Job flannel-wait.service/start failed with result 'dependency'.
core@chimp ~ $ cat /etc/systemd/system/flannel-wait.service

[Unit]
Description=Wait For Flannel
Requires=flanneld.service
After=flanneld.service

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo \"TINC_HOSTNAME=`hostname | sed -e 's/-/_/g'`\" > /etc/tinc-env"
ExecStartPre=/bin/sh -c "while [ ! -f /run/flannel/subnet.env ] ; do sleep 1; done"

Drill depper..

core@chimp ~ $ systemctl status flanneld.service
● flanneld.service - Network fabric for containers
   Loaded: loaded (/usr/lib64/systemd/system/flanneld.service; static; vendor preset: disabled)
  Drop-In: /etc/systemd/system/flanneld.service.d
           └─50-network-config.conf
   Active: active (running) since Wed 2016-05-04 18:09:24 CEST; 12min ago
     Docs: https://github.com/coreos/flannel
  Process: 929 ExecStartPost=/usr/bin/docker run --net=host --rm -v /run:/run quay.io/coreos/flannel:${FLANNEL_VER} /opt/bin/mk-docker-opts.sh -d /run/flannel_docker_opts.env -i (code=exited, status=0/SUCCESS)
  Process: 879 ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config { "Network": "10.1.0.0/16", "Backend": { "Type": "alloc"} } (code=exited, status=0/SUCCESS)
  Process: 877 ExecStartPre=/usr/bin/touch ${FLANNEL_ENV_FILE} (code=exited, status=0/SUCCESS)
  Process: 875 ExecStartPre=/usr/bin/mkdir -p ${ETCD_SSL_DIR} (code=exited, status=0/SUCCESS)
  Process: 873 ExecStartPre=/usr/bin/mkdir -p /run/flannel (code=exited, status=0/SUCCESS)
  Process: 871 ExecStartPre=/sbin/modprobe ip_tables (code=exited, status=0/SUCCESS)
 Main PID: 886 (sdnotify-proxy)
   Memory: 12.0M
      CPU: 93ms
   CGroup: /system.slice/flanneld.service
           ├─886 /usr/libexec/sdnotify-proxy /run/flannel/sd.sock /usr/bin/docker run --net=host --privileged=true --rm --volume=/run/flannel:/run/flannel --env=NOTIFY_SOCKET=/run/flannel/sd.sock --env=AW...
           └─889 /usr/bin/docker run --net=host --privileged=true --rm --volume=/run/flannel:/run/flannel --env=NOTIFY_SOCKET=/run/flannel/sd.sock --env=AWS_ACCESS_KEY_ID= --env=AWS_SECRET_ACCESS_KEY= --e...

May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.131290 00001 main.go:275] Installing signal handlers
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.139346 00001 main.go:188] Using 178.XXXXXX as external interface
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.139363 00001 main.go:189] Using 178.XXXXX as external endpoint
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.140740 00001 etcd.go:129] Found lease (10.1.6.0/24) for current IP (178.XXXX), reusing
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.176357 00001 etcd.go:84] Subnet lease acquired: 10.1.6.0/24
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.234997 00001 ipmasq.go:50] Adding iptables rule: FLANNEL -d 10.1.0.0/16 -j ACCEPT
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.237095 00001 ipmasq.go:50] Adding iptables rule: FLANNEL ! -d 224.0.0.0/4 -j MASQUERADE
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.256054 00001 ipmasq.go:50] Adding iptables rule: POSTROUTING -s 10.1.0.0/16 -j FLANNEL
May 04 18:09:24 chimp sdnotify-proxy[886]: I0504 16:09:24.258241 00001 ipmasq.go:50] Adding iptables rule: POSTROUTING ! -s 10.1.0.0/16 -d 10.1.0.0/16 -j MASQUERADE
May 04 18:09:24 chimp systemd[1]: Started Network fabric for containers.

As far as I understand this, the flannel-wait.service relies on the flanneld.service -which is running. But after all, why does it fail?

Thanks in advance!

0

My guess is that flanneld.service had to download the flannel container, which might have taken a second. Your flannel wait might have waited the default amount of time for the dependency (maybe 30sec?) and then failed. The thing I'm not sure about is how it being a oneshot affects this. For a normal service you'd just add a restart=always and it should have been fine. I'm not sure if a oneshot can have a restart parameter, since its really designed to be run once. But thats all a guess.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.