Filter controller_node selection to online nodes (#11120)

This commit is contained in:
Alan Rominger 2021-09-24 23:01:32 -04:00 committed by GitHub
parent 471f47cd9e
commit 3fc63489f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,7 +151,9 @@ class Instance(HasPolicyEditsMixin, BaseModel):
@staticmethod
def choose_online_control_plane_node():
return random.choice(Instance.objects.filter(enabled=True).filter(node_type__in=['control', 'hybrid']).values_list('hostname', flat=True))
return random.choice(
Instance.objects.filter(enabled=True, capacity__gt=0).filter(node_type__in=['control', 'hybrid']).values_list('hostname', flat=True)
)
def is_lost(self, ref_time=None):
if self.last_seen is None: