]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: only reapply osd spec if devices have changed
authorSage Weil <sage@newdream.net>
Tue, 2 Feb 2021 23:09:15 +0000 (17:09 -0600)
committerSebastian Wagner <sebastian.wagner@suse.com>
Mon, 22 Feb 2021 16:34:11 +0000 (17:34 +0100)
This avoids a lot of useless work when the devices have not changed.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit b129c1312113f56a227caeb535f656f5a090a85f)

src/pybind/mgr/cephadm/inventory.py
src/pybind/mgr/cephadm/services/osd.py

index 944d88c03fe2a3b29d45b4c7dd784363fdd06585..600fc64ac6c47854d2ea3c84a62033679060c2be 100644 (file)
@@ -174,6 +174,9 @@ class SpecStore():
             service_name, specs))
         return specs
 
+    def get_created(self, spec: ServiceSpec) -> Optional[datetime.datetime]:
+        return self.spec_created.get(spec.service_name())
+
 
 class HostCache():
     """
@@ -609,6 +612,20 @@ class HostCache():
         # already up to date:
         return False
 
+    def osdspec_needs_apply(self, host: str, spec: ServiceSpec) -> bool:
+        if (
+            host not in self.devices
+            or host not in self.last_device_change
+            or host not in self.last_device_update
+            or host not in self.osdspec_last_applied
+            or spec.service_name() not in self.osdspec_last_applied[host]
+        ):
+            return True
+        created = self.mgr.spec_store.get_created(spec)
+        if created and created > self.last_device_change[host]:
+            return True
+        return self.osdspec_last_applied[host][spec.service_name()] < self.last_device_change[host];
+
     def update_last_etc_ceph_ceph_conf(self, host: str) -> None:
         if not self.mgr.last_monmap:
             return
index c9182b43d750782fc7190304adfbaceccc1e3c80..8aa36d84799746d08e7f509a7732ef9c8c3eb3f6 100644 (file)
@@ -13,6 +13,7 @@ from datetime import datetime
 import orchestrator
 from cephadm.serve import CephadmServe
 from cephadm.utils import forall_hosts
+from ceph.utils import datetime_now
 from orchestrator import OrchestratorError
 from mgr_module import MonCommandFailed
 
@@ -36,6 +37,12 @@ class OSDService(CephService):
 
         @forall_hosts
         def create_from_spec_one(host: str, drive_selection: DriveSelection) -> Optional[str]:
+            # skip this host if there has been no change in inventory
+            if not self.mgr.cache.osdspec_needs_apply(host, drive_group):
+                self.mgr.log.debug("skipping apply of %s on %s (no change)" % (
+                    host, drive_group))
+                return None
+
             cmd = self.driveselection_to_ceph_volume(drive_selection,
                                                      osd_id_claims.get(host, []))
             if not cmd: