From 571333c1f30286662a49ddddcbaba7640682dc8c Mon Sep 17 00:00:00 2001 From: Jing Geng Date: Wed, 9 Nov 2022 18:19:28 +0000 Subject: [PATCH] Look up ep_id instead of the entire set in new snapshot --- .../plugins/ml2/drivers/calico/status.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/networking-calico/networking_calico/plugins/ml2/drivers/calico/status.py b/networking-calico/networking_calico/plugins/ml2/drivers/calico/status.py index 24f8ca19cb4..a561a24cd6c 100644 --- a/networking-calico/networking_calico/plugins/ml2/drivers/calico/status.py +++ b/networking-calico/networking_calico/plugins/ml2/drivers/calico/status.py @@ -101,20 +101,19 @@ def _post_snapshot_hook(self, old_endpoints_by_host): # Look for previous endpoints that are no longer present... for hostname, ep_ids in old_endpoints_by_host.items(): LOG.info("host: %s", hostname) + # Avoid self._endpoints_by_host[hostname] since that would + # auto-create the entry in the new dict, which would cause a + # leak. + new_ep_ids = self._endpoints_by_host.get(hostname, set()) # Check for particular endpoints that have disappeared, and # signal those. - for ep_id in ep_ids: - # Avoid self._endpoints_by_host[hostname] since that would - # auto-create the entry in the new dict, which would cause a - # leak. - new_ep_ids = self._endpoints_by_host.get(hostname, set()) - if ep_ids not in new_ep_ids: - LOG.info("signal None for %s", ep_id.endpoint) - self.calico_driver.on_port_status_changed( - hostname, - ep_id.endpoint, - None, - priority="low") + for ep_id in ep_ids.difference(new_ep_ids): + LOG.info("signal None for %s", ep_id.endpoint) + self.calico_driver.on_port_status_changed( + hostname, + ep_id.endpoint, + None, + priority="low") self.processing_snapshot = False def _on_status_set(self, response, hostname):