Skip to content

Commit 51823b8

Browse files
authored
Merge pull request #5759 from grondo/issue#5755
shell: unset `HWLOC_COMPONENTS` with `hwloc.xmlfile`
2 parents 76dd4c5 + e819222 commit 51823b8

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

doc/man1/common/job-shell-options.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
nonzero exit code.
3939

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

4346
* - :option:`output.limit`
4447
- Set KVS output limit to SIZE bytes, where SIZE may be a floating point

doc/man1/flux-shell.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ plugins include:
449449
.. option:: hwloc.xmlfile
450450

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

453455
.. warning::
454456
The directory referenced by :envvar:`FLUX_JOB_TMPDIR` is cleaned up when the

src/shell/hwloc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ static int create_xmlfile (flux_shell_t *shell)
6262
shell_log_errno ("failed to set HWLOC_XMLFILE in job environment");
6363
goto error;
6464
}
65+
/* Note: HWLOC_XMLFILE will be ignored if HWLOC_COMPONENTS is also set
66+
* in the environment, so unset that variable here.
67+
*/
68+
if (flux_shell_unsetenv (shell, "HWLOC_COMPONENTS") < 0
69+
&& errno != ENOENT) {
70+
shell_log_errno ("failed to unset HWLOC_COMPONENTS");
71+
goto error;
72+
}
6573
return 0;
6674
error:
6775
if (fd >= 0)

t/t2619-job-shell-hwloc.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ test_expect_success 'shell: HWLOC_XMLFILE is not set for normal jobs' '
1414
test_expect_success 'shell: -o hwloc.xmlfile sets HWLOC_XMLFILE' '
1515
flux run -o hwloc.xmlfile printenv HWLOC_XMLFILE
1616
'
17+
test_expect_success 'shell: -o hwloc.xmlfile unsets HWLOC_COMPONENTS' '
18+
test_must_fail flux run --env=HWLOC_COMPONENTS=x86 -o hwloc.xmlfile \
19+
printenv HWLOC_COMPONENTS
20+
'
1721
command -v hwloc-info >/dev/null && test_set_prereq HWLOC_INFO
1822
test_expect_success HWLOC_INFO 'shell: -o hwloc.xmlfile HWLOC_XMLFILE is valid' '
1923
flux run -o hwloc.xmlfile sh -c "hwloc-info --input \$HWLOC_XMLFILE"

0 commit comments

Comments
 (0)