From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AB491158020 for ; Sun, 11 Dec 2022 21:13:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B6631E0826; Sun, 11 Dec 2022 21:13:55 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 980AAE0826 for ; Sun, 11 Dec 2022 21:13:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B80EB341159 for ; Sun, 11 Dec 2022 21:13:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 18D01779 for ; Sun, 11 Dec 2022 21:13:53 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1670793228.70fa996d6be6a797e2d54c5320f021d23f30b249.zmedico@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-cluster/k3s/files/, sys-cluster/k3s/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-cluster/k3s/files/k3s-killall.sh sys-cluster/k3s/k3s-1.25.4_p1.ebuild X-VCS-Directories: sys-cluster/k3s/files/ sys-cluster/k3s/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 70fa996d6be6a797e2d54c5320f021d23f30b249 X-VCS-Branch: master Date: Sun, 11 Dec 2022 21:13:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5d099598-922c-4477-859a-81146a98c1d4 X-Archives-Hash: 8e7fa09731d62e43dda01b9f5223e8fe commit: 70fa996d6be6a797e2d54c5320f021d23f30b249 Author: Zac Medico gentoo org> AuthorDate: Sun Dec 11 21:02:08 2022 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Dec 11 21:13:48 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70fa996d sys-cluster/k3s: add k3s-killall script Closes: https://bugs.gentoo.org/885389 Signed-off-by: Zac Medico gentoo.org> sys-cluster/k3s/files/k3s-killall.sh | 78 ++++++++++++++++++++++++++++++++++++ sys-cluster/k3s/k3s-1.25.4_p1.ebuild | 1 + 2 files changed, 79 insertions(+) diff --git a/sys-cluster/k3s/files/k3s-killall.sh b/sys-cluster/k3s/files/k3s-killall.sh new file mode 100644 index 000000000000..a3aa2fcf3770 --- /dev/null +++ b/sys-cluster/k3s/files/k3s-killall.sh @@ -0,0 +1,78 @@ +#!/bin/sh +[ $(id -u) -eq 0 ] || exec sudo $0 $@ + +for bin in /var/lib/rancher/k3s/data/**/bin/; do + [ -d $bin ] && export PATH=$PATH:$bin:$bin/aux +done + +set -x + +for service in /etc/systemd/system/k3s*.service; do + [ -s $service ] && systemctl stop $(basename $service) +done + +for service in /etc/init.d/k3s*; do + [ -x $service ] && $service stop +done + +pschildren() { + ps -e -o ppid= -o pid= | \ + sed -e 's/^\s*//g; s/\s\s*/\t/g;' | \ + grep -w "^$1" | \ + cut -f2 +} + +pstree() { + for pid in $@; do + echo $pid + for child in $(pschildren $pid); do + pstree $child + done + done +} + +killtree() { + kill -9 $( + { set +x; } 2>/dev/null; + pstree $@; + set -x; + ) 2>/dev/null +} + +getshims() { + ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 +} + +killtree $({ set +x; } 2>/dev/null; getshims; set -x) + +do_unmount_and_remove() { + set +x + while read -r _ path _; do + case "$path" in $1*) echo "$path" ;; esac + done < /proc/self/mounts | sort -r | xargs -r -t -n 1 sh -c 'umount "$0" && rm -rf "$0"' + set -x +} + +do_unmount_and_remove '/run/k3s' +do_unmount_and_remove '/var/lib/rancher/k3s' +do_unmount_and_remove '/var/lib/kubelet/pods' +do_unmount_and_remove '/var/lib/kubelet/plugins' +do_unmount_and_remove '/run/netns/cni-' + +# Remove CNI namespaces +ip netns show 2>/dev/null | grep cni- | xargs -r -t -n 1 ip netns delete + +# Delete network interface(s) that match 'master cni0' +ip link show 2>/dev/null | grep 'master cni0' | while read ignore iface ignore; do + iface=${iface%%@*} + [ -z "$iface" ] || ip link delete $iface +done +ip link delete cni0 +ip link delete flannel.1 +ip link delete flannel-v6.1 +ip link delete kube-ipvs0 +ip link delete flannel-wg +ip link delete flannel-wg-v6 +rm -rf /var/lib/cni/ +iptables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | iptables-restore +ip6tables-save | grep -v KUBE- | grep -v CNI- | grep -iv flannel | ip6tables-restore diff --git a/sys-cluster/k3s/k3s-1.25.4_p1.ebuild b/sys-cluster/k3s/k3s-1.25.4_p1.ebuild index 993f21c2a09d..aaae4d40b59d 100644 --- a/sys-cluster/k3s/k3s-1.25.4_p1.ebuild +++ b/sys-cluster/k3s/k3s-1.25.4_p1.ebuild @@ -92,6 +92,7 @@ src_compile() { src_install() { dobin "dist/artifacts/${PN}" + newbin "${FILESDIR}/k3s-killall.sh" k3s-killall use kubectl-symlink && dosym k3s /usr/bin/kubectl systemd_dounit "${FILESDIR}/${PN}.service" newinitd "${FILESDIR}/${PN}.initd" "${PN}"