Skip to content

Commit

Permalink
HTCONDOR-570 Allow SINGULARITY_EXTRA_ARGUMENTS to be a classad
Browse files Browse the repository at this point in the history
expression or a raw string
  • Loading branch information
GregThain committed Sep 30, 2021
1 parent 4de3b21 commit 5b1f6a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docs/admin-manual/configuration-macros.rst
Expand Up @@ -6063,8 +6063,9 @@ These settings affect the *condor_starter*.
the target, then skip this bind mount.

:macro-def:`SINGULARITY_EXTRA_ARGUMENTS`
A string value containing a list of extra arguments to be appended
to the Singularity command line.
A string value or classad expression containing a list of extra arguments to be appended
to the Singularity command line. This can be an expression evaluted in the context of the
job ad and the machine ad.

condor_submit Configuration File Entries
-----------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions docs/admin-manual/singularity-support.rst
Expand Up @@ -191,13 +191,16 @@ on hold. This is controlled by the condor knob
If an administrator wants to pass additional arguments to the
singularity exec command that HTCondor does not currently support, the
parameter ``SINGULARITY_EXTRA_ARGUMENTS`` allows arbitraty additional
parameters to be passed to the singularity exec command. For example, to
parameters to be passed to the singularity exec command. Note that this
can be a classad expression, evaluated in the context of the job ad
and the machine, so the admin could set different options for different
kinds of jobs. For example, to
pass the ``-w`` argument, to make the image writeable, an administrator
could set

.. code-block:: condor-config
SINGULARITY_EXTRA_ARGUMENTS = -w
SINGULARITY_EXTRA_ARGUMENTS = "-w"
There are some rarely-used settings that some administrators may
need to set. By default, HTCondor looks for the Singularity runtime
Expand Down
3 changes: 2 additions & 1 deletion docs/version-history/development-release-series-91.rst
Expand Up @@ -15,7 +15,8 @@ Release Notes:

New Features:

- None.
- SINGULARITY_EXTRA_ARGUMENTS can now be a classad expression, so that the extra arguments
can depend on the job. HTCONDOR-570

Bugs Fixed:

Expand Down
16 changes: 12 additions & 4 deletions src/condor_starter.V6.1/singularity.cpp
Expand Up @@ -281,14 +281,22 @@ Singularity::setup(ClassAd &machineAd,
sing_args.AppendArg("-C");

std::string args_error;
char *tmp = param("SINGULARITY_EXTRA_ARGUMENTS");
if(!sing_args.AppendArgsV1RawOrV2Quoted(tmp,args_error)) {
std::string sing_extra_args;

if (!param_eval_string(sing_extra_args, "SINGULARITY_EXTRA_ARGUMENTS", "", &machineAd, &jobAd)) {
// SINGULARITY_EXTRA_ARGUMENTS isn't a valid expression. Try just an unquoted string
char *xtra = param("SINGULARITY_EXTRA_ARGUMENTS");
if (xtra) {
sing_extra_args = xtra;
free(xtra);
}
}

if(!sing_extra_args.empty() && !sing_args.AppendArgsV1RawOrV2Quoted(sing_extra_args.c_str(),args_error)) {
dprintf(D_ALWAYS,"singularity: failed to parse extra arguments: %s\n",
args_error.c_str());
free(tmp);
return Singularity::FAILURE;
}
if (tmp) free(tmp);

// if the startd has assigned us a gpu, add --nv to the sing exec
// arguments to mount the nvidia devices
Expand Down

0 comments on commit 5b1f6a8

Please sign in to comment.