Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix VM selection in clean-e2e.sh #1537

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions hack/clean-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@ docker rm -f vbmc
docker rm -f image-server-e2e
docker rm -f sushy-tools

virsh_vms=$(virsh list --name --all)

for vm in ${virsh_vms}; do
if [[ "${vm}" =~ "bmo-e2e-" ]]; then
virsh -c qemu:///system destroy --domain "${vm}"
virsh -c qemu:///system undefine --domain "${vm}" --nvram --remove-all-storage
fi
done

virsh -c qemu:///system net-destroy baremetal-e2e
virsh -c qemu:///system net-undefine baremetal-e2e
"${REPO_ROOT}/tools/bmh_test/clean_local_bmh_test_setup.sh" "^bmo-e2e-"

rm -rf "${REPO_ROOT}/test/e2e/_artifacts"
rm -rf "${REPO_ROOT}"/artifacts-*
Expand Down
10 changes: 5 additions & 5 deletions tools/bmh_test/clean_local_bmh_test_setup.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/usr/bin/env bash

set -eux
set -ux

BMH_NAME_REGEX="${1:-^bmh-test-}"
# Get a list of all virtual machines
VM_LIST=$(virsh -c qemu:///system list --all --name | grep '^bmh-test-') || true
VM_LIST=$(virsh -c qemu:///system list --all --name | grep "${BMH_NAME_REGEX}")

if [[ -n "${VM_LIST}" ]]; then
# Loop through the list and delete each virtual machine
for vm_name in ${VM_LIST}; do
virsh -c qemu:///system destroy --domain "${vm_name}"
virsh -c qemu:///system undefine --domain "${vm_name}" --remove-all-storage
kubectl delete baremetalhost "${vm_name}" || true
kubectl delete baremetalhost "${vm_name}"
done
else
echo "No virtual machines found. Skipping..."
fi

# Clear vbmc
docker stop vbmc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the harm if we stop it first, why are we removing this? Is there a possibility that it might not exist?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -f makes it unnecessary. We remove it no matter if it runs or not

docker rm vbmc
docker rm -f vbmc

# Clear network
virsh -c qemu:///system net-destroy baremetal-e2e
Expand Down
Loading