From d62d5c6cd23daeb922e5c6f64399cc30596c15a3 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 5 Feb 2021 13:40:53 +0100 Subject: [PATCH 1/2] VR: fix expunging vm will remove dhcp entries of another vm in VR (#4627) Steps to reproduce the issue (1) create two vm wei-001 and wei-002, start them (2) check /etc/cloudstack/dhcpentry.json and /etc/dhcphosts.txt in VR They have entries for both of wei-001 and wei-002 (3) stop wei-002, and restart VR (or restart network with cleanup). check /etc/cloudstack/dhcpentry.json and /etc/dhcphosts.txt in VR They have entries for wei-001 only (as wei-002 is stopped) (4) expunge wei-002. when it is done, check /etc/cloudstack/dhcpentry.json and /etc/dhcphosts.txt in VR They do not have entries for wei-001. VR health check fails at dhcp_check.py and dns_check.py --- systemvm/debian/opt/cloud/bin/cs_dhcp.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs_dhcp.py b/systemvm/debian/opt/cloud/bin/cs_dhcp.py index bb2ff7b07c3..d949981db8b 100755 --- a/systemvm/debian/opt/cloud/bin/cs_dhcp.py +++ b/systemvm/debian/opt/cloud/bin/cs_dhcp.py @@ -28,13 +28,10 @@ def merge(dbag, data): else: remove_keys = set() for key, entry in dbag.iteritems(): - if key != 'id' and entry['mac_address'] == data['mac_address']: + if key != 'id' and entry['mac_address'] == data['mac_address'] and data['remove']: remove_keys.add(key) break - if data['remove'] and key not in remove_keys: - remove_keys.add(key) - for remove_key in remove_keys: del(dbag[remove_key]) From c9c1d4a6e58739af92639253f5c3c09aecec0468 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Fri, 5 Feb 2021 18:12:12 +0530 Subject: [PATCH 2/2] marvin: fix test failures when changing service offering of a VM (#4651) Co-authored-by: Pearl Dsilva --- .../smoke/test_service_offerings.py | 17 +++++++++++++ test/integration/smoke/test_vm_snapshots.py | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py index 0e7f068a277..0ee055ad0f4 100644 --- a/test/integration/smoke/test_service_offerings.py +++ b/test/integration/smoke/test_service_offerings.py @@ -502,6 +502,23 @@ class TestServiceOfferings(cloudstackTestCase): self.skipTest("Skipping this test for {} due to bug CS-38153".format(self.hypervisor)) try: self.medium_virtual_machine.stop(self.apiclient) + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + # Ensure that VM is in stopped state + list_vm_response = list_virtual_machines( + self.apiclient, + id=self.medium_virtual_machine.id + ) + if isinstance(list_vm_response, list): + vm = list_vm_response[0] + if vm.state == 'Stopped': + self.debug("VM state: %s" % vm.state) + break + if timeout == 0: + raise Exception( + "Failed to stop VM (ID: %s) in change service offering" % vm.id) + timeout = timeout - 1 except Exception as e: self.fail("Failed to stop VM: %s" % e) diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py index a6803b80eda..ce63ed4aa63 100644 --- a/test/integration/smoke/test_vm_snapshots.py +++ b/test/integration/smoke/test_vm_snapshots.py @@ -454,6 +454,30 @@ class TestChangeServiceOfferingForVmWithSnapshots(cloudstackTestCase): self.debug("Stopping VM - ID: %s" % virtual_machine.id) try: virtual_machine.stop(self.apiclient) + timeout = self.services["timeout"] + + while True: + time.sleep(self.services["sleep"]) + + # Ensure that VM is in stopped state + list_vm_response = list_virtual_machines( + self.apiclient, + id=virtual_machine.id + ) + + if isinstance(list_vm_response, list): + + vm = list_vm_response[0] + if vm.state == 'Stopped': + self.debug("VM state: %s" % vm.state) + break + + if timeout == 0: + raise Exception( + "Failed to stop VM (ID: %s) in change service offering" % vm.id) + + timeout = timeout - 1 + except Exception as e: self.fail("Failed to stop VM: %s" % e)