Skip to content

Commit

Permalink
Fix server systemd detection
Browse files Browse the repository at this point in the history
* Use INVOCATION_ID 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 21, 2022
1 parent 990ba0e commit 2265417
Show file tree
Hide file tree
Showing 2 changed files with 5 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
5 changes: 4 additions & 1 deletion pkg/agent/containerd/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2265417

Please sign in to comment.