[Autoscaler] Proper resource demand plumbing (#10329)

This commit is contained in:
Alex Wu
2020-08-26 23:36:01 -07:00
committed by GitHub
parent 9056854c06
commit 6d2af33a01
5 changed files with 115 additions and 18 deletions
+13 -9
View File
@@ -117,7 +117,7 @@ class StandardAutoscaler:
# Aggregate resources the user is requesting of the cluster.
self.resource_requests = defaultdict(int)
# List of resource bundles the user is requesting of the cluster.
self.resource_demand_vector = None
self.resource_demand_vector = []
logger.info("StandardAutoscaler: {}".format(self.config))
@@ -197,14 +197,18 @@ class StandardAutoscaler:
self.log_info_string(nodes, target_workers)
# First let the resource demand scheduler launch nodes, if enabled.
if self.resource_demand_scheduler and self.resource_demand_vector:
to_launch = (self.resource_demand_scheduler.get_nodes_to_launch(
self.provider.non_terminated_nodes(tag_filters={}),
self.pending_launches.breakdown(),
self.resource_demand_vector))
# TODO(ekl) also enforce max launch concurrency here?
for node_type, count in to_launch:
self.launch_new_node(count, node_type=node_type)
if self.resource_demand_scheduler:
resource_demand_vector = self.resource_demand_vector + \
self.load_metrics.get_resource_demand_vector()
if resource_demand_vector:
to_launch = (
self.resource_demand_scheduler.get_nodes_to_launch(
self.provider.non_terminated_nodes(tag_filters={}),
self.pending_launches.breakdown(),
resource_demand_vector))
# TODO(ekl) also enforce max launch concurrency here?
for node_type, count in to_launch:
self.launch_new_node(count, node_type=node_type)
# Launch additional nodes of the default type, if still needed.
num_workers = len(nodes) + num_pending
+14 -1
View File
@@ -23,8 +23,16 @@ class LoadMetrics:
self.dynamic_resources_by_ip = {}
self.resource_load_by_ip = {}
self.local_ip = services.get_node_ip_address()
self.waiting_bundles = []
self.infeasible_bundles = []
def update(self, ip, static_resources, dynamic_resources, resource_load):
def update(self,
ip,
static_resources,
dynamic_resources,
resource_load,
waiting_bundles=[],
infeasible_bundles=[]):
self.resource_load_by_ip[ip] = resource_load
self.static_resources_by_ip[ip] = static_resources
@@ -43,6 +51,8 @@ class LoadMetrics:
static_resources != dynamic_resources:
self.last_used_time_by_ip[ip] = now
self.last_heartbeat_time_by_ip[ip] = now
self.waiting_bundles = waiting_bundles
self.infeasible_bundles = infeasible_bundles
def mark_active(self, ip):
assert ip is not None, "IP should be known at this time"
@@ -127,6 +137,9 @@ class LoadMetrics:
return nodes_used, resources_used, resources_total
def get_resource_demand_vector(self):
return self.waiting_bundles + self.infeasible_bundles
def info_string(self):
return " - " + "\n - ".join(
["{}: {}".format(k, v) for k, v in sorted(self._info().items())])