Skip to content

Commit

Permalink
Merge pull request #5759 from grondo/issue#5755
Browse files Browse the repository at this point in the history
shell: unset `HWLOC_COMPONENTS` with `hwloc.xmlfile`
  • Loading branch information
mergify[bot] committed Feb 28, 2024
2 parents 76dd4c5 + e819222 commit 51823b8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/man1/common/job-shell-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
nonzero exit code.

* - :option:`hwloc.xmlfile`
- Write hwloc XML gathered by job to a file and set ``HWLOC_XMLFILE``
- Write hwloc XML gathered by job to a file and set ``HWLOC_XMLFILE``.
Note that this option will also unset ``HWLOC_COMPONENTS`` if set, since
presence of this environment variable may cause hwloc to ignore
``HWLOC_XMLFILE``.

* - :option:`output.limit`
- Set KVS output limit to SIZE bytes, where SIZE may be a floating point
Expand Down
2 changes: 2 additions & 0 deletions doc/man1/flux-shell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ plugins include:
.. option:: hwloc.xmlfile

Write the job shell's copy of hwloc XML to a file and set ``HWLOC_XMLFILE``.
Note that this option will also unset ``HWLOC_COMPONENTS`` since presence
of this environment variable may cause hwloc to ignore ``HWLOC_XMLFILE``.

.. warning::
The directory referenced by :envvar:`FLUX_JOB_TMPDIR` is cleaned up when the
Expand Down
8 changes: 8 additions & 0 deletions src/shell/hwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ static int create_xmlfile (flux_shell_t *shell)
shell_log_errno ("failed to set HWLOC_XMLFILE in job environment");
goto error;
}
/* Note: HWLOC_XMLFILE will be ignored if HWLOC_COMPONENTS is also set
* in the environment, so unset that variable here.
*/
if (flux_shell_unsetenv (shell, "HWLOC_COMPONENTS") < 0
&& errno != ENOENT) {
shell_log_errno ("failed to unset HWLOC_COMPONENTS");
goto error;
}
return 0;
error:
if (fd >= 0)
Expand Down
4 changes: 4 additions & 0 deletions t/t2619-job-shell-hwloc.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ test_expect_success 'shell: HWLOC_XMLFILE is not set for normal jobs' '
test_expect_success 'shell: -o hwloc.xmlfile sets HWLOC_XMLFILE' '
flux run -o hwloc.xmlfile printenv HWLOC_XMLFILE
'
test_expect_success 'shell: -o hwloc.xmlfile unsets HWLOC_COMPONENTS' '
test_must_fail flux run --env=HWLOC_COMPONENTS=x86 -o hwloc.xmlfile \
printenv HWLOC_COMPONENTS
'
command -v hwloc-info >/dev/null && test_set_prereq HWLOC_INFO
test_expect_success HWLOC_INFO 'shell: -o hwloc.xmlfile HWLOC_XMLFILE is valid' '
flux run -o hwloc.xmlfile sh -c "hwloc-info --input \$HWLOC_XMLFILE"
Expand Down

0 comments on commit 51823b8

Please sign in to comment.