Skip to content

Commit

Permalink
Fix for kill all to not delete the data dir
Browse files Browse the repository at this point in the history
Add tests to kill all script

Signed-off-by: Vitor Savian <[email protected]>
  • Loading branch information
vitorsavian committed Aug 14, 2024
1 parent d36d1f3 commit 613399e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/nightly-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,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
1 change: 0 additions & 1 deletion bundle/bin/rke2-killall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-'

Expand Down
35 changes: 34 additions & 1 deletion tests/install/install_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,37 @@ def kubectlStatus(vm)
kubectl get node,all -A -o wide
SHELL
end
end
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
4 changes: 4 additions & 0 deletions tests/install/opensuse-leap/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
4 changes: 4 additions & 0 deletions tests/install/rocky-8/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
4 changes: 4 additions & 0 deletions tests/install/ubuntu-2004/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 613399e

Please sign in to comment.