Skip to content

modprobe: fix handling of modprobe.Context.bash() errors and expand testing #6957

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

Merged
merged 6 commits into from
Aug 9, 2025

Conversation

grondo
Copy link
Contributor

@grondo grondo commented Aug 8, 2025

This PR fixes the modprobe.Context.bash() helper, which currently is ignoring non-zero exit status from the invoked command(s).

Additionally, a few more tests are added to the modprobe testsuite to check that the bash() helper is working properly, and that module load failures (and other @task failures) cause flux modprobe to fail.

grondo added 2 commits August 8, 2025 10:08
Problem: sched-simple uses flux_log_error() when logging an error
message about a bad module argument, but errno is not valid here
so this call is not appropriate.

Switch to flux_log() with LOG_ERR.
Problem: The Context class bash() helper function doesn't catch nonzero
exit codes from the subprocess, which could lead to an instance being
started in an inconsistent state.

Switch to subprocess.run() instead of Popen() and check the
CompletedProcess returncode. Raise an appropriate RuntimError if the
process exited with a non-zero status.
Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

LGTM!

@grondo
Copy link
Contributor Author

grondo commented Aug 8, 2025

Thanks. I have a couple more improvements incoming here...

grondo added 4 commits August 8, 2025 16:22
Problem: `Modprobe.load()` tries to load target modules and all their
dependencies, which results in unnecessary errors when modules are
already loaded.

Get the list of loaded modules and filter them from the set of target
modules to load. If the set of modules to load is empty after this
step, raise `FileExistsError` with an appropriate message that there
was nothing to do.
Problem: `flux modprobe load` loads target modules and their
dependencies when necessary, but it will exit with nonzero exit status
if all modules are already loaded.

Downgrade the error that there was nothing to do to an informational
message and exit with success.
Problem: The description of `flux modprobe load` in flux-modprobe(1)
is insufficient as it does not describe the new behavior of the
command when modules are already loaded.

Add a paragraph to `flux-modprobe(1)` describing this behavior.
Problem: The modprobe tests in t0100-modprobe.t do not ensure that
some failures result in flux-modprobe (and thus rc1/rc3) failure,
and that `flux modprobe load <module>` doesn't error if module is
already loaded.

Expand tests in `t0100-modprobe.t` to cover these cases.
@grondo
Copy link
Contributor Author

grondo commented Aug 8, 2025

Ok, sorry about that @garlick. Changes since your last review:

  • Changed flux modprobe load so it ignores already loaded modules. Unlike flux module load, It is not an error if a module and all its dependencies are already loaded. Document this.
  • Add a test for the above
  • Simplify use of flux modprobe load in one test in the testsuite.

Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

Looks Even Better To Me! (LEBTM?)

@mergify mergify bot merged commit fc7adcc into flux-framework:master Aug 9, 2025
59 of 60 checks passed
Copy link

codecov bot commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.00%. Comparing base (6abf2b3) to head (f8e550c).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/bindings/python/flux/modprobe.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6957      +/-   ##
==========================================
- Coverage   84.04%   84.00%   -0.04%     
==========================================
  Files         545      545              
  Lines       91811    91822      +11     
==========================================
- Hits        77163    77139      -24     
- Misses      14648    14683      +35     
Files with missing lines Coverage Δ
src/cmd/flux-modprobe.py 97.22% <100.00%> (+0.05%) ⬆️
src/modules/sched-simple/sched.c 79.92% <100.00%> (+0.55%) ⬆️
src/bindings/python/flux/modprobe.py 96.03% <90.90%> (-0.50%) ⬇️

... and 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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