Skip to content

Commit 2cbe3bb

Browse files
committed
fix(updater): hand the host docker socket in under a name of its own
An update runs the updater image the target configuration names, so a downgrade runs the updater of the older release - and that one starts a dockerd of its own, unconditionally, on /var/run/docker.sock. The socket do-update.sh bind-mounts there makes that impossible: the path cannot be unlinked, so the daemon never binds it. The host's socket now goes in as /run/cuos-docker.sock, which an updater that does not know about it simply does not see - the situation it was written for. docker_environment.sh prefers it, still accepts the default path, because image-factory and every system older than this updater mount the socket there, and otherwise starts a daemon of its own. A socket that is present but does not answer has to unset DOCKER_HOST, or the client keeps addressing it while the retry loop brings up a dockerd on the default path. tool.sh's image factory keeps the default path deliberately: it builds on the host's daemon because that is faster and platform-independent, and it always runs the factory image it pins itself. Signed-off-by: Simon Walz <contact@simonwalz.de>
1 parent 091eb13 commit 2cbe3bb

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎system/cuos/do-update-shell.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ ROOT_DEV="$(findmnt -n -o SOURCE -T "/" | sed 's/\[.*\]//')"
2525
ROOT_DISK="/dev/$(lsblk -no PKNAME "$ROOT_DEV" | head -n1)"
2626

2727
touch "/root/.docker/config.json"
28+
# Same socket path as do-update.sh, and for the same reason.
2829
docker run --rm -it \
2930
--pull=never \
3031
--log-driver=journald \
3132
--privileged \
3233
--device "${ROOT_DISK}" \
3334
-v "/root/.docker/config.json:/root/.docker/config.json:ro" \
34-
-v "/var/run/docker.sock:/var/run/docker.sock:ro" \
35+
-v "/var/run/docker.sock:/run/cuos-docker.sock:ro" \
3536
-v "/usr/local/share/ca-certificates/custom:/usr/local/share/ca-certificates/custom:ro" \
3637
-v "/etc/image:/etc/image:ro" \
3738
-e "TARGET_DEVICE=${ROOT_DISK}" \

‎system/cuos/do-update.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ ROOT_DEV="$(findmnt -n -o SOURCE -T "/" | sed 's/\[.*\]//')"
5050
ROOT_DISK="/dev/$(lsblk -no PKNAME "$ROOT_DEV" | head -n1)"
5151

5252
touch "/root/.docker/config.json"
53+
# The host's docker socket goes in under a name of its own, because
54+
# /var/run/docker.sock inside the updater has to stay free: an updater that
55+
# brings no daemon along starts a dockerd there, and a bind mount over that
56+
# path cannot be unlinked, so the daemon never comes up. The updater of an
57+
# older release - the one a downgrade runs - is such an updater.
5358
docker run --rm \
5459
--pull=never \
5560
--log-driver=journald \
5661
--privileged \
5762
--device "${ROOT_DISK}" \
5863
-v "/root/.docker/config.json:/root/.docker/config.json:ro" \
59-
-v "/var/run/docker.sock:/var/run/docker.sock:ro" \
64+
-v "/var/run/docker.sock:/run/cuos-docker.sock:ro" \
6065
-v "/usr/local/share/ca-certificates/custom:/usr/local/share/ca-certificates/custom:ro" \
6166
-v "/etc/image:/etc/image:ro" \
6267
-v "${CONFIG_PATH}:/system.json" \

‎updater/docker_environment.sh‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,19 @@ start_dockerd() {
9292
return 0
9393
}
9494

95+
# The host's daemon, if the caller handed one in. /var/run/docker.sock is left
96+
# alone so that start_dockerd below can bind it; the plain path is still
97+
# honoured, because image-factory and any system older than this updater mount
98+
# the socket there.
99+
CUOS_DOCKER_SOCKET="${CUOS_DOCKER_SOCKET:-"/run/cuos-docker.sock"}"
100+
if [[ -S "${CUOS_DOCKER_SOCKET}" ]]; then
101+
export DOCKER_HOST="unix://${CUOS_DOCKER_SOCKET}"
102+
fi
103+
95104
if ! docker info >/dev/null 2>&1; then
105+
# A socket that does not answer must not keep the client from reaching the
106+
# dockerd started below, which listens on the default path.
107+
unset DOCKER_HOST
96108
if ! start_dockerd; then
97109
if ! start_dockerd; then
98110
if ! start_dockerd; then

0 commit comments

Comments
 (0)