From bd5fdfce330fee140936e1ce4ba2453544a036bd Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Tue, 12 Jul 2022 17:03:25 -0700 Subject: [PATCH] Fix server systemd detection * Use INVOCATION_ID to detect execution under systemd, since as of a9b5a1933fbd773062be1433d056df07f138a7bd NOTIFY_SOCKET is now cleared by the server code. * Set the unit type to notify by default for both server and agent, which is what Rancher-managed installs have done for a while. Signed-off-by: Brad Davidson --- install.sh | 6 +----- pkg/agent/containerd/config_linux.go | 5 ++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index b0af92eef0..783b4329ec 100755 --- a/install.sh +++ b/install.sh @@ -217,11 +217,7 @@ setup_env() { if [ -n "${INSTALL_K3S_TYPE}" ]; then SYSTEMD_TYPE=${INSTALL_K3S_TYPE} else - if [ "${CMD_K3S}" = server ]; then - SYSTEMD_TYPE=notify - else - SYSTEMD_TYPE=exec - fi + SYSTEMD_TYPE=notify fi # --- use binary install directory if defined or create default --- diff --git a/pkg/agent/containerd/config_linux.go b/pkg/agent/containerd/config_linux.go index 20697d20db..0a5a198f10 100644 --- a/pkg/agent/containerd/config_linux.go +++ b/pkg/agent/containerd/config_linux.go @@ -52,7 +52,10 @@ func setupContainerdConfig(ctx context.Context, cfg *config.Node) error { if disableCgroup { logrus.Warn("cgroup v2 controllers are not delegated for rootless. Disabling cgroup.") } else { - cfg.AgentConfig.Systemd = controllers["cpuset"] && os.Getenv("NOTIFY_SOCKET") != "" + // note: this mutatation of the passed agent.Config is later used to set the + // kubelet's cgroup-driver flag. This may merit moving to somewhere else in order + // to avoid mutating the configuration while setting up containerd. + cfg.AgentConfig.Systemd = !isRunningInUserNS && controllers["cpuset"] && os.Getenv("INVOCATION_ID") != "" } var containerdTemplate string