From: John Mulligan Date: Mon, 9 Mar 2026 20:02:53 +0000 (-0400) Subject: mgr/cephadm: add new choose_next_action method to CephadmService X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=14bc46490d5946d25f9977065db00def7569a414;p=ceph.git mgr/cephadm: add new choose_next_action method to CephadmService 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 --- diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index d2ab1c4c2920..e7344bae95a9 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -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):