Skip to content

Commit

Permalink
Fix server systemd detection
Browse files Browse the repository at this point in the history
* Use SYSTEMD_EXEC_PID to detect execution under systemd, since as of a9b5a19 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 <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Jul 13, 2022
1 parent ffe72ee commit a2a5e79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/containerd/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ 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") != ""
cfg.AgentConfig.Systemd = controllers["cpuset"] && os.Getenv("SYSTEMD_EXEC_PID") != ""
}

var containerdTemplate string
Expand Down

0 comments on commit a2a5e79

Please sign in to comment.