Skip to content

Commit f728ef1

Browse files
authored
Merge pull request GoogleCloudPlatform#4276 from alyssa-sm/large-scale-testing
SlurmGCP Resume Improvements
2 parents 5dd58fd + 4698cc8 commit f728ef1

5 files changed

Lines changed: 50 additions & 10 deletions

File tree

community/modules/scheduler/schedmd-slurm-gcp-v6-controller/modules/slurm_files/etc/slurm.conf.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DebugFlags=Power
2828
#
2929
#
3030
# TIMERS
31-
MessageTimeout=60
31+
MessageTimeout=120
3232

3333
################################################################################
3434
# vvvvv WARNING: DO NOT MODIFY SECTION BELOW vvvvv #

community/modules/scheduler/schedmd-slurm-gcp-v6-controller/modules/slurm_files/scripts/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get(key, default):
118118
"salloc_wait_nodes",
119119
"ignore_prefer_validation",
120120
]),
121-
"ResumeProgram": f"{scripts_dir}/resume.py",
121+
"ResumeProgram": f"{scripts_dir}/resume_wrapper.sh",
122122
"ResumeFailProgram": f"{scripts_dir}/suspend.py",
123123
"ResumeRate": get("resume_rate", 0),
124124
"ResumeTimeout": get("resume_timeout", 300),

community/modules/scheduler/schedmd-slurm-gcp-v6-controller/modules/slurm_files/scripts/resume.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ResumeJobData:
6767
class ResumeData:
6868
jobs: List[ResumeJobData]
6969

70+
7071
def get_resume_file_data() -> Optional[ResumeData]:
7172
if not (path := os.getenv("SLURM_RESUME_FILE")):
7273
log.error("SLURM_RESUME_FILE was not in environment. Cannot get detailed job, node, partition allocation data.")
@@ -77,7 +78,6 @@ def get_resume_file_data() -> Optional[ResumeData]:
7778

7879
jobs = []
7980
for jo in data.get("jobs", []):
80-
8181
job = ResumeJobData(
8282
job_id = jo.get("job_id"),
8383
partition = jo.get("partition"),
@@ -181,7 +181,7 @@ def create_instances_request(nodes: List[str], placement_group: Optional[str], e
181181
),
182182
)
183183

184-
if placement_group:
184+
if placement_group and excl_job_id is not None:
185185
pass # do not set minCount to force "all or nothing" behavior
186186
else:
187187
body["minCount"] = 1
@@ -653,11 +653,10 @@ def main(nodelist: str) -> None:
653653
if not nodes:
654654
log.info("No nodes to resume")
655655
return
656-
657656
resume_data = get_resume_file_data()
658657
log.info(f"resume {util.to_hostlist(nodes)}")
659658
resume_nodes(nodes, resume_data)
660-
659+
661660
if __name__ == "__main__":
662661
parser = argparse.ArgumentParser()
663662
parser.add_argument("nodelist", help="list of nodes to resume")
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2024 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e -o pipefail
18+
19+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
20+
PYTHON_SCRIPT="${SCRIPT_DIR}/resume.py"
21+
22+
# Capture all arguments passed by Slurm (the nodelist).
23+
ALL_ARGS=("$@")
24+
25+
# This array will hold extra argument for resume.py, like the resume data file.
26+
UNIQUE_RESUME_FILE=""
27+
28+
# Handle SLURM_RESUME_FILE if provided
29+
if [ -n "${SLURM_RESUME_FILE-}" ] && [ -f "$SLURM_RESUME_FILE" ]; then
30+
SAFE_DIR="/tmp/slurm_resume_data"
31+
mkdir -p "$SAFE_DIR"
32+
33+
UNIQUE_RESUME_FILE="${SAFE_DIR}/resumedata.$$.json"
34+
cp "$SLURM_RESUME_FILE" "$UNIQUE_RESUME_FILE"
35+
fi
36+
37+
SLURM_RESUME_FILE="${UNIQUE_RESUME_FILE}"
38+
"${PYTHON_SCRIPT}" "${ALL_ARGS[@]}" &
39+
disown
40+
41+
exit 0

community/modules/scheduler/schedmd-slurm-gcp-v6-controller/modules/slurm_files/scripts/tests/test_conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_dict_to_conf(value: dict, want: str):
9393
"""LaunchParameters=enable_nss_slurm,use_interactive_step
9494
SlurmctldParameters=cloud_dns,enable_configless,idle_on_node_suspend
9595
SchedulerParameters=bf_continue,salloc_wait_nodes,ignore_prefer_validation
96-
ResumeProgram=ukulele/resume.py
96+
ResumeProgram=ukulele/resume_wrapper.sh
9797
ResumeFailProgram=ukulele/suspend.py
9898
ResumeRate=0
9999
ResumeTimeout=300
@@ -119,7 +119,7 @@ def test_dict_to_conf(value: dict, want: str):
119119
},
120120
),
121121
"""SchedulerParameters=bf_continue,salloc_wait_nodes,ignore_prefer_validation
122-
ResumeProgram=ukulele/resume.py
122+
ResumeProgram=ukulele/resume_wrapper.sh
123123
ResumeFailProgram=ukulele/suspend.py
124124
ResumeRate=0
125125
ResumeTimeout=300
@@ -154,7 +154,7 @@ def test_dict_to_conf(value: dict, want: str):
154154
),
155155
"""PrivateData=events,jobs
156156
SchedulerParameters=bf_busy_nodes,bf_continue,ignore_prefer_validation,nohold_on_prolog_fail
157-
ResumeProgram=ukulele/resume.py
157+
ResumeProgram=ukulele/resume_wrapper.sh
158158
ResumeFailProgram=ukulele/suspend.py
159159
ResumeRate=1
160160
ResumeTimeout=2
@@ -174,7 +174,7 @@ def test_dict_to_conf(value: dict, want: str):
174174
TaskProlog=/slurm/custom_scripts/task_prolog.d/task-prolog
175175
TaskEpilog=/slurm/custom_scripts/task_epilog.d/task-epilog
176176
SchedulerParameters=bf_continue,salloc_wait_nodes,ignore_prefer_validation
177-
ResumeProgram=ukulele/resume.py
177+
ResumeProgram=ukulele/resume_wrapper.sh
178178
ResumeFailProgram=ukulele/suspend.py
179179
ResumeRate=0
180180
ResumeTimeout=300

0 commit comments

Comments
 (0)