Skip to content

Commit 64aeb09

Browse files
committed
chore: Move container mounts to parameter (#1147)
1 parent b6221ac commit 64aeb09

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

internal/remote/firecrest/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ func addSessionMountsToScript(sessionScript string, fileSystems *[]FileSystem, s
648648
mounts = append(mounts, fmt.Sprintf("%s:/secrets:ro", secretsPath))
649649
}
650650

651-
// Format mount list for the environment.toml file
651+
// Format mount list
652652
for i := range mounts {
653-
mounts[i] = fmt.Sprintf(" \"%s\",", mounts[i])
653+
mounts[i] = fmt.Sprintf("\"%s\"", mounts[i])
654654
}
655-
mountsStr := fmt.Sprintf("mounts = [\n%s\n]", strings.Join(mounts, "\n"))
655+
mountsStr := fmt.Sprintf("--container-mounts=%s", strings.Join(mounts, ","))
656656
return strings.Replace(sessionScript, "#{{SESSION_MOUNTS_PLACEHOLDER}}", mountsStr, 1)
657657
}
658658

internal/remote/firecrest/controller_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ func TestRenderSessionScriptStatic(t *testing.T) {
7070
assert.Contains(t, sessionScriptFinal, "#SBATCH --partition=my-partition")
7171

7272
// Check the mounts
73-
mountsRegExp := regexp.MustCompile(`mounts(?:\s*)=(?:\s*)[[]([^]]*)]`)
73+
// From `srun --help`:
74+
// --container-mounts=SRC:DST[:FLAGS][,SRC:DST...]
75+
// [pyxis] bind mount[s] inside the container. Mount
76+
// flags are separated with "+", e.g. "ro+rprivate"
77+
flagsRegExp := `:(?:ro|rprivate)(?:[+](?:ro|rprivate))*`
78+
mountRegExp := `"[^:,"]+:[^:,"]+(?:` + flagsRegExp + `)?"`
79+
mountsRegExp := regexp.MustCompile(`--container-mounts=(` + mountRegExp + `(?:,` + mountRegExp + `)*)`)
7480
matches := mountsRegExp.FindStringSubmatch(sessionScriptFinal)
7581
assert.Len(t, matches, 2)
7682
foundMounts := matches[1]

internal/remote/firecrest/session_script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,13 @@ fi
143143
# Create the environment.toml file to run the session
144144
EDF_FILE="${SESSION_DIR}/environment.toml"
145145
cat <<EOF >"${EDF_FILE}"
146-
#{{SESSION_MOUNTS_PLACEHOLDER}}
147-
148146
[annotations]
149147
com.hooks.cxi.enabled = "false"
150148
EOF
151149

152150
srun_param_container_image="--container-image ${REMOTE_SESSION_IMAGE}"
153151
srun_param_workdir="--container-workdir ${SESSION_WORK_DIR}"
152+
srun_param_mounts=#{{SESSION_MOUNTS_PLACEHOLDER}}
154153

155154
export RENKU_MOUNT_DIR="${SESSION_WORK_DIR}"
156155
export RENKU_WORKING_DIR="${SESSION_WORK_DIR}"
@@ -252,6 +251,7 @@ srun \
252251
--environment "${EDF_FILE}" \
253252
${srun_param_container_image} \
254253
${srun_param_workdir} \
254+
${srun_param_mounts} \
255255
--no-container-entrypoint sh /etc/rc \
256256
& pid=$!
257257
wait

0 commit comments

Comments
 (0)