]> 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)
committerMichael Fritch <mfritch@suse.com>
Mon, 13 Jun 2022 16:30:51 +0000 (10:30 -0600)
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 8e21c09879de04f1ed0fba4600de923a285b6cf9..7e45429a930827b1b425834956bb897fd47cf9ca 100644 (file)
@@ -172,6 +172,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():
     """
@@ -593,6 +596,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 c4c9ecd12bc88195ca466a1976ce7dba48377d2d..0501aefcc402aa62ab98ff998a567f8ff6e30f1e 100644 (file)
@@ -12,6 +12,7 @@ from ceph.utils import datetime_to_str, str_to_datetime
 from datetime import datetime
 import orchestrator
 from cephadm.utils import forall_hosts
+from ceph.utils import datetime_now
 from orchestrator import OrchestratorError
 from mgr_module import MonCommandFailed
 
@@ -35,6 +36,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: