From d62d5c6cd23daeb922e5c6f64399cc30596c15a3 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 5 Feb 2021 13:40:53 +0100 Subject: [PATCH] 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])