Skip to content

Commit 1c89773

Browse files
committed
mgr/cephadm: introduce deployment ordering for services
Some services don't work well with deploying every daemon in parallel and need deployment to follow a certain ordering. This commit sets up the framework for allowing services to specify the order in which its daemons should be deployed. The expectation is that the function will return a dict mapping integers to a list of daemons. When we deploy, we first deploy everything in the "0" entry, then "1" etc. The integers themselves are fairly arbitrary, we just need something sortable. Signed-off-by: Adam King <[email protected]> (cherry picked from commit e8eb36d) Resolves: rhbz#2372821
1 parent 8257fbc commit 1c89773

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/pybind/mgr/cephadm/serve.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def _apply_all_services(self) -> bool:
642642
hosts_altered: Set[str] = set()
643643
all_conflicting_daemons: List[orchestrator.DaemonDescription] = []
644644
all_daemons_needing_fencing: List[orchestrator.DaemonDescription] = []
645-
all_daemons_to_deploy: List[CephadmDaemonDeploySpec] = []
645+
all_daemons_to_deploy: Dict[int, List[CephadmDaemonDeploySpec]] = {}
646646
all_daemons_to_remove: List[orchestrator.DaemonDescription] = []
647647
services_in_need_of_fencing: List[Tuple[ServiceSpec, Dict[int, Dict[int, Optional[str]]]]] = []
648648
for spec in specs:
@@ -654,7 +654,12 @@ def _apply_all_services(self) -> bool:
654654
# compiles all these lists so we can split on host instead of service
655655
all_conflicting_daemons.extend(conflicting_daemons)
656656
all_daemons_needing_fencing.extend(daemons_to_fence)
657-
all_daemons_to_deploy.extend(daemons_to_deploy)
657+
svc = service_registry.get_service(spec.service_type)
658+
service_deploy_ordering = svc.get_daemon_deployment_ordering(daemons_to_deploy)
659+
for tier, daemons_of_tier in service_deploy_ordering.items():
660+
if tier not in all_daemons_to_deploy:
661+
all_daemons_to_deploy[tier] = []
662+
all_daemons_to_deploy[tier].extend(daemons_of_tier)
658663
all_daemons_to_remove.extend(daemons_to_remove)
659664
if service_needs_fencing and rank_map is not None:
660665
services_in_need_of_fencing.append((spec, rank_map))
@@ -721,14 +726,20 @@ async def _deploy_and_remove_all(
721726

722727
return await gather(*futures)
723728

724-
deploy_names = [d.name() for d in all_daemons_to_deploy]
725729
rm_names = (
726730
[d.name() for d in all_daemons_needing_fencing]
727731
+ [d.name() for d in all_conflicting_daemons]
728732
+ [d.name() for d in all_daemons_to_remove]
729733
)
730-
with self.mgr.async_timeout_handler(cmd=f'cephadm deploying ({deploy_names} and removing {rm_names} daemons)'):
731-
results = self.mgr.wait_async(_deploy_and_remove_all(all_daemons_needing_fencing, all_conflicting_daemons, all_daemons_to_deploy, all_daemons_to_remove))
734+
for tier in sorted(all_daemons_to_deploy.keys()):
735+
all_daemons_in_tier_to_deploy = all_daemons_to_deploy[tier]
736+
deploy_names = [d.name() for d in all_daemons_in_tier_to_deploy]
737+
if tier == 0:
738+
with self.mgr.async_timeout_handler(cmd=f'cephadm deploying ({deploy_names} and removing {rm_names} daemons)'):
739+
results = self.mgr.wait_async(_deploy_and_remove_all(all_daemons_needing_fencing, all_conflicting_daemons, all_daemons_in_tier_to_deploy, all_daemons_to_remove))
740+
else:
741+
with self.mgr.async_timeout_handler(cmd=f'cephadm deploying ({deploy_names} daemons)'):
742+
results = self.mgr.wait_async(_deploy_and_remove_all([], [], all_daemons_in_tier_to_deploy, []))
732743

733744
if any(res[0] for res in results):
734745
changed = True

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ def config(self, spec: ServiceSpec) -> None:
359359
"""
360360
pass
361361

362+
def get_daemon_deployment_ordering(self, daemons: List[CephadmDaemonDeploySpec]) -> Dict[int, List[CephadmDaemonDeploySpec]]:
363+
# for services that need to deploy their daemons in a certain order
364+
# this will return a dict of ints (the integers are arbitrary and just count up)
365+
# to a list of daemons it is okay to deploy in parallel. The expectation being
366+
# we'll deploy all the daemons in the "0" entry, then all in "1" etc.
367+
# The default behavior will just be to put all daemons in the "0" entry
368+
return {0: daemons}
369+
362370
def daemon_check_post(self, daemon_descrs: List[DaemonDescription]) -> None:
363371
"""The post actions needed to be done after daemons are checked"""
364372
if self.mgr.config_dashboard:

0 commit comments

Comments
 (0)