Skip to content

Commit 33ecef1

Browse files
committed
Fix remove_vm logic when scheduler is enabled
1 parent e22a81e commit 33ecef1

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

test/bin/scenario.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ launch_vm() {
10721072

10731073
# Cleanup the failed VM before trying to recreate it
10741074
# Keep the storage pool for the subsequent VM creation
1075-
remove_vm "${vmname}" true
1075+
# Force destroy even in scheduler mode so retry can work
1076+
remove_vm "${vmname}" true true
10761077
done
10771078

10781079
if ${vm_created} ; then
@@ -1142,23 +1143,25 @@ launch_vm() {
11421143
}
11431144

11441145
# Clean up the resources for one VM, optionally skipping storage pool removal
1146+
# Parameters:
1147+
# vmname: name of the VM to remove
1148+
# keep_pool: if true, keep the storage pool (default: false)
1149+
# force_destroy: if true, destroy VM even in scheduler mode (default: false)
1150+
# Used by retry logic to clean up failed VM creation attempts
11451151
remove_vm() {
11461152
local -r vmname="${1}"
11471153
local -r keep_pool="${2:-false}"
1154+
local -r force_destroy="${3:-false}"
11481155
local -r full_vmname="$(full_vm_name "${vmname}")"
11491156

1150-
# In scheduler mode, the scheduler handles VM lifecycle
1151-
# We only release the VM back to the scheduler, not destroy it
1152-
if [ "${SCHEDULER_ENABLED}" = "true" ]; then
1153-
echo "Scheduler mode: releasing VM ${full_vmname} to scheduler"
1154-
# The scheduler will handle destruction when no compatible scenarios remain
1155-
# Just clean up scenario-specific state
1156-
rm -rf "${SCENARIO_INFO_DIR}/${SCENARIO}/vms/${vmname}"
1157+
# In scheduler mode, skip VM destruction unless forced (needed for retry logic)
1158+
# This allows VMs to be reused by subsequent scenarios
1159+
if [ "${SCHEDULER_ENABLED}" = "true" ] && [ "${force_destroy}" != "true" ]; then
11571160
return 0
11581161
fi
11591162

11601163
# Remove the actual VM
1161-
if sudo virsh dumpxml "${full_vmname}" >/dev/null; then
1164+
if sudo virsh dumpxml "${full_vmname}" >/dev/null 2>&1; then
11621165
if ! sudo virsh dominfo "${full_vmname}" | grep '^State' | grep -q 'shut off'; then
11631166
sudo virsh destroy --graceful "${full_vmname}" || true
11641167
fi

test/scenarios/presubmits/el96-src@storage-version-migrator.sh renamed to test/scenarios/presubmits/el96-src@storage-version-migration.sh

File renamed without changes.

0 commit comments

Comments
 (0)