systemd // falhou com resultado 'dependência'

2

Sou muito novo neste tópico systemd . Eu tenho algumas unidades com varios Requer, depois e antes. Em algumas unidades recebi mensagens como:

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

Mas qual dependência em detalhes? Foi assim que tentei detalhar o problema:

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'.

Veja qual serviço é necessário ...

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"

Siga para 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.

Tanto quanto eu entendo isso, o flannel-wait.service depende do flanneld.service -que está sendo executado. Mas afinal, por que falha?

Obrigado antecipadamente!

    
por Norman 04.05.2016 / 18:32

1 resposta

0

Meu palpite é que o flanneld.service teve que baixar o contêiner de flanela, o que pode ter levado um segundo. Sua espera de flanela pode ter esperado o tempo padrão para a dependência (talvez 30 segundos) e depois falhar. A coisa que eu não tenho certeza sobre como é ser um pouco afeta isso. Para um serviço normal, você apenas adicionava um restart = always e deveria ter sido bom. Não tenho certeza se um oneshot pode ter um parâmetro de reinicialização, uma vez que é realmente projetado para ser executado uma vez. Mas isso é tudo um palpite.

    
por 06.05.2016 / 16:10