Make BuildKite's docker runtime reload logic robust against empty runtime dict

PiperOrigin-RevId: 479678511
This commit is contained in:
Etienne Perot
2022-10-07 15:18:09 -07:00
committed by gVisor bot
parent 36ddd3050c
commit 66aa0427cd
+5 -2
View File
@@ -77,8 +77,11 @@ done
set -euo pipefail
# Remove all Docker runtimes that may be installed.
if grep -qE runtimes /etc/docker/daemon.json; then
cat /etc/docker/daemon.json | jq 'del(.runtimes) + {runtimes: {}}' \
num_docker_runtimes="$(jq \
'(if has("runtimes") then .runtimes else {} end) | length' \
< /etc/docker/daemon.json)"
if [[ "$num_docker_runtimes" -gt 0 ]]; then
cat /etc/docker/daemon.json | jq 'del(.runtimes)' \
| sudo tee /etc/docker/daemon.json.tmp
sudo mv /etc/docker/daemon.json.tmp /etc/docker/daemon.json
bash -c "$DOCKER_RELOAD_COMMAND"