]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orchestrator: Introduce OutdatableDictMixin
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 9 Jul 2019 13:08:53 +0000 (15:08 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Fri, 12 Jul 2019 07:31:54 +0000 (09:31 +0200)
No need for a persistent cache in DeepSea

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/deepsea/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/ssh/module.py

index 826ef6aa602c61a9abe4a29cdd9d6b59cd609b63..c7e20784aa18f990a6d71f88c8e894472836f510 100644 (file)
@@ -108,8 +108,8 @@ class DeepSeaOrchestrator(MgrModule, orchestrator.Orchestrator):
         self._last_failure_msg = None
         self._all_completions = dict()
         self._completion_lock = Lock()
-        self.inventory_cache = orchestrator.OutdatableDict(self, 'inventory_cache')
-        self.service_cache = orchestrator.OutdatableDict(self, 'service_cache')
+        self.inventory_cache = orchestrator.OutdatableDict()
+        self.service_cache = orchestrator.OutdatableDict()
 
     def available(self):
         if not self._config_valid():
index ec0e8a480408b73f2f0cd48f95d48198ea3fcc5a..bdf774dbf482211db3cd863c76e857401e1a2f73 100644 (file)
@@ -1039,7 +1039,7 @@ class OutdatableData(object):
         return 'OutdatableData(data={}, last_refresh={})'.format(self.data, self.last_refresh)
 
 
-class OutdatableDict(PersistentStoreDict):
+class OutdatableDictMixin(object):
     """
     Toolbox for implementing a cache. As every orchestrator has
     different needs, we cannot implement any logic here.
@@ -1047,16 +1047,16 @@ class OutdatableDict(PersistentStoreDict):
 
     def __getitem__(self, item):
         # type: (str) -> OutdatableData
-        return OutdatableData.from_json(super(OutdatableDict, self).__getitem__(item))
+        return OutdatableData.from_json(super(OutdatableDictMixin, self).__getitem__(item))
 
     def __setitem__(self, key, value):
         # type: (str, OutdatableData) -> None
         val = None if value is None else value.json()
-        super(OutdatableDict, self).__setitem__(key, val)
+        super(OutdatableDictMixin, self).__setitem__(key, val)
 
     def items(self):
         # type: () -> Iterator[Tuple[str, OutdatableData]]
-        for item in super(OutdatableDict, self).items():
+        for item in super(OutdatableDictMixin, self).items():
             k, v = item
             yield k, OutdatableData.from_json(v)
 
@@ -1076,3 +1076,9 @@ class OutdatableDict(PersistentStoreDict):
         outdated = [item[0] for item in self.items() if item[1].outdated()]
         for o in outdated:
             del self[o]
+
+class OutdatablePersistentDict(OutdatableDictMixin, PersistentStoreDict):
+    pass
+
+class OutdatableDict(OutdatableDictMixin, dict):
+    pass
index 43072c4d382d34bdcea2706d581685406e2d18c0..73675e520572ba91f80d480c9301becbaec48a58 100644 (file)
@@ -147,7 +147,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
         # cache is invalidated by
         # 1. timeout
         # 2. refresh parameter
-        self.inventory_cache = orchestrator.OutdatableDict(self, self._STORE_HOST_PREFIX)
+        self.inventory_cache = orchestrator.OutdatablePersistentDict(self, self._STORE_HOST_PREFIX)
 
     def handle_command(self, inbuf, command):
         if command["prefix"] == "ssh set-ssh-config":