]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: fix waiting for mgr to warm up 45773/head
authorYaarit Hatuka <yaarit@redhat.com>
Tue, 9 Nov 2021 18:31:11 +0000 (18:31 +0000)
committerLaura Flores <lflores@redhat.com>
Tue, 5 Apr 2022 00:10:52 +0000 (19:10 -0500)
1. The implementation of config_notify() in telemetry module sets the
flag for event, which is supposed to wake up the 'serve' thread whenever
a config option is changed. The problem is that we call config_notify()
at the beginning of serve(), before we enter its 'run' loop. This call
sets the event which cancels the 10 seconds wait for the mgr to warm up.
To fix this, we extract the logic of updating the config options to a
separate function (config_update_module_option()), and call it on
__init__, instead of calling config_notify() in serve().

2. We should always wait for the mgr to warm up here (10 seconds). In
case of a sporadic event (e.g. a config option change via CLI) the event
will be set, and wait will return immediately. We enforce this wait by
using time.sleep(10) instead of event.wait(10).

Fixes: https://tracker.ceph.com/issues/53204
Signed-off-by: Yaarit Hatuka <yaarit@redhat.com>
(cherry picked from commit fa5cc0ca081ca3cce552e0cb21a1e17273cf3482)

 Conflicts:
src/pybind/mgr/telemetry/module.py

- Several options under __init__ had to be removed that were not present
  in Pacific
- No type checking in Pacific

src/pybind/mgr/telemetry/module.py

index f025e94013a81d05951e2bbea413ca2ba1ea83d0..41b8a4b111c9245a407d0bba8d6aed6f281d2045 100644 (file)
@@ -204,13 +204,17 @@ class Module(MgrModule):
         self.last_report = dict()
         self.report_id = None
         self.salt = None
+        self.config_update_module_option()
 
-    def config_notify(self):
+    def config_update_module_option(self):
         for opt in self.MODULE_OPTIONS:
             setattr(self,
                     opt['name'],
                     self.get_module_option(opt['name']))
             self.log.debug(' %s = %s', opt['name'], getattr(self, opt['name']))
+
+    def config_notify(self):
+        self.config_update_module_option()
         # wake up serve() thread
         self.event.set()
 
@@ -823,11 +827,10 @@ class Module(MgrModule):
 
     def serve(self):
         self.load()
-        self.config_notify()
         self.run = True
 
         self.log.debug('Waiting for mgr to warm up')
-        self.event.wait(10)
+        time.sleep(10)
 
         while self.run:
             self.event.clear()