From e5113fe097fce5dce15c53f14d45cb2b5ca2d385 Mon Sep 17 00:00:00 2001 From: Vitor Savian Date: Tue, 13 Aug 2024 16:12:03 -0300 Subject: [PATCH] Fix for kill all to not delete the data dir Add tests to kill all script Signed-off-by: Vitor Savian --- .github/workflows/nightly-install.yaml | 9 +++++++ bundle/bin/rke2-killall.sh | 1 - tests/install/install_util.rb | 35 ++++++++++++++++++++++++- tests/install/opensuse-leap/Vagrantfile | 4 +++ tests/install/rocky-8/Vagrantfile | 4 +++ tests/install/ubuntu-2004/Vagrantfile | 4 +++ 6 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-install.yaml b/.github/workflows/nightly-install.yaml index cdf043d30d..8701d0822a 100644 --- a/.github/workflows/nightly-install.yaml +++ b/.github/workflows/nightly-install.yaml @@ -65,3 +65,12 @@ jobs: - name: "rke2-procps" if: ${{ !contains(matrix.vm, 'windows') }} run: vagrant provision --provision-with=rke2-procps + - name: "rke2-mount-directory" + if: ${{ !contains(matrix.vm, 'windows') }} + run: vagrant provision --provision-with=rke2-mount-directory + - name: "rke2-killall" + if: ${{ !contains(matrix.vm, 'windows') }} + run: vagrant provision --provision-with=rke2-killall + - name: "rke2-check-mount" + if: ${{ !contains(matrix.vm, 'windows') }} + run: vagrant provision --provision-with=rke2-check-mount diff --git a/bundle/bin/rke2-killall.sh b/bundle/bin/rke2-killall.sh index 7e24bb9d35..f9db1010cb 100755 --- a/bundle/bin/rke2-killall.sh +++ b/bundle/bin/rke2-killall.sh @@ -62,7 +62,6 @@ systemctl stop rke2-agent.service || true killtree $({ set +x; } 2>/dev/null; getshims; set -x) do_unmount_and_remove '/run/k3s' -do_unmount_and_remove "${RKE2_DATA_DIR}" do_unmount_and_remove '/var/lib/kubelet/pods' do_unmount_and_remove '/run/netns/cni-' diff --git a/tests/install/install_util.rb b/tests/install/install_util.rb index 114a71bd65..06a340d6cf 100644 --- a/tests/install/install_util.rb +++ b/tests/install/install_util.rb @@ -87,4 +87,37 @@ def kubectlStatus(vm) kubectl get node,all -A -o wide SHELL end -end \ No newline at end of file +end + +def mountDirs(vm) + vm.provision "rke2-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/rke2/server /var/lib/rancher/rke2/server + SHELL + end +end + +def checkMountPoint(vm) + vm.provision "rke2-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/rke2/server + SHELL + end +end + +def runKillAllScript(vm) + vm.provision "rke2-killall", type: "shell", run: ENV['CI'] == 'true' ? 'never' : 'once' do |sh| + sh.inline = <<~SHELL + #!/usr/bin/env bash + set -eu -o pipefail + echo 'Run kill all' + rke2-killall.sh + SHELL + end +end diff --git a/tests/install/opensuse-leap/Vagrantfile b/tests/install/opensuse-leap/Vagrantfile index 8b43db4638..c96c170963 100644 --- a/tests/install/opensuse-leap/Vagrantfile +++ b/tests/install/opensuse-leap/Vagrantfile @@ -40,6 +40,10 @@ Vagrant.configure("2") do |config| kubectlStatus(test.vm) checkRKE2Processes(test.vm) + + mountDirs(test.vm) + runKillAllScript(test.vm) + checkMountPoint(test.vm) end config.vm.provision "install-packages", type: "shell", run: "once" do |sh| diff --git a/tests/install/rocky-8/Vagrantfile b/tests/install/rocky-8/Vagrantfile index 02ec340aa6..0e98f1084c 100644 --- a/tests/install/rocky-8/Vagrantfile +++ b/tests/install/rocky-8/Vagrantfile @@ -41,6 +41,10 @@ Vagrant.configure("2") do |config| kubectlStatus(test.vm) checkRKE2Processes(test.vm) + + mountDirs(test.vm) + runKillAllScript(test.vm) + checkMountPoint(test.vm) end config.vm.provision "install-packages", type: "shell", run: "once" do |sh| diff --git a/tests/install/ubuntu-2004/Vagrantfile b/tests/install/ubuntu-2004/Vagrantfile index 92ea543007..47e47a8b58 100644 --- a/tests/install/ubuntu-2004/Vagrantfile +++ b/tests/install/ubuntu-2004/Vagrantfile @@ -46,6 +46,10 @@ Vagrant.configure("2") do |config| ps auxZ | grep -E 'etcd|kube|rke2|container|confined' | grep -v grep SHELL end + + mountDirs(test.vm) + runKillAllScript(test.vm) + checkMountPoint(test.vm) end config.vm.provision "install-packages", type: "shell", run: "once" do |sh|