Autoscaler hotfix for #4555. (#4653)

This commit is contained in:
Romil Bhardwaj 2019-05-08 14:50:52 -07:00 committed by Robert Nishihara
parent 28496c8b50
commit 0421cba4e8
2 changed files with 11 additions and 2 deletions

View file

@ -158,7 +158,16 @@ class LoadMetrics(object):
def update(self, ip, static_resources, dynamic_resources):
self.static_resources_by_ip[ip] = static_resources
self.dynamic_resources_by_ip[ip] = dynamic_resources
# We are not guaranteed to have a corresponding dynamic resource for
# every static resource because dynamic resources are based on the
# available resources in the heartbeat, which does not exist if it is
# zero. Thus, we have to update dynamic resources here.
dynamic_resources_update = dynamic_resources.copy()
for resource_name, capacity in static_resources.items():
if resource_name not in dynamic_resources_update:
dynamic_resources_update[resource_name] = 0.0
self.dynamic_resources_by_ip[ip] = dynamic_resources_update
now = time.time()
if ip not in self.last_used_time_by_ip or \
static_resources != dynamic_resources:

View file

@ -112,7 +112,7 @@ class Monitor(object):
for j in range(message.BatchLength()):
heartbeat_message = message.Batch(j)
num_resources = heartbeat_message.ResourcesAvailableLabelLength()
num_resources = heartbeat_message.ResourcesTotalLabelLength()
static_resources = {}
dynamic_resources = {}
for i in range(num_resources):