Randomze choice of zoned fingergw
If we're performing internal routing to a zoned fingergw, choose one at random if there's more than one in order to load balance. Change-Id: I46e32426d3a6dc2b2ebac7fdc54b5a61ad231d20
This commit is contained in:
parent
e047fc42c6
commit
b3435878c9
|
@ -16,6 +16,7 @@
|
|||
import json
|
||||
import logging
|
||||
import time
|
||||
import random
|
||||
from abc import ABCMeta
|
||||
from typing import List
|
||||
|
||||
|
@ -261,9 +262,11 @@ class RPCListener(RPCListenerBase):
|
|||
job.sendWorkComplete(json.dumps(running_items))
|
||||
|
||||
def _get_fingergw_in_zone(self, zone):
|
||||
for gw in self.sched.component_registry.all('fingergw'):
|
||||
if gw.zone == zone:
|
||||
return gw
|
||||
gws = [gw for gw in self.sched.component_registry.all('fingergw')
|
||||
if gw.zone == zone]
|
||||
if gws:
|
||||
return random.choice(gws)
|
||||
return None
|
||||
|
||||
def handle_get_job_log_stream_address(self, job):
|
||||
# TODO: map log files to ports. Currently there is only one
|
||||
|
|
Loading…
Reference in New Issue