From: John Mulligan Date: Mon, 9 Mar 2026 20:49:26 +0000 (-0400) Subject: mgr/cephadm: add custom choose_next_action to monitoring services X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=318cc0824ea811824e39321e2ed4367e6b403193;p=ceph.git mgr/cephadm: add custom choose_next_action to monitoring services Like the previous commit, update the prometheus, node-exporter, and alertmanager services to use choose_next_action and share the logic of that function via next_action_for_mgmt_stack_service. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/cephadm/services/monitoring.py b/src/pybind/mgr/cephadm/services/monitoring.py index 3dc54f667a93..b36e2071ee1b 100644 --- a/src/pybind/mgr/cephadm/services/monitoring.py +++ b/src/pybind/mgr/cephadm/services/monitoring.py @@ -14,7 +14,12 @@ from cephadm.tlsobject_types import TLSCredentials from orchestrator import DaemonDescription from ceph.deployment.service_spec import AlertManagerSpec, GrafanaSpec, ServiceSpec, \ SNMPGatewaySpec, PrometheusSpec, MgmtGatewaySpec -from cephadm.services.cephadmservice import CephadmService, CephadmDaemonDeploySpec, get_dashboard_urls +from cephadm.services.cephadmservice import ( + CephadmDaemonDeploySpec, + CephadmService, + get_dashboard_urls, + next_action_for_mgmt_stack_service, +) from mgr_util import build_url, password_hash from ceph.deployment.utils import wrap_ipv6 from .. import utils @@ -472,6 +477,24 @@ class AlertmanagerService(CephadmService): return HandleCommandResult(-errno.EBUSY, '', warn_message) return HandleCommandResult(0, warn_message, '') + manages_own_next_action = True + + 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. + """ + return next_action_for_mgmt_stack_service( + scheduled_action, daemon_type, spec, curr_deps, last_deps + ) + @register_cephadm_service class PrometheusService(CephadmService): @@ -757,6 +780,24 @@ class PrometheusService(CephadmService): return '/federate' return '/prometheus/federate' + manages_own_next_action = True + + 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. + """ + return next_action_for_mgmt_stack_service( + scheduled_action, daemon_type, spec, curr_deps, last_deps + ) + @register_cephadm_service class NodeExporterService(CephadmService): @@ -808,6 +849,24 @@ class NodeExporterService(CephadmService): out = f'It is presumed safe to stop {names}' return HandleCommandResult(0, out, '') + manages_own_next_action = True + + 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. + """ + return next_action_for_mgmt_stack_service( + scheduled_action, daemon_type, spec, curr_deps, last_deps + ) + @register_cephadm_service class LokiService(CephadmService):