From 87fa3bb336b3baafa0ed3e922a27e6e8abdc8f89 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 19 Mar 2021 16:37:31 +0100 Subject: [PATCH] sbatch: assert types to avoid silent parse errors --- NOISE | 13 +++++++++++++ garlic/stages/sbatch.nix | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/NOISE b/NOISE index ccc460c..32cda73 100644 --- a/NOISE +++ b/NOISE @@ -120,5 +120,18 @@ ABSTRACT we build within Nix, they will be copied with the current data and consequently not updated during the Nix compilation process. +1.9 Sbatch silently fails on parsing + + When submitting a job with a wrong specification in MN4 with SLURM + 17.11.9-2, for example this bogus line: + + #SBATCH --nodes=1 2 + + It silently fails to parse the options, falling back to the defaults, + without any error. + + We have improved our checking to detect bogus options passed to SLURM, + so we prevent this problem from happening. + /* vim: set ts=2 sw=2 tw=72 fo=watqc expandtab spell autoindent: */ diff --git a/garlic/stages/sbatch.nix b/garlic/stages/sbatch.nix index d088807..b32334b 100644 --- a/garlic/stages/sbatch.nix +++ b/garlic/stages/sbatch.nix @@ -22,7 +22,6 @@ , time ? null , output ? "stdout.log" , error ? "stderr.log" -, contiguous ? null , extra ? null , acctgFreq ? null }: @@ -30,6 +29,24 @@ with stdenv.lib; with garlicTools; +# sbatch fails silently if we pass garbage, so we assert the types here to avoid +# sending `nodes = [ 1 2 ]` by mistake. +assert (jobName != null) -> isString jobName; +assert (chdir != null) -> isString chdir; +assert (nixPrefix != null) -> isString nixPrefix; +assert (ntasks != null) -> isInt ntasks; +assert (ntasksPerNode != null) -> isInt ntasksPerNode; +assert (ntasksPerSocket != null) -> isInt ntasksPerSocket; +assert (cpusPerTask != null) -> isInt cpusPerTask; +assert (nodes != null) -> isInt nodes; +assert (exclusive != null) -> isBool exclusive; +assert (qos != null) -> isString qos; +assert (reservation != null) -> isString reservation; +assert (time != null) -> isString time; +assert (output != null) -> isString output; +assert (error != null) -> isString error; +assert (extra != null) -> isString extra; + let sbatchOpt = name: value: optionalString (value!=null)