@@ -97,19 +97,24 @@ def assign_rank_generation(
9797 gen ,
9898 )
9999
100- def matches_daemon (self , dd : DaemonDescription ) -> bool :
100+ def matches_daemon (self , dd : DaemonDescription , upgrade_in_progress : bool = False ) -> bool :
101101 if self .daemon_type != dd .daemon_type :
102102 return False
103103 if self .hostname != dd .hostname :
104104 return False
105105 # fixme: how to match against network?
106106 if self .name and self .name != dd .daemon_id :
107107 return False
108- if self .ports :
109- if self .ports != dd .ports and dd .ports :
110- return False
111- if self .ip != dd .ip and dd .ip :
112- return False
108+ # only consider daemon "not matching" on port/ip
109+ # differences if we're not mid upgrade. During upgrade
110+ # it's very likely we'll deploy the daemon with the
111+ # new port/ips as part of the upgrade process
112+ if not upgrade_in_progress :
113+ if self .ports :
114+ if self .ports != dd .ports and dd .ports :
115+ return False
116+ if self .ip != dd .ip and dd .ip :
117+ return False
113118 return True
114119
115120 def matches_rank_map (
@@ -154,6 +159,7 @@ def __init__(self,
154159 per_host_daemon_type : Optional [str ] = None ,
155160 rank_map : Optional [Dict [int , Dict [int , Optional [str ]]]] = None ,
156161 blocking_daemon_hosts : Optional [List [orchestrator .HostSpec ]] = None ,
162+ upgrade_in_progress : bool = False
157163 ):
158164 assert spec
159165 self .spec = spec # type: ServiceSpec
@@ -171,6 +177,7 @@ def __init__(self,
171177 self .per_host_daemon_type = per_host_daemon_type
172178 self .ports_start = spec .get_port_start ()
173179 self .rank_map = rank_map
180+ self .upgrade_in_progress = upgrade_in_progress
174181
175182 def hosts_by_label (self , label : str ) -> List [orchestrator .HostSpec ]:
176183 return [h for h in self .hosts if label in h .labels ]
@@ -234,7 +241,7 @@ def place_per_host_daemons(
234241 for dd in existing :
235242 found = False
236243 for p in host_slots :
237- if p .matches_daemon (dd ):
244+ if p .matches_daemon (dd , self . upgrade_in_progress ):
238245 host_slots .remove (p )
239246 found = True
240247 break
@@ -311,7 +318,7 @@ def expand_candidates(ls: List[DaemonPlacement], num: int) -> List[DaemonPlaceme
311318 for dd in daemons :
312319 found = False
313320 for p in others :
314- if p .matches_daemon (dd ) and p .matches_rank_map (dd , self .rank_map , ranks ):
321+ if p .matches_daemon (dd , self . upgrade_in_progress ) and p .matches_rank_map (dd , self .rank_map , ranks ):
315322 others .remove (p )
316323 if dd .is_active :
317324 existing_active .append (dd )
0 commit comments