Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp run: wait for cgroup and call sd_notify() #203

Merged
merged 3 commits into from
Feb 27, 2025

Conversation

garlick
Copy link
Member

@garlick garlick commented Feb 27, 2025

This prepares to let imp run run as the main process in a user systemd instance

  • wait for cgroup to empty out before exiting
  • call sd_notify() so Type=notify unit can be used (and allow NOTIFY_SOCKET to be passed thru the environment).

It is built on top of #201

grondo
grondo previously approved these changes Feb 27, 2025
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One suggestion inline.

src/imp/run.c Outdated
@@ -281,6 +281,7 @@ int imp_run_privileged (struct imp_state *imp,
struct kv *kv_env;
const char *name;
const cf_t *cf_run;
const char *notify_socket = getenv ("NOTIFY_SOCKET");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could instead add this variable to run_env_var_allowed() for consistency with FLUX_JOB_ID and FLUX_JOB_USERID.

If that isn't desirable, a comment here might help remind a reader why this variable is special (though admittedly at this point it's obvious)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, i tried that originally and it didn't work for some reason and got myself a little confused in the process. Let me try again and see if I can run down what's happening.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the privileged imp process has its environment cleared, and the environment curated by the unprivileged imp process is passed through to execve(). But the imp itself, whose environment remains empty, will be making the sd_notify() calls so this does need to be handled differently.

I'll add a comment.

@mergify mergify bot dismissed grondo’s stale review February 27, 2025 16:09

The merge-base changed after approval.

Problem: imp run doesn't wait for its cgroup to empty out,
even when running as the main process of a systemd unit in the
flux systemd instance.

Add a call to cgroup_wait_for_empty ().

Fixes flux-framework#202
Problem: NOTIFY_SOCKET is filtered out of imp run's environment,
but it is needed to call sd_notify().

Ensure it passes through.
Problem: imp run should support running with type=notify when
launched by sdexec as the main process of a systemd unit.

Make the appropriate sd_notify(3) calls in imp run, similar to
what was done for imp exec.
@garlick
Copy link
Member Author

garlick commented Feb 27, 2025

Also need reapproval on this one :-)

Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

@mergify mergify bot merged commit b19503a into flux-framework:master Feb 27, 2025
17 checks passed
@garlick garlick deleted the imp_run_cgroup branch February 27, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants