Restart = sempre não tenta reiniciar depois que o serviço requerido falhou

0

Eu tenho um kubelet.service que requer docker.service . O kubelet.service é como:

[Unit]
Description=kubelet
After=docker.service
Requires=docker.service

[Service]
WorkingDirectory=/var/lib/kubelet
EnvironmentFile=-/etc/kubernetes/kubelet
ExecStart=/usr/local/bin/kubelet ...
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Quando o docker.service for reiniciado, o kubelet.service será reiniciado automaticamente. No entanto, quando eu reinicializar o servidor, se docker.service falhar durante a inicialização, o kubelet.service não será reiniciado automaticamente!

# journalctl -u kubelet.service 
-- Logs begin at Fri 2018-05-25 09:35:00 CST, end at Fri 2018-05-25 09:53:13 CST. --
May 25 09:35:03 debian systemd[1]: Dependency failed for kubelet.
May 25 09:35:03 debian systemd[1]: kubelet.service: Job kubelet.service/start failed with result 'dependency'.

# journalctl -u docker
-- Logs begin at Fri 2018-05-25 09:35:00 CST, end at Fri 2018-05-25 09:53:46 CST. --
May 25 09:35:03 debian systemd[1]: Starting Docker Application Container Engine...
May 25 09:35:03 debian dockerd[1905]: invalid value "" for flag --mtu: strconv.ParseInt: parsing "": invalid syntax
May 25 09:35:03 debian dockerd[1905]: See '/usr/bin/dockerd --help'.
May 25 09:35:03 debian systemd[1]: docker.service: Main process exited, code=exited, status=125/n/a
May 25 09:35:03 debian systemd[1]: Failed to start Docker Application Container Engine.
May 25 09:35:03 debian systemd[1]: docker.service: Unit entered failed state.
May 25 09:35:03 debian systemd[1]: docker.service: Failed with result 'exit-code'.
May 25 09:35:12 debian systemd[1]: docker.service: Service hold-off time over, scheduling restart.
May 25 09:35:12 debian systemd[1]: Stopped Docker Application Container Engine.
May 25 09:35:12 debian systemd[1]: Starting Docker Application Container Engine...

Como você pode ver, o kubelet parou às 09:35:03 e simplesmente nunca reinicia mesmo depois que o docker começou normalmente às 09:35:12

    
por Haoyuan Ge 25.05.2018 / 03:54

2 respostas

1

Você está atingindo seu limite nas tentativas de reinicialização. Revise StartLimitBurst . Pergunta semelhante aqui .

    
por 25.05.2018 / 04:07
0

Restart não se refere a dependências com falha, mas ao processo pertencente a esta unidade.

man systemd.service :

Restart=
Configures whether the service shall be restarted when the service process exits, is killed, or a timeout is reached. The service process may be the main service process, but it may also be one of the processes specified with ExecStartPre=, ExecStartPost=, ExecStop=, ExecStopPost=, or ExecReload=. When the death of the process is a result of systemd operation (e.g. service stop or restart), the service will not be restarted. Timeouts include missing the watchdog "keep-alive ping" deadline and a service start, reload, and stop operation timeouts.

    
por 25.05.2018 / 04:01