mirror of
https://github.com/k3s-io/k3s.git
synced 2026-05-28 04:34:19 -04:00
Add a change for killall to not unmount server and agent directory
Signed-off-by: Vitor Savian <vitor.savian@suse.com> Add recursive search and deletion of unmounted/mounted dirs in killall Signed-off-by: Vitor Savian <vitor.savian@suse.com> Only clean the server and agent directory if it is uninstall Signed-off-by: Vitor Savian <vitor.savian@suse.com> Add uninstall test to check mount points Signed-off-by: Vitor Savian <vitor.savian@suse.com> Add uninstall test in CI Signed-off-by: Vitor Savian <vitor.savian@suse.com>
This commit is contained in:
parent
82ba778a86
commit
3aceb85c22
9 changed files with 120 additions and 5 deletions
10
.github/workflows/install.yaml
vendored
10
.github/workflows/install.yaml
vendored
|
|
@ -89,6 +89,14 @@ jobs:
|
|||
run: vagrant provision --provision-with=k3s-status
|
||||
- name: "k3s-procps"
|
||||
run: vagrant provision --provision-with=k3s-procps
|
||||
- name: "k3s-mount-directory"
|
||||
run: vagrant provision --provision-with=k3s-mount-directory
|
||||
- name: "k3s-uninstall"
|
||||
run: vagrant provision --provision-with=k3s-uninstall
|
||||
- name: "k3s-check-mount"
|
||||
run: vagrant provision --provision-with=k3s-check-mount
|
||||
- name: "k3s-unmount-dir"
|
||||
run: vagrant provision --provision-with=k3s-unmount-dir
|
||||
- name: Cleanup VM
|
||||
run: vagrant destroy -f
|
||||
- name: On Failure, launch debug session
|
||||
|
|
@ -96,4 +104,4 @@ jobs:
|
|||
if: ${{ failure() }}
|
||||
with:
|
||||
## If no one connects after 5 minutes, shut down server.
|
||||
wait-timeout-minutes: 5
|
||||
wait-timeout-minutes: 5
|
||||
|
|
|
|||
22
install.sh
22
install.sh
|
|
@ -843,7 +843,6 @@ do_unmount_and_remove() {
|
|||
}
|
||||
|
||||
do_unmount_and_remove '/run/k3s'
|
||||
do_unmount_and_remove "${K3S_DATA_DIR}"
|
||||
do_unmount_and_remove '/var/lib/kubelet/pods'
|
||||
do_unmount_and_remove '/var/lib/kubelet/plugins'
|
||||
do_unmount_and_remove '/run/netns/cni-'
|
||||
|
|
@ -902,10 +901,29 @@ for cmd in kubectl crictl ctr; do
|
|||
fi
|
||||
done
|
||||
|
||||
clean_mounted_directory() {
|
||||
if ! grep -q " \$1" /proc/mounts; then
|
||||
rm -rf "\$1"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for path in "\$1"/*; do
|
||||
if [ -d "\$path" ]; then
|
||||
if grep -q " \$path" /proc/mounts; then
|
||||
clean_mounted_directory "\$path"
|
||||
else
|
||||
rm -rf "\$path"
|
||||
fi
|
||||
else
|
||||
rm "\$path"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
rm -rf /etc/rancher/k3s
|
||||
rm -rf /run/k3s
|
||||
rm -rf /run/flannel
|
||||
rm -rf \${K3S_DATA_DIR}
|
||||
clean_mounted_directory \${K3S_DATA_DIR}
|
||||
rm -rf /var/lib/kubelet
|
||||
rm -f ${BIN_DIR}/k3s
|
||||
rm -f ${KILLALL_K3S_SH}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
937085bbac8e3b55209739762e05c2c1006c4f4fe65dba01908f3544dc47da27 install.sh
|
||||
e10b36efb5e7e7692f144582d09f5909a91c5b5996965d643dbe13282befcfc1 install.sh
|
||||
|
|
|
|||
9
tests/install/fedora/Vagrantfile
vendored
9
tests/install/fedora/Vagrantfile
vendored
|
|
@ -43,6 +43,15 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
checkK3sProcesses(test.vm)
|
||||
|
||||
mountDirs(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
runUninstall(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
unmountDir(test.vm)
|
||||
end
|
||||
|
||||
config.vm.provision 'selinux-status', type: 'shell', run: 'once', inline: 'sestatus'
|
||||
|
|
|
|||
|
|
@ -89,4 +89,49 @@ def waitForNodeReady(vm)
|
|||
k3s check-config | grep 'cgroups V2 mounted'
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def mountDirs(vm)
|
||||
vm.provision "k3s-mount-directory", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
||||
sh.inline = <<~SHELL
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
echo 'Mounting server dir'
|
||||
mount --bind /var/lib/rancher/k3s/server /var/lib/rancher/k3s/server
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
|
||||
def runUninstall(vm)
|
||||
vm.provision "k3s-uninstall", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
||||
sh.inline = <<~SHELL
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
echo 'Uninstall k3s'
|
||||
k3s-server-uninstall.sh
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
|
||||
def checkMountPoint(vm)
|
||||
vm.provision "k3s-check-mount", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
||||
sh.inline = <<~SHELL
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
echo 'Check the mount'
|
||||
mount | grep /var/lib/rancher/k3s/server
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
|
||||
def unmountDir(vm)
|
||||
vm.provision "k3s-unmount-dir", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh|
|
||||
sh.inline = <<~SHELL
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
echo 'unmount the mount'
|
||||
umount /var/lib/rancher/k3s/server
|
||||
rm -rf /var/lib/rancher
|
||||
SHELL
|
||||
end
|
||||
end
|
||||
|
|
|
|||
9
tests/install/opensuse-leap/Vagrantfile
vendored
9
tests/install/opensuse-leap/Vagrantfile
vendored
|
|
@ -54,6 +54,15 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
checkK3sProcesses(test.vm)
|
||||
|
||||
mountDirs(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
runUninstall(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
unmountDir(test.vm)
|
||||
end
|
||||
|
||||
%w[libvirt virtualbox vmware_desktop].each do |p|
|
||||
|
|
|
|||
9
tests/install/rocky-8/Vagrantfile
vendored
9
tests/install/rocky-8/Vagrantfile
vendored
|
|
@ -44,6 +44,15 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
checkK3sProcesses(test.vm)
|
||||
|
||||
mountDirs(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
runUninstall(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
unmountDir(test.vm)
|
||||
end
|
||||
|
||||
config.vm.provision 'selinux-status', type: 'shell', run: 'once', inline: 'sestatus'
|
||||
|
|
|
|||
8
tests/install/rocky-9/Vagrantfile
vendored
8
tests/install/rocky-9/Vagrantfile
vendored
|
|
@ -45,6 +45,14 @@ Vagrant.configure("2") do |config|
|
|||
checkK3sProcesses(test.vm)
|
||||
|
||||
checkCGroupV2(test.vm)
|
||||
|
||||
mountDirs(test.vm)
|
||||
|
||||
runUninstall(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
unmountDir(test.vm)
|
||||
end
|
||||
|
||||
config.vm.provision 'selinux-status', type: 'shell', run: 'once', inline: 'sestatus'
|
||||
|
|
|
|||
9
tests/install/ubuntu-2204/Vagrantfile
vendored
9
tests/install/ubuntu-2204/Vagrantfile
vendored
|
|
@ -44,6 +44,15 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
checkCGroupV2(test.vm)
|
||||
|
||||
mountDirs(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
runUninstall(test.vm)
|
||||
|
||||
checkMountPoint(test.vm)
|
||||
|
||||
unmountDir(test.vm)
|
||||
end
|
||||
|
||||
%w[libvirt virtualbox vmware_desktop].each do |p|
|
||||
|
|
|
|||
Loading…
Reference in a new issue