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
This commit is contained in:
Wei Zhou 2021-02-05 13:40:53 +01:00 committed by GitHub
parent 29e309839d
commit d62d5c6cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -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])