[autoscaler] give max_workers precedence over min_workers in resource demand scheduler (#12106)

This commit is contained in:
Ameer Haj Ali
2020-11-19 02:24:48 +02:00
committed by GitHub
parent d826452e0b
commit 4717fcd9c0
2 changed files with 21 additions and 1 deletions
@@ -523,7 +523,8 @@ def _add_min_workers_nodes(
total_nodes_to_add_dict = {}
for node_type, config in node_types.items():
existing = node_type_counts.get(node_type, 0)
target = config.get("min_workers", 0)
target = min(
config.get("min_workers", 0), config.get("max_workers", 0))
if existing < target:
total_nodes_to_add_dict[node_type] = target - existing
node_type_counts[node_type] = target
@@ -246,6 +246,13 @@ def test_add_min_workers_nodes():
"min_workers": 99999,
"max_workers": 99999,
},
"gpubla": {
"resources": {
"GPU": 1
},
"min_workers": 10,
"max_workers": 0,
},
}
assert _add_min_workers_nodes([],
{},
@@ -281,6 +288,18 @@ def test_add_min_workers_nodes():
"gpu": 99999
}, {})
assert _add_min_workers_nodes([], {},
{"gpubla": types["gpubla"]}) == ([], {}, {})
types["gpubla"]["max_workers"] = 10
assert _add_min_workers_nodes([], {}, {"gpubla": types["gpubla"]}) == ([{
"GPU": 1
}] * 10, {
"gpubla": 10
}, {
"gpubla": 10
})
def test_get_nodes_to_launch_with_min_workers():
provider = MockProvider()