From aaac31c8a45accc0b3bd6a632a92afebbadafcce Mon Sep 17 00:00:00 2001 From: Mogeko Date: Fri, 21 Jun 2024 10:29:28 +0800 Subject: [PATCH 1/2] rke2: include killall script in the bin Add `fix-systemd-unit-name.patch` to patch the killall script --- .../networking/cluster/rke2/builder.nix | 11 +++++++++++ .../cluster/rke2/fix-systemd-unit-name.patch | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch diff --git a/pkgs/applications/networking/cluster/rke2/builder.nix b/pkgs/applications/networking/cluster/rke2/builder.nix index 285108834c1e..190251cfd716 100644 --- a/pkgs/applications/networking/cluster/rke2/builder.nix +++ b/pkgs/applications/networking/cluster/rke2/builder.nix @@ -7,6 +7,9 @@ lib: { rke2Version, rke2RepoSha256, rke2VendorHash, updateScript # Runtime dependencies , procps, coreutils, util-linux, ethtool, socat, iptables, bridge-utils, iproute2, kmod, lvm2 +# Killall Script dependencies +, systemd, gnugrep, gnused + # Testing dependencies , nixosTests, testers, rke2 }: @@ -41,6 +44,9 @@ buildGoModule rec { lvm2 # dmsetup ]; + # Patch the systemd unit name to be `rke2.service`. + patches = [ ./fix-systemd-unit-name.patch ]; + # See: https://github.com/rancher/rke2/blob/e7f87c6dd56fdd76a7dab58900aeea8946b2c008/scripts/build-binary#L27-L38 ldflags = [ "-w" @@ -72,6 +78,11 @@ buildGoModule rec { install -D $GOPATH/bin/rke2 $out/bin/rke2 wrapProgram $out/bin/rke2 \ --prefix PATH : ${lib.makeBinPath buildInputs} + + install -D ./bundle/bin/rke2-killall.sh $out/bin/rke2-killall.sh + wrapProgram $out/bin/rke2-killall.sh \ + --prefix PATH : ${lib.makeBinPath [ systemd gnugrep gnused ]} \ + --prefix PATH : ${lib.makeBinPath buildInputs} ''; doCheck = false; diff --git a/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch b/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch new file mode 100644 index 000000000000..c7b5c4490873 --- /dev/null +++ b/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch @@ -0,0 +1,14 @@ +diff --git a/bundle/bin/rke2-killall.sh b/bundle/bin/rke2-killall.sh +index 1099ad90..db8a7ea9 100755 +--- a/bundle/bin/rke2-killall.sh ++++ b/bundle/bin/rke2-killall.sh +@@ -54,8 +54,7 @@ export PATH=$PATH:/var/lib/rancher/rke2/bin + + set -x + +-systemctl stop rke2-server.service || true +-systemctl stop rke2-agent.service || true ++systemctl stop rke2.service || true + + killtree $({ set +x; } 2>/dev/null; getshims; set -x) + From 7f6cd3837d86cb4bf15eb06913b8f75f572a9d90 Mon Sep 17 00:00:00 2001 From: Mogeko Date: Fri, 21 Jun 2024 10:50:41 +0800 Subject: [PATCH 2/2] nixos/rke2: modify the systemd unit name to be consistent with the upstream remove `fix-systemd-unit-name.patch`. --- nixos/modules/services/cluster/rke2/default.nix | 2 +- .../networking/cluster/rke2/builder.nix | 3 --- .../cluster/rke2/fix-systemd-unit-name.patch | 14 -------------- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch diff --git a/nixos/modules/services/cluster/rke2/default.nix b/nixos/modules/services/cluster/rke2/default.nix index 9ddbd299fdf8..51b849ebcc80 100644 --- a/nixos/modules/services/cluster/rke2/default.nix +++ b/nixos/modules/services/cluster/rke2/default.nix @@ -241,7 +241,7 @@ in "kernel.panic_on_oops" = 1; }; - systemd.services.rke2 = { + systemd.services."rke2-${cfg.role}" = { description = "Rancher Kubernetes Engine v2"; documentation = [ "https://github.com/rancher/rke2#readme" ]; after = [ "network-online.target" ]; diff --git a/pkgs/applications/networking/cluster/rke2/builder.nix b/pkgs/applications/networking/cluster/rke2/builder.nix index 190251cfd716..58a9d6c629ea 100644 --- a/pkgs/applications/networking/cluster/rke2/builder.nix +++ b/pkgs/applications/networking/cluster/rke2/builder.nix @@ -44,9 +44,6 @@ buildGoModule rec { lvm2 # dmsetup ]; - # Patch the systemd unit name to be `rke2.service`. - patches = [ ./fix-systemd-unit-name.patch ]; - # See: https://github.com/rancher/rke2/blob/e7f87c6dd56fdd76a7dab58900aeea8946b2c008/scripts/build-binary#L27-L38 ldflags = [ "-w" diff --git a/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch b/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch deleted file mode 100644 index c7b5c4490873..000000000000 --- a/pkgs/applications/networking/cluster/rke2/fix-systemd-unit-name.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/bundle/bin/rke2-killall.sh b/bundle/bin/rke2-killall.sh -index 1099ad90..db8a7ea9 100755 ---- a/bundle/bin/rke2-killall.sh -+++ b/bundle/bin/rke2-killall.sh -@@ -54,8 +54,7 @@ export PATH=$PATH:/var/lib/rancher/rke2/bin - - set -x - --systemctl stop rke2-server.service || true --systemctl stop rke2-agent.service || true -+systemctl stop rke2.service || true - - killtree $({ set +x; } 2>/dev/null; getshims; set -x) -