l sync-containers3: increase kill timeout
This commit is contained in:
parent
1ebf209b70
commit
953f78184f
@ -117,6 +117,7 @@ in {
|
|||||||
mount
|
mount
|
||||||
util-linux
|
util-linux
|
||||||
jq
|
jq
|
||||||
|
retry
|
||||||
];
|
];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = pkgs.writers.writeDash "${ctr.name}_watcher" ''
|
ExecStart = pkgs.writers.writeDash "${ctr.name}_watcher" ''
|
||||||
@ -124,7 +125,7 @@ in {
|
|||||||
while sleep 5; do
|
while sleep 5; do
|
||||||
# get the payload
|
# get the payload
|
||||||
# check if the host reacted recently
|
# check if the host reacted recently
|
||||||
case $(curl -s -o /dev/null --retry 10 -w '%{http_code}' http://127.0.0.1:8500/v1/kv/containers/${ctr.name}) in
|
case $(curl -s -o /dev/null --retry 10 --retry-delay 10 -w '%{http_code}' http://127.0.0.1:8500/v1/kv/containers/${ctr.name}) in
|
||||||
404)
|
404)
|
||||||
echo 'got 404 from kv, should kill the container'
|
echo 'got 404 from kv, should kill the container'
|
||||||
break
|
break
|
||||||
@ -137,8 +138,14 @@ in {
|
|||||||
# echo 'got 200 from kv, will check payload'
|
# echo 'got 200 from kv, will check payload'
|
||||||
export payload=$(consul kv get containers/${ctr.name})
|
export payload=$(consul kv get containers/${ctr.name})
|
||||||
if [ "$(jq -rn 'env.payload | fromjson.host')" = '${config.networking.hostName}' ]; then
|
if [ "$(jq -rn 'env.payload | fromjson.host')" = '${config.networking.hostName}' ]; then
|
||||||
# echo 'we are the host, continuing'
|
# echo 'we are the host, trying to reach container'
|
||||||
|
if $(retry -t 10 -d 10 -- /run/wrappers/bin/ping -q -c 1 ${ctr.name}.r > /dev/null); then
|
||||||
|
# echo 'container is reachable, continueing'
|
||||||
continue
|
continue
|
||||||
|
else
|
||||||
|
# echo 'container seems dead, killing'
|
||||||
|
break
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo 'we are not host, killing container'
|
echo 'we are not host, killing container'
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user