Add gid to config.toml only when docker group is present

If we don't install docker and install just containerd apt packages,
there is no docker group. In this scenario, we should not add the gid to
config.toml
This commit is contained in:
Davanum Srinivas 2020-02-07 11:03:53 -05:00
parent 415b3ed950
commit c4ef6a94b3
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -2668,8 +2668,6 @@ EOF
cni_template_path=""
fi
fi
# Reuse docker group for containerd.
local containerd_gid="$(cat /etc/group | grep ^docker: | cut -d: -f 3)"
cat > "${config_path}" <<EOF
# Kubernetes doesn't use containerd restart manager.
disabled_plugins = ["restart"]
@ -2678,9 +2676,6 @@ oom_score = -999
[debug]
level = "${CONTAINERD_LOG_LEVEL:-"info"}"
[grpc]
gid = ${containerd_gid}
[plugins.cri]
stream_server_address = "127.0.0.1"
max_container_log_line_size = ${CONTAINERD_MAX_CONTAINER_LOG_LINE:-262144}
@ -2691,6 +2686,16 @@ oom_score = -999
[plugins.cri.registry.mirrors."docker.io"]
endpoint = ["https://mirror.gcr.io","https://registry-1.docker.io"]
EOF
# Reuse docker group for containerd.
local containerd_gid="$(cat /etc/group | grep ^docker: | cut -d: -f 3)"
if [[ ! -z "${containerd_gid:-}" ]]; then
cat >> "${config_path}" <<EOF
# reuse id of the docker group
[grpc]
gid = ${containerd_gid}
EOF
fi
chmod 644 "${config_path}"
echo "Restart containerd to load the config change"