From 97d20b69a3c22486e5a59f2c9a9c53374e8f7265 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Wed, 27 Jan 2021 15:34:44 +0000 Subject: [PATCH] VR: fix expunging vm will remove dhcp entries of another vm in VR 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 bb2ff7b07c3b..d949981db8b9 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])