]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: try to acquire lock early in reporter's loop
authorGuillaume Abrioux <gabrioux@ibm.com>
Tue, 20 Jun 2023 12:24:42 +0000 (14:24 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 14:52:53 +0000 (14:52 +0000)
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 <gabrioux@ibm.com>
(cherry picked from commit 3f7384c7e1a9656dcc91fcd9e34c9095371a2a1e)

src/cephadm/node-proxy/reporter.py

index a5ba531d1a8def19ff102df5c7d67c158933c257..07ac637bf1c8ced25f2a0f044177e317c8a73324 100644 (file)
@@ -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)