@@ -27,7 +27,6 @@ def _build_slurm_script(
2727 image_name : str ,
2828 account : str ,
2929 partition : str ,
30- remote_build_dir : str ,
3130 remote_logs_dir : str ,
3231 output_sqsh : str ,
3332) -> str :
@@ -44,45 +43,26 @@ def _build_slurm_script(
4443
4544set -euo pipefail
4645
47- # Prevent podman from connecting to a stale or inaccessible D-Bus socket.
48- # Some compute nodes have /run/user/<uid>/bus created by PAM but with no
49- # daemon listening, causing podman to fail with "connection refused".
50- export DBUS_SESSION_BUS_ADDRESS=unix:path=/dev/null
51- export XDG_RUNTIME_DIR="${{TMPDIR:-/tmp}}/runtime-$$"
52- mkdir -p "${{XDG_RUNTIME_DIR}}"
53-
5446IMAGE_TAG="{ image_name } :${{SLURM_JOB_ID}}"
55- FINAL_SQSH="{ output_sqsh } "
56- TEMP_SQSH="${{FINAL_SQSH}}.tmp.${{SLURM_JOB_ID}}"
47+ SCRATCH_SQSH="${{SCRATCH}}/{ image_name } .sqsh"
5748
5849cleanup() {{
5950 podman rmi "${{IMAGE_TAG}}" 2>/dev/null || true
60- rm -f "${{TEMP_SQSH}}" 2>/dev/null || true
61- rm -rf "${{XDG_RUNTIME_DIR}}" 2>/dev/null || true
51+ rm -f "${{SCRATCH_SQSH}}" 2>/dev/null || true
6252}}
6353trap cleanup EXIT
6454
6555echo "=== Building { image_name } on $(hostname) at $(date) ==="
66- echo "CPUs available: $(nproc)"
67-
68- podman build \\
69- -t "${{IMAGE_TAG}}" \\
70- "{ remote_build_dir } "
56+ podman build -t "${{IMAGE_TAG}}" .
7157
7258echo "=== Converting to sqsh ==="
73- # Run enroot from the output directory so its internal temp file is on the
74- # same filesystem as the output, avoiding a cross-filesystem rename (EXDEV).
75- mkdir -p "$(dirname "${{TEMP_SQSH}}")"
76- (cd "$(dirname "${{TEMP_SQSH}}")" && enroot import -o "${{TEMP_SQSH}}" "podman://${{IMAGE_TAG}}")
77- if [ ! -s "${{TEMP_SQSH}}" ]; then
78- echo "ERROR: enroot import failed — sqsh not created"
79- exit 1
80- fi
59+ enroot import -o "${{SCRATCH_SQSH}}" "podman://${{IMAGE_TAG}}"
8160
8261echo "=== Saving to capstor ==="
83- mv "${{TEMP_SQSH}}" "${{FINAL_SQSH}}"
62+ mkdir -p "$(dirname "{ output_sqsh } ")"
63+ cp "${{SCRATCH_SQSH}}" "{ output_sqsh } "
8464
85- echo "=== Done: { image_name } -> ${{FINAL_SQSH} } at $(date) ==="
65+ echo "=== Done: { image_name } -> { output_sqsh } at $(date) ==="
8666"""
8767
8868
@@ -164,7 +144,6 @@ async def main(image_name: str) -> int:
164144 image_name = image_name ,
165145 account = account ,
166146 partition = partition ,
167- remote_build_dir = remote_build_dir ,
168147 remote_logs_dir = remote_logs_dir ,
169148 output_sqsh = output_sqsh ,
170149 )
0 commit comments