From 0ac36b635c0be76682a43380f624c11e73524bbc Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Mon, 1 Jun 2026 16:00:13 +0200 Subject: [PATCH] chore: Move container mounts to parameter --- internal/remote/firecrest/controller.go | 6 +++--- internal/remote/firecrest/controller_test.go | 8 +++++++- internal/remote/firecrest/session_script.sh | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/remote/firecrest/controller.go b/internal/remote/firecrest/controller.go index e198856b..9cb029af 100644 --- a/internal/remote/firecrest/controller.go +++ b/internal/remote/firecrest/controller.go @@ -648,11 +648,11 @@ func addSessionMountsToScript(sessionScript string, fileSystems *[]FileSystem, s mounts = append(mounts, fmt.Sprintf("%s:/secrets:ro", secretsPath)) } - // Format mount list for the environment.toml file + // Format mount list for i := range mounts { - mounts[i] = fmt.Sprintf(" \"%s\",", mounts[i]) + mounts[i] = fmt.Sprintf("\"%s\"", mounts[i]) } - mountsStr := fmt.Sprintf("mounts = [\n%s\n]", strings.Join(mounts, "\n")) + mountsStr := fmt.Sprintf("--container-mounts=%s", strings.Join(mounts, ",")) return strings.Replace(sessionScript, "#{{SESSION_MOUNTS_PLACEHOLDER}}", mountsStr, 1) } diff --git a/internal/remote/firecrest/controller_test.go b/internal/remote/firecrest/controller_test.go index 7c5583eb..6b5e0106 100644 --- a/internal/remote/firecrest/controller_test.go +++ b/internal/remote/firecrest/controller_test.go @@ -70,7 +70,13 @@ func TestRenderSessionScriptStatic(t *testing.T) { assert.Contains(t, sessionScriptFinal, "#SBATCH --partition=my-partition") // Check the mounts - mountsRegExp := regexp.MustCompile(`mounts(?:\s*)=(?:\s*)[[]([^]]*)]`) + // From `srun --help`: + // --container-mounts=SRC:DST[:FLAGS][,SRC:DST...] + // [pyxis] bind mount[s] inside the container. Mount + // flags are separated with "+", e.g. "ro+rprivate" + flagsRegExp := `:(?:ro|rprivate)(?:[+](?:ro|rprivate))*` + mountRegExp := `"[^:,"]+:[^:,"]+(?:` + flagsRegExp + `)?"` + mountsRegExp := regexp.MustCompile(`--container-mounts=(` + mountRegExp + `(?:,` + mountRegExp + `)*)`) matches := mountsRegExp.FindStringSubmatch(sessionScriptFinal) assert.Len(t, matches, 2) foundMounts := matches[1] diff --git a/internal/remote/firecrest/session_script.sh b/internal/remote/firecrest/session_script.sh index 0784357e..63a17da6 100644 --- a/internal/remote/firecrest/session_script.sh +++ b/internal/remote/firecrest/session_script.sh @@ -143,14 +143,13 @@ fi # Create the environment.toml file to run the session EDF_FILE="${SESSION_DIR}/environment.toml" cat <"${EDF_FILE}" -#{{SESSION_MOUNTS_PLACEHOLDER}} - [annotations] com.hooks.cxi.enabled = "false" EOF srun_param_container_image="--container-image ${REMOTE_SESSION_IMAGE}" srun_param_workdir="--container-workdir ${SESSION_WORK_DIR}" +srun_param_mounts=#{{SESSION_MOUNTS_PLACEHOLDER}} export RENKU_MOUNT_DIR="${SESSION_WORK_DIR}" export RENKU_WORKING_DIR="${SESSION_WORK_DIR}" @@ -252,6 +251,7 @@ srun \ --environment "${EDF_FILE}" \ ${srun_param_container_image} \ ${srun_param_workdir} \ + ${srun_param_mounts} \ --no-container-entrypoint sh /etc/rc \ & pid=$! wait