Commit bd5fdfce authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Fix server systemd detection

* Use INVOCATION_ID to detect execution under systemd, since as of a9b5a193 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: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 1674b9d6
...@@ -217,11 +217,7 @@ setup_env() { ...@@ -217,11 +217,7 @@ setup_env() {
if [ -n "${INSTALL_K3S_TYPE}" ]; then if [ -n "${INSTALL_K3S_TYPE}" ]; then
SYSTEMD_TYPE=${INSTALL_K3S_TYPE} SYSTEMD_TYPE=${INSTALL_K3S_TYPE}
else else
if [ "${CMD_K3S}" = server ]; then
SYSTEMD_TYPE=notify SYSTEMD_TYPE=notify
else
SYSTEMD_TYPE=exec
fi
fi fi
# --- use binary install directory if defined or create default --- # --- use binary install directory if defined or create default ---
......
...@@ -52,7 +52,10 @@ func setupContainerdConfig(ctx context.Context, cfg *config.Node) error { ...@@ -52,7 +52,10 @@ func setupContainerdConfig(ctx context.Context, cfg *config.Node) error {
if disableCgroup { if disableCgroup {
logrus.Warn("cgroup v2 controllers are not delegated for rootless. Disabling cgroup.") logrus.Warn("cgroup v2 controllers are not delegated for rootless. Disabling cgroup.")
} else { } 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 var containerdTemplate string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment