From 65c7148ea23fd5cc0906881ee0683f0bccbcbd46 Mon Sep 17 00:00:00 2001 From: Andrii Shestakov Date: Wed, 8 Jul 2026 13:05:25 +0200 Subject: [PATCH 1/2] Mount slurm-scripts to nodesets worker --- helm/nodesets/templates/_helpers.tpl | 16 ++++++++++ helm/nodesets/templates/nodeset.yaml | 30 +++++++++++++++++-- helm/nodesets/values.yaml | 2 ++ helm/slurm-cluster/templates/_helpers.tpl | 11 +++++++ .../templates/slurm-cluster-cr.yaml | 6 ++++ helm/slurm-cluster/values.yaml | 2 ++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/helm/nodesets/templates/_helpers.tpl b/helm/nodesets/templates/_helpers.tpl index e4cd88250..722610d2f 100644 --- a/helm/nodesets/templates/_helpers.tpl +++ b/helm/nodesets/templates/_helpers.tpl @@ -114,6 +114,22 @@ customInitContainers: {{- end }} {{- end -}} +{{/* Name of the slurm-scripts ConfigMap. Matches slurm-cluster chart's naming convention. */}} +{{- define "nodesets.slurmScriptsCMName" -}} +{{- if $.Values.slurmScriptsConfigMapName -}} +{{- $.Values.slurmScriptsConfigMapName -}} +{{- else if $.Values.clusterName -}} +{{- printf "%s-slurm-scripts" (default $.Chart.Name $.Values.clusterName | trunc 63 | trimSuffix "-") -}} +{{- end -}} +{{- end -}} + +{{/* True if list has an entry with the given name. Usage: include "nodesets.hasMountName" (dict "list" .jailSubMounts "name" "x") */}} +{{- define "nodesets.hasMountName" -}} +{{- $found := false -}} +{{- range .list }}{{- if eq .name $.name }}{{ $found = true }}{{- end }}{{- end -}} +{{- $found -}} +{{- end -}} + {{/* Construct container gpu resource from GPU spec ([0]) and GPU resource spec ([1]) */}} {{- define "nodesets.resource.gpuFrom" -}} {{- $gpuSpec := (index . 0) | default dict -}} diff --git a/helm/nodesets/templates/nodeset.yaml b/helm/nodesets/templates/nodeset.yaml index 4087a1ec6..0e92d8563 100644 --- a/helm/nodesets/templates/nodeset.yaml +++ b/helm/nodesets/templates/nodeset.yaml @@ -175,14 +175,40 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} - {{- with (.jailSubMounts | default list) }} + {{- $slurmScriptsCMName := include "nodesets.slurmScriptsCMName" $ }} + {{- $jailSubMounts := .jailSubMounts | default list }} + {{- $customVolumeMounts := .customVolumeMounts | default list }} + {{- $injectJailSlurmScripts := and $slurmScriptsCMName (not (eq "true" (include "nodesets.hasMountName" (dict "list" $jailSubMounts "name" "slurm-scripts-jail")))) }} + {{- $injectCustomSlurmScripts := and $slurmScriptsCMName (not (eq "true" (include "nodesets.hasMountName" (dict "list" $customVolumeMounts "name" "slurm-scripts")))) }} + + {{- if or $injectJailSlurmScripts $jailSubMounts }} jailSubMounts: + {{- if $injectJailSlurmScripts }} + - name: slurm-scripts-jail + mountPath: /opt/slurm_scripts + volumeSource: + configMap: + name: {{ $slurmScriptsCMName | quote }} + defaultMode: 0755 + {{- end }} + {{- with $jailSubMounts }} {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} - {{- with (.customVolumeMounts | default list) }} + {{- if or $injectCustomSlurmScripts $customVolumeMounts }} customVolumeMounts: + {{- if $injectCustomSlurmScripts }} + - name: slurm-scripts + mountPath: /opt/slurm_scripts + volumeSource: + configMap: + name: {{ $slurmScriptsCMName | quote }} + defaultMode: 0755 + {{- end }} + {{- with $customVolumeMounts }} {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- with (.persistentVolumeClaimRetentionPolicy | default dict) }} diff --git a/helm/nodesets/values.yaml b/helm/nodesets/values.yaml index 2885f8ced..42c3356f6 100644 --- a/helm/nodesets/values.yaml +++ b/helm/nodesets/values.yaml @@ -6,6 +6,8 @@ nameOverride: "" fullnameOverride: "" clusterName: "" +# Name of the slurm-scripts ConfigMap. Defaults to "-slurm-scripts". +slurmScriptsConfigMapName: "" # Priority Classes configuration # Define priority classes that can be used by NodeSets priorityClasses: diff --git a/helm/slurm-cluster/templates/_helpers.tpl b/helm/slurm-cluster/templates/_helpers.tpl index 43338b445..5513a78d3 100644 --- a/helm/slurm-cluster/templates/_helpers.tpl +++ b/helm/slurm-cluster/templates/_helpers.tpl @@ -26,8 +26,19 @@ {{/* Name of the slurm-scripts ConfigMap */}} {{- define "slurm-cluster.slurmScriptsCMName" -}} +{{- if .Values.slurmScriptsConfigMapName -}} +{{- .Values.slurmScriptsConfigMapName -}} +{{- else -}} {{- printf "%s-slurm-scripts" (include "slurm-cluster.name" .) -}} {{- end -}} +{{- end -}} + +{{/* True if list has an entry with the given name. Usage: include "slurm-cluster.hasMountName" (dict "list" .volumeSources "name" "x") */}} +{{- define "slurm-cluster.hasMountName" -}} +{{- $found := false -}} +{{- range .list }}{{- if eq .name $.name }}{{ $found = true }}{{- end }}{{- end -}} +{{- $found -}} +{{- end -}} {{- define "validateAccountingConfig" -}} {{- if .Values.slurmNodes.accounting.enabled -}} diff --git a/helm/slurm-cluster/templates/slurm-cluster-cr.yaml b/helm/slurm-cluster/templates/slurm-cluster-cr.yaml index 2ca0f46a2..8a88386cd 100644 --- a/helm/slurm-cluster/templates/slurm-cluster-cr.yaml +++ b/helm/slurm-cluster/templates/slurm-cluster-cr.yaml @@ -103,10 +103,12 @@ spec: {{- end }} {{- end }} volumeSources: + {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.volumeSources "name" "slurm-scripts"))) }} - name: slurm-scripts configMap: name: {{ include "slurm-cluster.slurmScriptsCMName" . }} defaultMode: 0755 + {{- end }} {{- range .Values.volumeSources }} - name: {{ .name | quote }} {{- omit . "name" "createPVC" "storageClassName" "size" | toYaml | nindent 6 }} @@ -480,12 +482,16 @@ spec: jailSubMounts: {{- default list .Values.slurmNodes.login.volumes.jailSubMounts | toYaml | nindent 10 }} customMounts: + {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts"))) }} - name: slurm-scripts mountPath: /opt/slurm_scripts/ volumeSourceName: slurm-scripts + {{- end }} + {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts-jail"))) }} - name: slurm-scripts-jail mountPath: /mnt/jail.upper/opt/slurm_scripts/ volumeSourceName: slurm-scripts + {{- end }} {{- if .Values.slurmNodes.login.volumes.customMounts }} {{- .Values.slurmNodes.login.volumes.customMounts | toYaml | nindent 10 }} {{- end }} diff --git a/helm/slurm-cluster/values.yaml b/helm/slurm-cluster/values.yaml index 63b338a72..ed902f8d1 100644 --- a/helm/slurm-cluster/values.yaml +++ b/helm/slurm-cluster/values.yaml @@ -3,6 +3,8 @@ clusterName: "slurm1" # Supported values: enabled, disabled. # Use disabled only when the namespace contains a single SlurmCluster. podNamePrefix: "disabled" +# Name of the slurm-scripts ConfigMap. Defaults to "-slurm-scripts". +slurmScriptsConfigMapName: "" # Additional annotations for the cluster annotations: {} # Maintenance defines the maintenance window for the cluster. From 9a4cac0f09653ae62dd368c4fa0f0018d4d4156f Mon Sep 17 00:00:00 2001 From: Andrii Shestakov Date: Mon, 19 Oct 2026 18:01:18 +0400 Subject: [PATCH 2/2] fixes --- helm/nodesets/templates/_helpers.tpl | 15 +- helm/nodesets/templates/nodeset.yaml | 4 +- .../tests/slurm_scripts_mount_test.yaml | 160 ++++++++++++++++++ helm/nodesets/tests/volumes_test.yaml | 20 +-- helm/nodesets/values.yaml | 2 +- helm/slurm-cluster/templates/_helpers.tpl | 9 +- .../templates/slurm-cluster-cr.yaml | 6 +- .../tests/slurm_scripts_mount_test.yaml | 107 ++++++++++++ 8 files changed, 298 insertions(+), 25 deletions(-) create mode 100644 helm/nodesets/tests/slurm_scripts_mount_test.yaml create mode 100644 helm/slurm-cluster/tests/slurm_scripts_mount_test.yaml diff --git a/helm/nodesets/templates/_helpers.tpl b/helm/nodesets/templates/_helpers.tpl index 722610d2f..ac6a2df56 100644 --- a/helm/nodesets/templates/_helpers.tpl +++ b/helm/nodesets/templates/_helpers.tpl @@ -114,19 +114,22 @@ customInitContainers: {{- end }} {{- end -}} -{{/* Name of the slurm-scripts ConfigMap. Matches slurm-cluster chart's naming convention. */}} +{{/* Name of the slurm-scripts ConfigMap. Matches slurm-cluster chart, including its default cluster name. */}} {{- define "nodesets.slurmScriptsCMName" -}} {{- if $.Values.slurmScriptsConfigMapName -}} {{- $.Values.slurmScriptsConfigMapName -}} -{{- else if $.Values.clusterName -}} -{{- printf "%s-slurm-scripts" (default $.Chart.Name $.Values.clusterName | trunc 63 | trimSuffix "-") -}} +{{- else -}} +{{- printf "%s-slurm-scripts" (default "helm-slurm-cluster" $.Values.clusterName | trunc 63 | trimSuffix "-") -}} {{- end -}} {{- end -}} -{{/* True if list has an entry with the given name. Usage: include "nodesets.hasMountName" (dict "list" .jailSubMounts "name" "x") */}} -{{- define "nodesets.hasMountName" -}} +{{/* True if list has an entry with the given name or mountPath. */}} +{{- define "nodesets.hasMount" -}} {{- $found := false -}} -{{- range .list }}{{- if eq .name $.name }}{{ $found = true }}{{- end }}{{- end -}} +{{- $path := .path | default "" -}} +{{- range .list }} +{{- if or (eq .name $.name) (and $path .mountPath (eq (clean .mountPath) (clean $path))) }}{{ $found = true }}{{- end }} +{{- end -}} {{- $found -}} {{- end -}} diff --git a/helm/nodesets/templates/nodeset.yaml b/helm/nodesets/templates/nodeset.yaml index 0e92d8563..a701e9da7 100644 --- a/helm/nodesets/templates/nodeset.yaml +++ b/helm/nodesets/templates/nodeset.yaml @@ -178,8 +178,8 @@ spec: {{- $slurmScriptsCMName := include "nodesets.slurmScriptsCMName" $ }} {{- $jailSubMounts := .jailSubMounts | default list }} {{- $customVolumeMounts := .customVolumeMounts | default list }} - {{- $injectJailSlurmScripts := and $slurmScriptsCMName (not (eq "true" (include "nodesets.hasMountName" (dict "list" $jailSubMounts "name" "slurm-scripts-jail")))) }} - {{- $injectCustomSlurmScripts := and $slurmScriptsCMName (not (eq "true" (include "nodesets.hasMountName" (dict "list" $customVolumeMounts "name" "slurm-scripts")))) }} + {{- $injectJailSlurmScripts := not (eq "true" (include "nodesets.hasMount" (dict "list" $jailSubMounts "name" "slurm-scripts-jail" "path" "/opt/slurm_scripts"))) }} + {{- $injectCustomSlurmScripts := not (eq "true" (include "nodesets.hasMount" (dict "list" $customVolumeMounts "name" "slurm-scripts" "path" "/opt/slurm_scripts"))) }} {{- if or $injectJailSlurmScripts $jailSubMounts }} jailSubMounts: diff --git a/helm/nodesets/tests/slurm_scripts_mount_test.yaml b/helm/nodesets/tests/slurm_scripts_mount_test.yaml new file mode 100644 index 000000000..752c516fb --- /dev/null +++ b/helm/nodesets/tests/slurm_scripts_mount_test.yaml @@ -0,0 +1,160 @@ +suite: test slurm-scripts mount injection +templates: + - templates/nodeset.yaml +set: + nodesets: + - &worker + name: worker + slurmd: &slurmd + resources: {cpu: "1", memory: 1Gi} + volumes: + spool: {emptyDir: {}} + jail: {emptyDir: {}} + munge: + resources: {cpu: 100m, memory: 128Mi} +tests: + - it: should inject both mounts with the cluster-derived ConfigMap name + set: + clusterName: my-cluster + asserts: + - equal: + path: spec.slurmd.volumes.jailSubMounts[0] + value: + name: slurm-scripts-jail + mountPath: /opt/slurm_scripts + volumeSource: + configMap: {name: my-cluster-slurm-scripts, defaultMode: 493} + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0] + value: + name: slurm-scripts + mountPath: /opt/slurm_scripts + volumeSource: + configMap: {name: my-cluster-slurm-scripts, defaultMode: 493} + + - it: should not inject mounts that already exist with the same name + set: + clusterName: my-cluster + nodesets: + - <<: *worker + slurmd: + <<: *slurmd + volumes: + spool: {emptyDir: {}} + jail: {emptyDir: {}} + jailSubMounts: + - {name: slurm-scripts-jail, mountPath: /somewhere/else, volumeSource: {emptyDir: {}}} + customVolumeMounts: + - {name: slurm-scripts, mountPath: /elsewhere, volumeSource: {emptyDir: {}}} + asserts: + - lengthEqual: + path: spec.slurmd.volumes.jailSubMounts + count: 1 + - equal: + path: spec.slurmd.volumes.jailSubMounts[0].mountPath + value: /somewhere/else + - lengthEqual: + path: spec.slurmd.volumes.customVolumeMounts + count: 1 + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].mountPath + value: /elsewhere + + - it: should not inject mounts that use another name but the same mountPath + set: + clusterName: my-cluster + nodesets: + - <<: *worker + slurmd: + <<: *slurmd + volumes: + spool: {emptyDir: {}} + jail: {emptyDir: {}} + jailSubMounts: + - {name: my-jail-scripts, mountPath: /opt/slurm_scripts/, volumeSource: {emptyDir: {}}} + customVolumeMounts: + - {name: my-scripts, mountPath: /opt/./slurm_scripts//, volumeSource: {emptyDir: {}}} + asserts: + - lengthEqual: + path: spec.slurmd.volumes.jailSubMounts + count: 1 + - equal: + path: spec.slurmd.volumes.jailSubMounts[0].name + value: my-jail-scripts + - lengthEqual: + path: spec.slurmd.volumes.customVolumeMounts + count: 1 + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].name + value: my-scripts + + - it: should inject mounts next to user mounts on unrelated paths + set: + clusterName: my-cluster + nodesets: + - <<: *worker + slurmd: + <<: *slurmd + volumes: + spool: {emptyDir: {}} + jail: {emptyDir: {}} + customVolumeMounts: + - {name: data, mountPath: /opt/slurm_scripts_extra, volumeSource: {emptyDir: {}}} + asserts: + - lengthEqual: + path: spec.slurmd.volumes.customVolumeMounts + count: 2 + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].name + value: slurm-scripts + - equal: + path: spec.slurmd.volumes.customVolumeMounts[1].name + value: data + + - it: should fall back to the slurm-cluster default name when clusterName is empty + asserts: + - equal: + path: spec.slurmd.volumes.jailSubMounts[0].volumeSource.configMap.name + value: helm-slurm-cluster-slurm-scripts + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.configMap.name + value: helm-slurm-cluster-slurm-scripts + + - it: should use an explicit slurmScriptsConfigMapName + set: + clusterName: my-cluster + slurmScriptsConfigMapName: custom-scripts + asserts: + - equal: + path: spec.slurmd.volumes.jailSubMounts[0].volumeSource.configMap.name + value: custom-scripts + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.configMap.name + value: custom-scripts + + - it: should use an explicit slurmScriptsConfigMapName with empty clusterName + set: + slurmScriptsConfigMapName: custom-scripts + asserts: + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.configMap.name + value: custom-scripts + + - it: should truncate a long clusterName like the slurm-cluster chart + set: + clusterName: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbb + asserts: + - equal: + path: spec.slurmd.volumes.jailSubMounts[0].volumeSource.configMap.name + value: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-slurm-scripts + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.configMap.name + value: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-slurm-scripts + + - it: should truncate a long clusterName without a trailing dash + set: + clusterName: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + asserts: + - equal: + path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.configMap.name + value: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-slurm-scripts diff --git a/helm/nodesets/tests/volumes_test.yaml b/helm/nodesets/tests/volumes_test.yaml index 11351c60c..ac0eb87eb 100644 --- a/helm/nodesets/tests/volumes_test.yaml +++ b/helm/nodesets/tests/volumes_test.yaml @@ -86,19 +86,19 @@ tests: - isNotEmpty: path: spec.slurmd.volumes.jailSubMounts - equal: - path: spec.slurmd.volumes.jailSubMounts[0].name + path: spec.slurmd.volumes.jailSubMounts[1].name value: "tmp" - equal: - path: spec.slurmd.volumes.jailSubMounts[0].mountPath + path: spec.slurmd.volumes.jailSubMounts[1].mountPath value: "/tmp" - equal: - path: spec.slurmd.volumes.jailSubMounts[0].subPath + path: spec.slurmd.volumes.jailSubMounts[1].subPath value: "tmp" - equal: - path: spec.slurmd.volumes.jailSubMounts[0].readOnly + path: spec.slurmd.volumes.jailSubMounts[1].readOnly value: false - exists: - path: spec.slurmd.volumes.jailSubMounts[0].volumeSource.emptyDir + path: spec.slurmd.volumes.jailSubMounts[1].volumeSource.emptyDir - it: should configure custom mounts correctly set: @@ -136,19 +136,19 @@ tests: - isNotEmpty: path: spec.slurmd.volumes.customVolumeMounts - equal: - path: spec.slurmd.volumes.customVolumeMounts[0].name + path: spec.slurmd.volumes.customVolumeMounts[1].name value: "tmp" - equal: - path: spec.slurmd.volumes.customVolumeMounts[0].mountPath + path: spec.slurmd.volumes.customVolumeMounts[1].mountPath value: "/tmp" - equal: - path: spec.slurmd.volumes.customVolumeMounts[0].subPath + path: spec.slurmd.volumes.customVolumeMounts[1].subPath value: "tmp" - equal: - path: spec.slurmd.volumes.customVolumeMounts[0].readOnly + path: spec.slurmd.volumes.customVolumeMounts[1].readOnly value: false - exists: - path: spec.slurmd.volumes.customVolumeMounts[0].volumeSource.emptyDir + path: spec.slurmd.volumes.customVolumeMounts[1].volumeSource.emptyDir - it: should configure security context correctly set: diff --git a/helm/nodesets/values.yaml b/helm/nodesets/values.yaml index 42c3356f6..a86c4b609 100644 --- a/helm/nodesets/values.yaml +++ b/helm/nodesets/values.yaml @@ -6,7 +6,7 @@ nameOverride: "" fullnameOverride: "" clusterName: "" -# Name of the slurm-scripts ConfigMap. Defaults to "-slurm-scripts". +# Name of the slurm-scripts ConfigMap. Defaults to "-slurm-scripts" ("helm-slurm-cluster" if clusterName is empty). slurmScriptsConfigMapName: "" # Priority Classes configuration # Define priority classes that can be used by NodeSets diff --git a/helm/slurm-cluster/templates/_helpers.tpl b/helm/slurm-cluster/templates/_helpers.tpl index 5513a78d3..96f64266e 100644 --- a/helm/slurm-cluster/templates/_helpers.tpl +++ b/helm/slurm-cluster/templates/_helpers.tpl @@ -33,10 +33,13 @@ {{- end -}} {{- end -}} -{{/* True if list has an entry with the given name. Usage: include "slurm-cluster.hasMountName" (dict "list" .volumeSources "name" "x") */}} -{{- define "slurm-cluster.hasMountName" -}} +{{/* True if list has an entry with the given name or mountPath. */}} +{{- define "slurm-cluster.hasMount" -}} {{- $found := false -}} -{{- range .list }}{{- if eq .name $.name }}{{ $found = true }}{{- end }}{{- end -}} +{{- $path := .path | default "" -}} +{{- range .list }} +{{- if or (eq .name $.name) (and $path .mountPath (eq (clean .mountPath) (clean $path))) }}{{ $found = true }}{{- end }} +{{- end -}} {{- $found -}} {{- end -}} diff --git a/helm/slurm-cluster/templates/slurm-cluster-cr.yaml b/helm/slurm-cluster/templates/slurm-cluster-cr.yaml index 8a88386cd..11792f938 100644 --- a/helm/slurm-cluster/templates/slurm-cluster-cr.yaml +++ b/helm/slurm-cluster/templates/slurm-cluster-cr.yaml @@ -103,7 +103,7 @@ spec: {{- end }} {{- end }} volumeSources: - {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.volumeSources "name" "slurm-scripts"))) }} + {{- if not (eq "true" (include "slurm-cluster.hasMount" (dict "list" .Values.volumeSources "name" "slurm-scripts"))) }} - name: slurm-scripts configMap: name: {{ include "slurm-cluster.slurmScriptsCMName" . }} @@ -482,12 +482,12 @@ spec: jailSubMounts: {{- default list .Values.slurmNodes.login.volumes.jailSubMounts | toYaml | nindent 10 }} customMounts: - {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts"))) }} + {{- if not (eq "true" (include "slurm-cluster.hasMount" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts" "path" "/opt/slurm_scripts"))) }} - name: slurm-scripts mountPath: /opt/slurm_scripts/ volumeSourceName: slurm-scripts {{- end }} - {{- if not (eq "true" (include "slurm-cluster.hasMountName" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts-jail"))) }} + {{- if not (eq "true" (include "slurm-cluster.hasMount" (dict "list" .Values.slurmNodes.login.volumes.customMounts "name" "slurm-scripts-jail" "path" "/mnt/jail.upper/opt/slurm_scripts"))) }} - name: slurm-scripts-jail mountPath: /mnt/jail.upper/opt/slurm_scripts/ volumeSourceName: slurm-scripts diff --git a/helm/slurm-cluster/tests/slurm_scripts_mount_test.yaml b/helm/slurm-cluster/tests/slurm_scripts_mount_test.yaml new file mode 100644 index 000000000..bbe764a63 --- /dev/null +++ b/helm/slurm-cluster/tests/slurm_scripts_mount_test.yaml @@ -0,0 +1,107 @@ +suite: test slurm-scripts mount injection +templates: + - templates/slurm-cluster-cr.yaml +tests: + - it: should inject volume source and login mounts with defaults + set: + clusterName: my-cluster + asserts: + - equal: + path: spec.volumeSources[0] + value: + name: slurm-scripts + configMap: {name: my-cluster-slurm-scripts, defaultMode: 493} + - equal: + path: spec.slurmNodes.login.volumes.customMounts + value: + - {name: slurm-scripts, mountPath: /opt/slurm_scripts/, volumeSourceName: slurm-scripts} + - {name: slurm-scripts-jail, mountPath: /mnt/jail.upper/opt/slurm_scripts/, volumeSourceName: slurm-scripts} + + - it: should not duplicate login mounts that already exist with the same name + set: + clusterName: my-cluster + slurmNodes: + login: + volumes: + customMounts: + - {name: slurm-scripts, mountPath: /custom/scripts, volumeSourceName: my-source} + - {name: slurm-scripts-jail, mountPath: /mnt/jail.upper/custom/scripts, volumeSourceName: my-source} + asserts: + - equal: + path: spec.slurmNodes.login.volumes.customMounts + value: + - {name: slurm-scripts, mountPath: /custom/scripts, volumeSourceName: my-source} + - {name: slurm-scripts-jail, mountPath: /mnt/jail.upper/custom/scripts, volumeSourceName: my-source} + + - it: should not inject login mounts that use another name but the same mountPath + set: + clusterName: my-cluster + slurmNodes: + login: + volumes: + customMounts: + - {name: my-scripts, mountPath: /opt/slurm_scripts, volumeSourceName: my-source} + - {name: my-scripts-jail, mountPath: /mnt/jail.upper/opt/./slurm_scripts//, volumeSourceName: my-source} + asserts: + - equal: + path: spec.slurmNodes.login.volumes.customMounts + value: + - {name: my-scripts, mountPath: /opt/slurm_scripts, volumeSourceName: my-source} + - {name: my-scripts-jail, mountPath: /mnt/jail.upper/opt/./slurm_scripts//, volumeSourceName: my-source} + + - it: should inject login mounts next to user mounts on unrelated paths + set: + clusterName: my-cluster + slurmNodes: + login: + volumes: + customMounts: + - {name: data, mountPath: /opt/slurm_scripts_extra, volumeSourceName: my-source} + asserts: + - lengthEqual: + path: spec.slurmNodes.login.volumes.customMounts + count: 3 + - equal: + path: spec.slurmNodes.login.volumes.customMounts[2].name + value: data + + - it: should not duplicate an existing slurm-scripts volume source + set: + clusterName: my-cluster + volumeSources: + - name: slurm-scripts + emptyDir: {} + asserts: + - lengthEqual: + path: spec.volumeSources + count: 1 + - equal: + path: spec.volumeSources[0] + value: + name: slurm-scripts + emptyDir: {} + + - it: should fall back to the chart name when clusterName is empty + set: + clusterName: "" + asserts: + - equal: + path: spec.volumeSources[0].configMap.name + value: helm-slurm-cluster-slurm-scripts + + - it: should use an explicit slurmScriptsConfigMapName + set: + clusterName: my-cluster + slurmScriptsConfigMapName: custom-scripts + asserts: + - equal: + path: spec.volumeSources[0].configMap.name + value: custom-scripts + + - it: should truncate a long clusterName and trim a trailing dash + set: + clusterName: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbb + asserts: + - equal: + path: spec.volumeSources[0].configMap.name + value: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-slurm-scripts