cluster/ - Configure containerd only if necessary

PR #107663 changed the startup logic to always call `SetupContainerd`
which will generate a new containerd `/etc/containerd/config.toml` file.

This is not always desired since some jobs install containerd from
source and the containerd startup scripts
(https://github.com/containerd/containerd/blob/main/contrib/gce/configure.sh)
are responsible for generating the `/etc/containerd/config.toml` file.
By always calling `SetupContainerd`, the containerd configuration by
containerd's `configure.sh` will be overridden which breaks certain test
jobs, see https://github.com/kubernetes/kubernetes/issues/107830.

To fix this issue, only call `SetupContainerd` if
`/etc/profile.d/containerd_env.sh` does not exist. When containerd
`configure.sh` script will run, `/etc/profile.d/containerd_env.sh` will
be written, and as a result the k8s setup scripts should avoid
overriding the containerd configuration.

Signed-off-by: David Porter <david@porter.me>
This commit is contained in:
David Porter 2022-02-10 14:17:44 -08:00
parent 3866cb91f2
commit 3281504a50

View File

@ -3442,7 +3442,12 @@ function main() {
# stop docker if it is present as we want to use just containerd
log-wrap 'StopDocker' systemctl stop docker || echo "unable to stop docker"
fi
log-wrap 'SetupContainerd' setup-containerd
if [[ ! -e "/etc/profile.d/containerd_env.sh" ]]; then
log-wrap 'SetupContainerd' setup-containerd
else
echo "Skipping SetupContainerd step because containerd has already been setup by containerd's configure.sh script"
fi
log-start 'SetupKubePodLogReadersGroupDir'
if [[ -n "${KUBE_POD_LOG_READERS_GROUP:-}" ]]; then