From d6c8d9c3aebd8d68033a0e5f97ca65b9d568dd14 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Sun, 27 Sep 2020 09:17:11 +0200 Subject: [PATCH] Stop old validation loops before reinitializing the cluster Whenever the cluster in initialized, new loops for keepalive validation are created. The old loos should be stopped to not overload the nsx with keepalive checks. Change-Id: I6ae746ba11457c141814424f42e9a0c0e2684601 --- vmware_nsxlib/v3/cluster.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vmware_nsxlib/v3/cluster.py b/vmware_nsxlib/v3/cluster.py index 6d8b5229..c5c7bf67 100644 --- a/vmware_nsxlib/v3/cluster.py +++ b/vmware_nsxlib/v3/cluster.py @@ -461,6 +461,7 @@ class ClusteredAPI(object): self._print_keepalive = 0 self._silent = False self._api_call_collectors = [] + self._loops = [] def _init_cluster(*args, **kwargs): self._init_endpoints(providers, min_conns_per_pool, @@ -531,6 +532,11 @@ class ClusteredAPI(object): break eventlet.sleep(0.5) + if self._loops: + for loop in self._loops: + loop.stop() + self._loops = [] + if len(self._endpoints) > 1: # We don't monitor connectivity when one endpoint is available, # since there is no alternative to querying this single backend @@ -543,6 +549,7 @@ class ClusteredAPI(object): loop.start(initial_delay=self._keepalive_interval, periodic_interval_max=self._keepalive_interval, stop_on_exception=False) + self._loops.append(loop) LOG.debug("Done initializing API endpoint(s). " "API cluster health: %s", self.health)