# If no action is specified, check whether we need to start the daemon
if not action and dd.daemon_type in DISABLED_SERVICES:
if dd.status == 0 and not dd.user_stopped:
- self.log.debug(f'Starting daemon {dd.name()}')
- action = 'start'
+ should_start = False
+ if spec and service_registry.get_service(daemon_type_to_service(dd.daemon_type)).ranked(spec):
+ # For ranked services, check if we should start this daemon
+ same_rank_daemons = [
+ d for d in self.mgr.cache.get_daemons_by_service(dd.service_name())
+ if d.rank == dd.rank and d.daemon_type == dd.daemon_type
+ ]
+ self.log.debug(
+ f'Start hightest rank_gen daemon of same rank daemons {same_rank_daemons}'
+ )
+ if len(same_rank_daemons) == 1:
+ should_start = True
+ else:
+ # Multiple daemons exist for this rank, only start the highest generation
+ highest_gen_daemon = max(same_rank_daemons,
+ key=lambda d: d.rank_generation or 0)
+ should_start = (dd == highest_gen_daemon)
+ else:
+ should_start = True
+ if should_start:
+ self.log.debug(f'Starting daemon {dd.name()}')
+ action = 'start'
if action:
if scheduled_action == 'redeploy' and action == 'reconfig':