fix(collector): fix critical SwapUsedBytes underflow and table-drive memory tests#208
Open
ramnnn2006 wants to merge 1 commit into
Open
fix(collector): fix critical SwapUsedBytes underflow and table-drive memory tests#208ramnnn2006 wants to merge 1 commit into
ramnnn2006 wants to merge 1 commit into
Conversation
convert sequential tests in both files to table-driven with t.Run(tc.name). cover boundaries: zero total, swapfree > swaptotal underflow guard, fully used memory, exactly-at-threshold pct, and multiple concurrency profiles. also fix uint64 underflow in poll() when SwapFree exceeds SwapTotal. Signed-off-by: ramnnn2006 <phrkvvp@gmail.com>
|
🚀 First PR — welcome aboard! A few things to expect:
If you get stuck, reply here or jump to Discussions. We want this PR to land. |
Contributor
Author
|
hey @btwshivam , lmk if anything needs fixing, looking forward to contributing more! |
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.
What
fixes a critical uint64 underflow bug in
poll()whereSwapTotal - SwapFreesilently wraps to ~18 exabytes when the kernel reports
SwapFree > SwapTotal,corrupting the
SwapUsedBytesmetric fed into the doctor's oom_imminent rule.also a testing refactor converting all sequential cases in
memory_test.goandmemory_collector_test.gointo table-driven tests witht.Run.Why
Fixes #137
the bug is critical because the corrupted value propagates silently into oom
detection with no visible error, either triggering false alerts or masking real
memory pressure on kernels where this condition occurs (vm snapshots, hibernate
resume, live patching).
How
swapTotal > swapFreeguard before the subtraction inpoll(), clamps to 0 instead of wrappingTestMemoryCollectorPollconverted to a 6-case tablecovering zero total, no swap, swapfree > swaptotal (exercises the guard),
fully used memory, exactly-at-threshold pct, and error path
TestParseMeminfoLinewrapped existing cases int.RunTestCollectorMemoryHighCardinalityBurst,Sustained100Kps,ConcurrentRecordall converted to parametrized table cases with multipleload and concurrency profiles
Testing
go build ./...passesgo test ./...passesgo vet ./...passesgolangci-lint run ./...passesTested locally.
N/A — pure docs/refactor
sudo ./bin/bpf-verify --read 5sconfirms 6/6 programs still load./scripts/verify.shpasses (or specific phase:./scripts/verify.sh quality)Checklist
feat(scope): subject)git commit -s)scripts/verify.sh