Skip to content

Commit f57b161

Browse files
committed
fix(slurmCI): make archiveImage jobIdFile read non-fatal
If cat fails (file missing, allocation never wrote it), the export should be best-effort — not hard-fail the pipeline step. Move the jobId read inside the existing try/catch along with the export sh(). Also promote the unresolved-path check to an else-if before the try, avoiding an unnecessary sh invocation when the path is known bad. Signed-off-by: NirWolfer <nwolfer@nvidia.com>
1 parent 6cc6f40 commit f57b161

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

vars/slurmCI.groovy

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,32 @@ int call(ctx, oneStep, config) {
9494
def containerName = args.containerName
9595
if (!jobIdFile || !containerName) {
9696
echo "archiveImage: skipping export — jobIdFile or containerName is null (step '${oneStep.name}')"
97+
} else if (resolvedOutputPath.contains('${')) {
98+
echo "archiveImage: skipping export — outputPath contains unresolved variables: ${resolvedOutputPath}"
9799
} else {
98-
def jobId = ''
99-
withEnv(["ARCHIVE_JOB_ID_FILE=${jobIdFile}"]) {
100-
jobId = sh(script: 'cat "$ARCHIVE_JOB_ID_FILE"', returnStdout: true).trim()
101-
}
102-
jobId = jobId.replaceAll(/[^0-9]/, '')
103-
if (resolvedOutputPath.contains('${')) {
104-
echo "archiveImage: skipping export — outputPath contains unresolved variables: ${resolvedOutputPath}"
105-
} else {
106-
try {
107-
withEnv([
108-
"ARCHIVE_CONTAINER=${containerName}",
109-
"ARCHIVE_OUTPUT=${resolvedOutputPath}",
110-
"ARCHIVE_JOB_ID=${jobId}",
111-
"ARCHIVE_ENROOT_DATA_PATH=${env.ENROOT_DATA_PATH ?: ''}",
112-
]) {
113-
sh(label: "archiveImage: export '${containerName}' -> ${resolvedOutputPath}", script: '''
100+
try {
101+
def jobId = ''
102+
withEnv(["ARCHIVE_JOB_ID_FILE=${jobIdFile}"]) {
103+
jobId = sh(script: 'cat "$ARCHIVE_JOB_ID_FILE"', returnStdout: true).trim()
104+
}
105+
jobId = jobId.replaceAll(/[^0-9]/, '')
106+
withEnv([
107+
"ARCHIVE_CONTAINER=${containerName}",
108+
"ARCHIVE_OUTPUT=${resolvedOutputPath}",
109+
"ARCHIVE_JOB_ID=${jobId}",
110+
"ARCHIVE_ENROOT_DATA_PATH=${env.ENROOT_DATA_PATH ?: ''}",
111+
]) {
112+
sh(label: "archiveImage: export '${containerName}' -> ${resolvedOutputPath}", script: '''
114113
#!/bin/bash
115114
set -euo pipefail
116115
mkdir -p "$(dirname "$ARCHIVE_OUTPUT")"
117116
scctl --raw-errors client connect -- srun --jobid="$ARCHIVE_JOB_ID" --ntasks=1 --oversubscribe env ENROOT_DATA_PATH="$ARCHIVE_ENROOT_DATA_PATH" enroot export --output "$ARCHIVE_OUTPUT" "pyxis_$ARCHIVE_CONTAINER"
118117
echo "Export complete: $ARCHIVE_OUTPUT"
119118
echo "To debug: see docs/ci/crash-debug.md"
120119
''')
121-
}
122-
} catch (e) {
123-
echo "archiveImage: export failed (non-fatal): ${e.message}"
124120
}
121+
} catch (e) {
122+
echo "archiveImage: export failed (non-fatal): ${e.message}"
125123
}
126124
}
127125
}

0 commit comments

Comments
 (0)