diff --git a/helm/slurm-cluster/templates/slurm-scripts-cm.yaml b/helm/slurm-cluster/templates/slurm-scripts-cm.yaml index 8a28efbce..24a47ea7f 100644 --- a/helm/slurm-cluster/templates/slurm-scripts-cm.yaml +++ b/helm/slurm-cluster/templates/slurm-scripts-cm.yaml @@ -24,7 +24,11 @@ data: {{- if $conf.customContent }} {{ tpl ($conf.customContent) $ | indent 4 }} {{- else }} -{{ tpl (printf "slurm_scripts/%s" $name | $.Files.Get) $ | indent 4 }} + {{- $content := printf "slurm_scripts/%s" $name | $.Files.Get }} + {{- if not $content }} + {{- fail (printf "slurmScripts.builtIn.%s is enabled but no bundled script exists; remove this obsolete entry or set customContent" $name) }} + {{- end }} +{{ tpl $content $ | indent 4 }} {{- end }} {{- end }} {{- end }} @@ -41,7 +45,11 @@ data: {{- if $conf.customConfig }} {{- $checks = append $checks (fromJson (tpl ($conf.customConfig) $)) }} {{- else }} - {{- $checks = append $checks (fromJson (tpl (printf "slurm_scripts/%s.json" $name | $.Files.Get) $)) }} + {{- $config := printf "slurm_scripts/%s.json" $name | $.Files.Get }} + {{- if not $config }} + {{- fail (printf "slurmScripts.builtIn.%s is enabled but no bundled check configuration exists; remove this obsolete entry or set customConfig" $name) }} + {{- end }} + {{- $checks = append $checks (fromJson (tpl $config $)) }} {{- end }} {{- end }} {{- end }} diff --git a/helm/slurm-cluster/tests/slurm_scripts_test.yaml b/helm/slurm-cluster/tests/slurm_scripts_test.yaml new file mode 100644 index 000000000..8c874c056 --- /dev/null +++ b/helm/slurm-cluster/tests/slurm_scripts_test.yaml @@ -0,0 +1,26 @@ +suite: test Slurm scripts configuration +templates: + - slurm-scripts-cm.yaml +tests: + - it: should reject an enabled built-in without a bundled script + set: + slurmScripts: + builtIn: + removed_check.sh: + enabled: true + asserts: + - failedTemplate: + errorMessage: "slurmScripts.builtIn.removed_check.sh is enabled but no bundled script exists; remove this obsolete entry or set customContent" + + - it: should reject an enabled built-in without a bundled check configuration + set: + slurmScripts: + builtIn: + removed_check.sh: + enabled: true + customContent: |- + #!/bin/bash + exit 0 + asserts: + - failedTemplate: + errorMessage: "slurmScripts.builtIn.removed_check.sh is enabled but no bundled check configuration exists; remove this obsolete entry or set customConfig"