mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-01 22:50:54 +00:00
build: guard parallel races on build symlink and ~/.docker
Parallel make jobs invoke kata-deploy-binaries-in-docker.sh concurrently and collide on two shared paths: ln: Already exists mkdir: /home/$USER/.docker: File exists Skip the symlink creation when the link is already in place. If a parallel job wins the create race in the cold-start window, fall back to re-checking that the link exists so a real ln failure (permission, disk full, etc.) still propagates rather than being silently swallowed. The `~/.docker` mkdir is guarded by a `[[ ! -d ]]` check that two processes can pass simultaneously, after which one bare `mkdir` fails. Switch to `mkdir -p` so the second invocation is a no-op. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
committed by
Fabiano Fidêncio
parent
815ebc340d
commit
18cee00df9
@@ -49,8 +49,10 @@ if [[ "${CROSS_BUILD}" == "true" ]]; then
|
||||
[[ -z "${r}" ]] && sudo docker run --privileged --rm tonistiigi/binfmt --install "${TARGET_ARCH}"
|
||||
fi
|
||||
|
||||
if [[ "${script_dir}" != "${PWD}" ]]; then
|
||||
ln -sf "${script_dir}/build" "${PWD}/build"
|
||||
if [[ "${script_dir}" != "${PWD}" && ! -L "${PWD}/build" ]]; then
|
||||
# If a parallel job creates the link between the check and our ln,
|
||||
# accept that and move on; any other failure aborts.
|
||||
ln -s "${script_dir}/build" "${PWD}/build" 2>/dev/null || [[ -L "${PWD}/build" ]]
|
||||
fi
|
||||
|
||||
# This is the gid of the "docker" group on host. In case of docker in docker builds
|
||||
@@ -66,7 +68,9 @@ fi
|
||||
|
||||
remove_dot_docker_dir=false
|
||||
if [[ ! -d "${HOME}/.docker" ]]; then
|
||||
mkdir "${HOME}"/.docker
|
||||
# Tolerate the dir being created by a parallel job between the check
|
||||
# above and this mkdir.
|
||||
mkdir -p "${HOME}"/.docker
|
||||
remove_dot_docker_dir=true
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user