Skip to content

Commit 6aba0cd

Browse files
mgr/cephadm: allow services to be conditionally ranked
Add a spec argument to the `ranked` function. If this function returns true the service will use ranks. In some cases we want 'rankedness' to be conditional on parameters of the given service spec. Signed-off-by: John Mulligan <[email protected]>
1 parent 59acb54 commit 6aba0cd

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/pybind/mgr/cephadm/module.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3296,6 +3296,9 @@ def _plan(self, spec: ServiceSpec) -> dict:
32963296
'data': self._preview_osdspecs(osdspecs=[cast(DriveGroupSpec, spec)])}
32973297

32983298
svc = self.cephadm_services[spec.service_type]
3299+
rank_map = None
3300+
if svc.ranked(spec):
3301+
rank_map = self.spec_store[spec.service_name()].rank_map
32993302
ha = HostAssignment(
33003303
spec=spec,
33013304
hosts=self.cache.get_schedulable_hosts(),
@@ -3304,7 +3307,7 @@ def _plan(self, spec: ServiceSpec) -> dict:
33043307
networks=self.cache.networks,
33053308
daemons=self.cache.get_daemons_by_service(spec.service_name()),
33063309
allow_colo=svc.allow_colo(),
3307-
rank_map=self.spec_store[spec.service_name()].rank_map if svc.ranked() else None
3310+
rank_map=rank_map
33083311
)
33093312
ha.validate()
33103313
hosts, to_add, to_remove = ha.place()

src/pybind/mgr/cephadm/serve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def has_interface_for_vip(host: str, sspec: ServiceSpec) -> bool:
780780
}
781781

782782
rank_map = None
783-
if svc.ranked():
783+
if svc.ranked(spec):
784784
rank_map = self.mgr.spec_store[spec.service_name()].rank_map or {}
785785
ha = HostAssignment(
786786
spec=spec,

src/pybind/mgr/cephadm/services/cephadmservice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def per_host_daemon_type(self, spec: Optional[ServiceSpec] = None) -> Optional[s
288288
"""
289289
return None
290290

291-
def ranked(self) -> bool:
291+
def ranked(self, spec: ServiceSpec) -> bool:
292292
"""
293293
If True, we will assign a stable rank (0, 1, ...) and monotonically increasing
294294
generation (0, 1, ...) to each daemon we create/deploy.

src/pybind/mgr/cephadm/services/nfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class NFSService(CephService):
2424
TYPE = 'nfs'
2525

26-
def ranked(self) -> bool:
26+
def ranked(self, spec: ServiceSpec) -> bool:
2727
return True
2828

2929
def fence(self, daemon_id: str) -> None:

0 commit comments

Comments
 (0)