mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
BuildKite pre-command: Use alternate way to reload Docker when available.
PiperOrigin-RevId: 456884864
This commit is contained in:
committed by
gVisor bot
parent
c1111baf6c
commit
cf533616cb
@@ -36,7 +36,15 @@ export TOTAL_PARTITIONS=${BUILDKITE_PARALLEL_JOB_COUNT:-1}
|
||||
export RUNTIME="buildkite_runtime_${BUILDKITE_BRANCH}-${BUILDKITE_BUILD_ID}"
|
||||
export RUNTIME="$(echo "$RUNTIME" | sed -r 's~[^-_a-z0-9]+~_~g')"
|
||||
|
||||
# Ensure Docker has experimental enabled.
|
||||
# If running in a container, set the reload command appropriately.
|
||||
if [[ -x /tmp/buildkite-reload-host-docker/reload ]]; then
|
||||
export DOCKER_RELOAD_COMMAND='/tmp/buildkite-reload-host-docker/reload'
|
||||
else
|
||||
export DOCKER_RELOAD_COMMAND='sudo systemctl reload docker'
|
||||
fi
|
||||
|
||||
# Ensure Docker has experimental enabled, install runtimes.
|
||||
HAD_EXPERIMENTAL="$(docker version --format='{{.Server.Experimental}}')"
|
||||
if [[ -n "${STAGED_BINARIES:-}" ]]; then
|
||||
# Used `runsc` from STAGED_BINARIES instead of building it from scratch.
|
||||
tmpdir="$(mktemp -d)"
|
||||
@@ -49,9 +57,16 @@ else
|
||||
make sudo TARGETS=//runsc:runsc \
|
||||
ARGS="install --experimental=true --runtime=${RUNTIME} -- ${RUNTIME_ARGS:-}"
|
||||
fi
|
||||
# WARNING: We may be running in a container when this command executes.
|
||||
# This only makes sense if Docker's `live-restore` feature is enabled.
|
||||
sudo systemctl restart docker
|
||||
if [[ "$HAD_EXPERIMENTAL" == false ]]; then
|
||||
# WARNING: We may be running in a container when this command executes.
|
||||
# This only makes sense if Docker's `live-restore` feature is enabled.
|
||||
sudo systemctl restart docker
|
||||
else
|
||||
# If experimental-ness was already enabled, we don't need to restart, as the
|
||||
# only thing we modified is the list of runtimes, which can be reloaded with
|
||||
# just a SIGHUP.
|
||||
bash -c "$DOCKER_RELOAD_COMMAND"
|
||||
fi
|
||||
|
||||
# Helper for benchmarks, based on the branch.
|
||||
if test "${BUILDKITE_BRANCH}" = "master"; then
|
||||
|
||||
@@ -102,7 +102,8 @@ endif
|
||||
## RUNTIME_ARGS - Arguments passed to the runtime when installed.
|
||||
## STAGED_BINARIES - A tarball of staged binaries. If this is set, then binaries
|
||||
## will be installed from this staged bundle instead of built.
|
||||
##
|
||||
## DOCKER_RELOAD_COMMAND - The command to run to reload Docker. (default: sudo systemctl reload docker).
|
||||
|
||||
ifeq (,$(BRANCH_NAME))
|
||||
RUNTIME := runsc
|
||||
RUNTIME_DIR := $(shell dirname $(shell mktemp -u))/$(RUNTIME)
|
||||
@@ -114,6 +115,7 @@ RUNTIME_BIN := $(RUNTIME_DIR)/runsc
|
||||
RUNTIME_LOG_DIR := $(RUNTIME_DIR)/logs
|
||||
RUNTIME_LOGS := $(RUNTIME_LOG_DIR)/runsc.log.%TEST%.%TIMESTAMP%.%COMMAND%
|
||||
RUNTIME_ARGS ?=
|
||||
DOCKER_RELOAD_COMMAND ?= sudo systemctl reload docker
|
||||
|
||||
ifeq ($(shell stat -f -c "%T" /sys/fs/cgroup 2>/dev/null),cgroup2fs)
|
||||
CGROUPV2 := true
|
||||
@@ -138,7 +140,8 @@ configure_noreload = \
|
||||
sudo $(RUNTIME_BIN) install --experimental=true --runtime="$(1)" -- $(RUNTIME_ARGS) --debug-log "$(RUNTIME_LOGS)" $(2) && \
|
||||
sudo rm -rf "$(RUNTIME_LOG_DIR)" && mkdir -p "$(RUNTIME_LOG_DIR)"
|
||||
reload_docker = \
|
||||
sudo systemctl reload docker && \
|
||||
$(call header,DOCKER RELOAD); \
|
||||
bash -xc "$(DOCKER_RELOAD_COMMAND)" && \
|
||||
if test -f /etc/docker/daemon.json; then \
|
||||
sudo chmod 0755 /etc/docker && \
|
||||
sudo chmod 0644 /etc/docker/daemon.json; \
|
||||
|
||||
Reference in New Issue
Block a user