From 9d3a7be4dd9f68acab05ba28f89e1467622205b8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 21 Dec 2023 09:47:57 +0100 Subject: [PATCH 1/2] server: fix debug message when expunge a vm (#8374) This PR fixes the debug message when expunge a vm --- .../java/com/cloud/vm/VirtualMachineManagerImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index 4c8883476a2..a49609fc374 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -602,7 +602,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { if (vm == null || vm.getRemoved() != null) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Unable to find vm or vm is destroyed: " + vm); + s_logger.debug("Unable to find vm or vm is expunged: " + vm); } return; } @@ -612,17 +612,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) { - s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); - throw new CloudRuntimeException("Unable to destroy " + vm); + s_logger.debug("Unable to expunge the vm because it is not in the correct state: " + vm); + throw new CloudRuntimeException("Unable to expunge " + vm); } } catch (final NoTransitionException e) { - s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); - throw new CloudRuntimeException("Unable to destroy " + vm, e); + s_logger.debug("Unable to expunge the vm because it is not in the correct state: " + vm); + throw new CloudRuntimeException("Unable to expunge " + vm, e); } if (s_logger.isDebugEnabled()) { - s_logger.debug("Destroying vm " + vm); + s_logger.debug("Expunging vm " + vm); } final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); From d83d994929828ab63f23047dfe819c4c2d637d8e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 21 Dec 2023 20:54:43 +0530 Subject: [PATCH 2/2] test: additional check to ensure hosts are left in up state (#8383) With this change, a fix is added for failures seen with test_08_migrate_vm or other migration-related tests because the target host is in `Connecting` state, #8356 (comment) #8374 (comment) and more --- test/integration/smoke/test_vm_life_cycle.py | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index a9a554e19ad..6c824c1fe7d 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -1011,8 +1011,37 @@ class TestSecuredVmMigration(cloudstackTestCase): @classmethod def tearDownClass(cls): + if cls.hypervisor.lower() in ["kvm"]: + cls.ensure_all_hosts_are_up() super(TestSecuredVmMigration, cls).tearDownClass() + @classmethod + def ensure_all_hosts_are_up(cls): + hosts = Host.list( + cls.apiclient, + zoneid=cls.zone.id, + type='Routing', + hypervisor='KVM' + ) + for host in hosts: + if host.state != "Up": + SshClient(host.ipaddress, port=22, user=cls.hostConfig["username"], passwd=cls.hostConfig["password"]) \ + .execute("service cloudstack-agent stop ; \ + sleep 10 ; \ + service cloudstack-agent start") + interval = 5 + retries = 10 + while retries > -1: + time.sleep(interval) + restarted_host = Host.list( + cls.apiclient, + hostid=host.id, + type='Routing' + )[0] + if restarted_host.state == "Up": + break + retries = retries - 1 + def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection()