From fc55904d82b9c15650a2ed2c2fe7e9274ff708fa Mon Sep 17 00:00:00 2001 From: Matthew Clive Date: Sat, 26 Sep 2020 04:42:17 -0400 Subject: [PATCH] Add network dependency to installed service file (#2210) Adds the line `After=network-online.target` to the k3s systemd service file. This applies the fix mentioned in [this GH comment](https://github.com/rancher/k3s/issues/1626#issuecomment-642253812) which I can confirm makes k3s networking survive reboot in Raspbian Buster. [It appears, in some docs I found](https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files) that this is a recommended and usual way of specifying that we need the target to be _completed_ before starting k3s. Using just the `Wants=` directive doesn't work for this task, you have to add both directives at once to do this. Quote: > `Wants=`: This directive is similar to `Requires=`, but less strict. > `Systemd` will attempt to start any units listed here when this unit > is activated. If these units are not found or fail to start, the > current unit will continue to function. This is the recommended way to > configure most dependency relationships. **Again, this implies a > parallel activation unless modified by other directives** > [...] > `After=`: The units listed in this directive will be started before > starting the current unit. This does not imply a dependency > relationship and **one must be established through the above > directives if this is required.** - _(Emphasis mine)_ Signed-off-by: Matthew Clive Signed-off-by: Brad Davidson --- install.sh | 1 + package/rpm/install.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 6995e444b4..00035ece12 100755 --- a/install.sh +++ b/install.sh @@ -644,6 +644,7 @@ create_systemd_service_file() { Description=Lightweight Kubernetes Documentation=https://k3s.io Wants=network-online.target +After=network-online.target [Install] WantedBy=multi-user.target diff --git a/package/rpm/install.sh b/package/rpm/install.sh index 8d56e4bb93..7e976a6a45 100755 --- a/package/rpm/install.sh +++ b/package/rpm/install.sh @@ -649,6 +649,7 @@ create_systemd_service_file() { Description=Lightweight Kubernetes Documentation=https://k3s.io Wants=network-online.target +After=network-online.target Conflicts=${conflicts} [Install]