From: Guillaume Abrioux Date: Tue, 20 Jun 2023 12:24:42 +0000 (+0200) Subject: node-proxy: try to acquire lock early in reporter's loop X-Git-Tag: v19.3.0~102^2~77 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3f7384c7e1a9656dcc91fcd9e34c9095371a2a1e;p=ceph.git node-proxy: try to acquire lock early in reporter's loop The lock should be acquired early in this loop. If the lock gets acquired by another call after we enter that condition *and* before Reporter.loop() actually acquires it, it can lead to issue if during this short amount of time the value of `data_ready` gets modified Signed-off-by: Guillaume Abrioux --- diff --git a/src/cephadm/node-proxy/reporter.py b/src/cephadm/node-proxy/reporter.py index a5ba531d1a8d..07ac637bf1c8 100644 --- a/src/cephadm/node-proxy/reporter.py +++ b/src/cephadm/node-proxy/reporter.py @@ -28,10 +28,11 @@ class Reporter: # scenario probably we should just send the sub-parts # that have changed to minimize the traffic in # dense clusters + log.logger.debug("waiting for a lock.") + self.system.lock.acquire() + log.logger.debug("lock acquired.") if self.system.data_ready: - log.logger.debug("waiting for a lock.") - self.system.lock.acquire() - log.logger.debug("lock acquired.") + log.logger.info('data ready to be sent to the mgr.') if not self.system.get_system() == self.system.previous_data: log.logger.info('data has changed since last iteration.') d = self.system.get_system() @@ -46,6 +47,6 @@ class Reporter: self.system.previous_data = self.system.get_system() else: log.logger.info('no diff, not sending data to the mgr.') - self.system.lock.release() - log.logger.debug("lock released.") + self.system.lock.release() + log.logger.debug("lock released.") time.sleep(5)