Skip to content

Commit 683c69c

Browse files
committed
Allow same compute resource name in different queues
Signed-off-by: chenwany <[email protected]>
1 parent 9180618 commit 683c69c

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/slurm_plugin/instance_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _parse_requested_instances(self, node_list):
216216
for node in node_list:
217217
try:
218218
queue_name, node_type, instance_name = parse_nodename(node)
219-
instance_type = self._instance_name_type_mapping[instance_name]
219+
instance_type = self._instance_name_type_mapping[queue_name][instance_name]
220220
instances_to_launch[queue_name][instance_type].append(node)
221221
except (InvalidNodenameError, KeyError):
222222
logger.warning("Discarding NodeName with invalid format: %s", node)

tests/slurm_plugin/slurm_resources/test_instance_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,11 +1050,11 @@ def test_parse_requested_instances(
10501050
):
10511051
# Mock instance name/type mapping
10521052
instance_name_type_mapping = {
1053-
"c5xlarge": "c5.xlarge",
1054-
"g34xlarge": "g3.4xlarge",
1055-
"g38xlarge": "g3.8xlarge",
1056-
"u6tb1metal": "u-6tb1.metal",
1057-
"i3enmetal2tb": "i3en.metal-2tb",
1053+
"queue1": {"c5xlarge": "c5.xlarge"},
1054+
"queue2": {"g34xlarge": "g3.4xlarge", "g38xlarge": "g3.8xlarge", "u6tb1metal": "u-6tb1.metal"},
1055+
"queuename-with-dash-and_underscore": {
1056+
"i3enmetal2tb": "i3en.metal-2tb",
1057+
},
10581058
}
10591059
instance_manager._instance_name_type_mapping = instance_name_type_mapping
10601060

tests/slurm_plugin/test_clustermgtd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,9 @@ def test_manage_cluster_boto3(
15381538
# patch boto3 call
15391539
boto3_stubber("ec2", mocked_boto3_request)
15401540
mocker.patch("slurm_plugin.clustermgtd.datetime").now.return_value = datetime(2020, 1, 2, 0, 0, 0)
1541-
mocker.patch("slurm_plugin.clustermgtd.retrieve_instance_type_mapping", return_value={"c5xlarge": "c5.xlarge"})
1541+
mocker.patch(
1542+
"slurm_plugin.clustermgtd.retrieve_instance_type_mapping", return_value={"queue": {"c5xlarge": "c5.xlarge"}}
1543+
)
15421544
sync_config = ClustermgtdConfig(test_datadir / config_file)
15431545
cluster_manager = ClusterManager(sync_config)
15441546
dynamodb_table_mock = mocker.patch.object(cluster_manager._compute_fleet_status_manager, "_table")

tests/slurm_plugin/test_resume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_resume_launch(
256256
cluster_name="hit",
257257
head_node_private_ip="some_ip",
258258
head_node_hostname="some_hostname",
259-
instance_name_type_mapping={"c5xlarge": "c5.xlarge", "c52xlarge": "c5.2xlarge"},
259+
instance_name_type_mapping={"queue1": {"c5xlarge": "c5.xlarge"}, "queue2": {"c52xlarge": "c5.2xlarge"}},
260260
clustermgtd_heartbeat_file_path="some_path",
261261
clustermgtd_timeout=600,
262262
boto3_config=botocore.config.Config(),

0 commit comments

Comments
 (0)