Skip to content

Commit

Permalink
Merge pull request #5903 from garlick/issue#5901
Browse files Browse the repository at this point in the history
flux-exec: set up systemd environment to support sdexec debugging
  • Loading branch information
mergify[bot] committed Apr 20, 2024
2 parents 20ca0b8 + 5d58f34 commit 60f3341
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/man7/flux-environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ MISCELLANEOUS
command front end executable used by the ssh connector to start
:program:`flux relay` on the remote system.

.. envvar:: DBUS_SESSION_BUS_ADDRESS

:man1:`flux-exec` sets this to point to the Flux instance owner's
D-Bus instance, to ensure that a remote invocation of
:option:`systemctl --user` accesses the service manager for the Flux
instance owner. This is helpful when debugging a system instance
configured to launch jobs with systemd, as described in
:man5:`flux-config-exec`.


.. _sub_command_environment:

SUB-COMMAND ENVIRONMENT
Expand Down
1 change: 1 addition & 0 deletions doc/test/spell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,4 @@ unsatisfiable
validators
hostpids
Xauth
dbus
13 changes: 13 additions & 0 deletions src/cmd/flux-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,19 @@ int main (int argc, char *argv[])
&imp_path);
}

/* Allow systemd commands to work on flux systemd instance by
* setting DBUS_SESSION_BUS_ADDRESS if not already set.
* See flux-framework/flux-core#5901
*/
const char *security_owner;
if (!(security_owner = flux_attr_get (h, "security.owner")))
log_err_exit ("failed to fetch security.owner attribute");
(void)flux_cmd_setenvf (cmd,
0,
"DBUS_SESSION_BUS_ADDRESS",
"unix:path=/run/user/%s/bus",
security_owner);

/* Get input ranks from --jobid if given:
*/
if (optparse_getopt (opts, "jobid", &optargp) > 0) {
Expand Down
13 changes: 13 additions & 0 deletions t/t0005-exec.t
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,17 @@ test_expect_success 'stdin broadcast -- long lines' '
done
'

test_expect_success 'dbus environment variable is set' '
DBUS_SESSION_BUS_ADDRESS= \
flux exec -r 0 printenv DBUS_SESSION_BUS_ADDRESS
'
test_expect_success 'dbus environment variable is not overwritten if set' '
DBUS_SESSION_BUS_ADDRESS=xyz \
flux exec -r 0 printenv DBUS_SESSION_BUS_ADDRESS >dbus.out &&
cat >dbus.exp <<-EOT &&
xyz
EOT
test_cmp dbus.exp dbus.out
'

test_done

0 comments on commit 60f3341

Please sign in to comment.