]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add new choose_next_action method to CephadmService
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 9 Mar 2026 20:02:53 +0000 (16:02 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 26 Mar 2026 13:31:39 +0000 (09:31 -0400)
Add a new method to the CephadmService ABC. This method allows
service types to customize behavior when determining what
action needs to be taken if dependencies are changed, etc.

The server.py method _check_daemons uses cascading if-statements
that would look for differences between old and new dependencies
and check various properties to customize the type of action
cephadm is to take next. For example:
the nfs service must be *redeploy*ed instead of *reconfig*ured
when a dependency other than a kmip configuration has been
changed. The new choose_next_action method will be added
to _check_daemons to eventually replace these special cases here
and associate them with the various CephadmService subclasses.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/cephadm/services/cephadmservice.py

index d2ab1c4c2920fdd446c7e007ab961c4c35300313..e7344bae95a9b6104a1422d8ddeeaffddb2c1c9f 100644 (file)
@@ -886,6 +886,35 @@ class CephadmService(metaclass=ABCMeta):
     def has_placement_changed(self, deps: List[str], spec: ServiceSpec) -> bool:
         return False
 
+    # manages_own_next_action allows the CephadmService subclasses
+    # to incrementally support using choose_next_action instead of
+    # "hard coded" blocks in the _check_daemons function.
+    manages_own_next_action = False
+
+    def choose_next_action(
+        self,
+        scheduled_action: utils.Action,
+        daemon_type: Optional[str],
+        spec: Optional[ServiceSpec],
+        curr_deps: List[str],
+        last_deps: List[str],
+    ) -> utils.Action:
+        """Given the scheduled_action, service spec, daemon_type, and
+        current and previous dependency lists return the next action that
+        this service would prefer cephadm take.
+        """
+        if curr_deps == last_deps:
+            return scheduled_action
+        sym_diff = set(curr_deps).symmetric_difference(last_deps)
+        logger.info(
+            'Reconfigure wanted %s: deps %r -> %r (diff %r)',
+            spec.service_name() if spec else daemon_type,
+            last_deps,
+            curr_deps,
+            sym_diff,
+        )
+        return utils.Action.RECONFIG
+
 
 class CephService(CephadmService):