mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Wait/reap build container before removing it
Fixes: https://github.com/GoogleCloudPlatform/kubernetes/issues/1853
This commit is contained in:
parent
3910b2d6e1
commit
21eb09fb6a
@ -241,6 +241,17 @@ function kube::build::short_hash() {
|
|||||||
echo ${short_hash:0:5}
|
echo ${short_hash:0:5}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pedantically kill, wait-on and remove a container. The -f -v options
|
||||||
|
# to rm don't actually seem to get the job done, so force kill the
|
||||||
|
# container, wait to ensure it's stopped, then try the remove. This is
|
||||||
|
# a workaround for bug https://github.com/docker/docker/issues/3968.
|
||||||
|
function kube::build::destroy_container() {
|
||||||
|
"${DOCKER[@]}" kill "$1" >/dev/null 2>&1 || true
|
||||||
|
"${DOCKER[@]}" wait "$1" >/dev/null 2>&1 || true
|
||||||
|
"${DOCKER[@]}" rm -f -v "$1" >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
@ -417,14 +428,10 @@ function kube::build::run_build_command() {
|
|||||||
local -ra docker_cmd=(
|
local -ra docker_cmd=(
|
||||||
"${DOCKER[@]}" run "${docker_run_opts[@]}" "${KUBE_BUILD_IMAGE}")
|
"${DOCKER[@]}" run "${docker_run_opts[@]}" "${KUBE_BUILD_IMAGE}")
|
||||||
|
|
||||||
# Remove the container if it is left over from some previous aborted run
|
# Clean up container from any previous run
|
||||||
"${DOCKER[@]}" rm -f -v "${KUBE_BUILD_CONTAINER_NAME}" >/dev/null 2>&1 || true
|
kube::build::destroy_container "${KUBE_BUILD_CONTAINER_NAME}"
|
||||||
"${docker_cmd[@]}" "$@"
|
"${docker_cmd[@]}" "$@"
|
||||||
|
kube::build::destroy_container "${KUBE_BUILD_CONTAINER_NAME}"
|
||||||
# Remove the container after we run. '--rm' might be appropriate but it
|
|
||||||
# appears that sometimes it fails. See
|
|
||||||
# https://github.com/docker/docker/issues/3968
|
|
||||||
"${DOCKER[@]}" rm -f -v "${KUBE_BUILD_CONTAINER_NAME}" >/dev/null 2>&1 || true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test if the output directory is remote (and can only be accessed through
|
# Test if the output directory is remote (and can only be accessed through
|
||||||
@ -460,8 +467,7 @@ function kube::build::copy_output() {
|
|||||||
rm -rf "${LOCAL_OUTPUT_BINPATH}"
|
rm -rf "${LOCAL_OUTPUT_BINPATH}"
|
||||||
mkdir -p "${LOCAL_OUTPUT_BINPATH}"
|
mkdir -p "${LOCAL_OUTPUT_BINPATH}"
|
||||||
|
|
||||||
# Remove the container if it is left over from some previous aborted run
|
kube::build::destroy_container "${KUBE_BUILD_CONTAINER_NAME}"
|
||||||
"${DOCKER[@]}" rm -f -v "${KUBE_BUILD_CONTAINER_NAME}" >/dev/null 2>&1 || true
|
|
||||||
"${docker_cmd[@]}" bash -c "cp -r ${REMOTE_OUTPUT_BINPATH} /tmp/bin;touch /tmp/finished;rm /tmp/bin/test_for_remote;/bin/sleep 600" > /dev/null 2>&1
|
"${docker_cmd[@]}" bash -c "cp -r ${REMOTE_OUTPUT_BINPATH} /tmp/bin;touch /tmp/finished;rm /tmp/bin/test_for_remote;/bin/sleep 600" > /dev/null 2>&1
|
||||||
|
|
||||||
# Wait until binaries have finished coppying
|
# Wait until binaries have finished coppying
|
||||||
|
Loading…
Reference in New Issue
Block a user