Disable sacct metrics if sacct exists but accounting is disabled#535
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Slurm sacct collector initialization to synchronously “preflight” sacct so the exporter can disable sacct metrics when Slurm accounting storage is disabled, and adjusts unit tests to mock the new subprocess call.
Changes:
- Add an
sacctpreflight call duringSacct.initialize()to detect the “Slurm accounting storage is disabled” message and raiseSacctNotAvailException. - Add/adjust tests to mock
subprocess.runand validate the accounting-disabled behavior.
| Criterion | Max Points | Points Awarded | Notes |
|---|---|---|---|
| PR Description Accuracy | 20 | 20 | Matches the changes (preflight to detect accounting disabled and disable collector). |
| PR Atomicity | 20 | 20 | Single cohesive change (collector behavior + tests). |
| Logical Implementation | 10 | 10 | Straightforward and localized. |
| Regression Risk | 10 | 0 | Disabling the collector on init can change global Prometheus output (see comment about disable_created_metrics() ordering). |
| Exception Handling | 10 | 10 | Preflight failure is handled without breaking init flow. |
| Code Comments | 10 | 10 | No problematic commentary introduced. |
| Repetitive Code | 10 | 10 | No significant duplication introduced. |
| Spelling | 5 | 5 | No spelling issues found in the changed code. |
| Logging Quality | 5 | 5 | Logging is generally clear for preflight failures/disablement. |
FINAL SCORE: 90/100
RECOMMENDATION: MERGE
RATIONALE: The change aligns with the PR’s goal and test coverage was updated accordingly. Consider addressing the noted Prometheus global-metric side effect to avoid unexpected output changes when accounting is disabled.
BLOCKERS: None
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| azure-slurm-exporter/exporter/sacct.py | Adds sacct preflight during initialization to detect disabled accounting and disable the collector. |
| azure-slurm-exporter/test/test_sacct.py | Mocks the new subprocess preflight call and adds a test for the accounting-disabled case. |
bwatrous
reviewed
Jul 7, 2026
bwatrous
previously approved these changes
Jul 7, 2026
azreenz
force-pushed
the
azreenzaman/exporter-sacct-fix
branch
from
July 13, 2026 19:43
0775d5f to
f77f636
Compare
azreenz
force-pushed
the
azreenzaman/exporter-sacct-fix
branch
from
July 15, 2026 16:54
f77f636 to
79c781d
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
aditigaur4
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Check AccountStorageType in scontrol show config during intialize step to check for slurm accounting. If accounting is disabled we disable the collector in the exporter. If scontrol show config fails to run during intialize step ie we don't know accounting is explictly disabled we allow the collector to run.
When sacct exisits but accounting is disabled we get the following warning in the log: