SCHED-1897: Add idle node memory health check#2773
Conversation
8ba59e7 to
137f04e
Compare
f883250 to
7ae1a4e
Compare
7ae1a4e to
9e0cbb1
Compare
| @@ -0,0 +1,91 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Some of our checks are already written in Python. Given that this check has Python tests, maybe write it in Python as well, and the testing part would be even easier?
There was a problem hiding this comment.
Python would simplify JSON parsing and enable more direct unit tests. However, most of the checks in this folder currently invoke shell scripts, and these Python tests deliberately exercise the shell command as a black box.
The scripts are mostly set of system commands.
I suggest keeping this check in shell for this PR and reconsidering Python if its logic grows.
There was a problem hiding this comment.
I think it's a historical mistake that we wrote these checks in Bash. Bash scripts are getting more and more complex, and it's very hard for humans to deal with this, even though they are written by AI agents now.
E.g., in this script, there is JSON parsing and several other parsers and validators; to work with them, you have to be a bash+jq+awk+whatever tools are used. With Python, you only need to be a Python expert.
But it's up to you, we have a lot of bash already :-)
| "node_states": ["any"], | ||
| "on_fail": "drain", | ||
| "on_ok": "none", | ||
| "reason_base": "[user_problem] $name", |
There was a problem hiding this comment.
@rdjjke We're introducing a new drain reason and it is fine. But what about the old alloc_mem_used drain reason? When we remove the old check we might have drained nodes which will never automatically be undrained.
So, we can avoid this by defining alloc_mem_used as a drain reason here, so we carry over the drain reason. Wht do you think? Do we have a lot of those nodes drained for this reason?
| if (.jobs | type) == "array" then | ||
| .jobs | length | ||
| else | ||
| error(".jobs must be an array") |
There was a problem hiding this comment.
What if the next version of Slurm returns not [], but null? Or even skip the job key (like in Go by default)? Looks like this check will stop working, always exiting 0
Summary
idle_mem_usedperiodic health check forhc_programscontrol listjobsRealMemoryvalue exposed by Expose node RealMemory without controller RPC #2774MemTotal - RealMemory, without a separate Helm thresholdMemAvailableis belowRealMemory, with an actionable diagnostic reasonWhy
This PR is related to the SCHED-1897 Jira ticket. Idle nodes retaining unexpectedly high memory usage may have leaked or spurious processes left behind by previous jobs. Detecting that condition periodically prevents affected nodes from silently returning to service.
Using local
scontrol listjobsavoids a controller RPC for idle detection. Deriving the threshold from SlurmRealMemorykeeps the check aligned with the worker memory configured by Soperator.Dependency
This PR is stacked on #2774, which publishes node
RealMemorylocally and makesCHECKS_NODE_REAL_MEM_BYTESRPC-free in the normal path. Merge #2774 first, then retarget this PR tomain.This replaces the feature diff from #2742. That PR was accidentally merged into #2743; #2774 replaces the detached #2743 pull ref and this PR carries only the dependent idle-memory check.
Impact
The check is enabled by default and runs only through Slurm's
HealthCheckProgram. Nodes with local Slurm jobs are left unchanged. Unexpectedlistjobsfailures, unavailable memory data, missingRealMemory, and inconsistent values fail open.On failure, the drain reason reports available memory, Slurm
RealMemory, the deficit, current used memory, and the derived maximum idle usage.Validation
python3 -m unittest discover -s helm/slurm-cluster/slurm_scripts -p '*_test.py' -v(15 tests passed)bash -n helm/slurm-cluster/slurm_scripts/idle_mem_used.shhelm/slurm-cluster/tests/idle_mem_used_test.yamlas YAMLgit diff --check agent/rpc-free-node-real-memory...HEAD