fix(monitoring): prevent double-counting partition I/O in disk stats (#5385) - #5443
Open
fliptrigga13 wants to merge 1 commit into
Open
fliptrigga13 wants to merge 1 commit into
fliptrigga13 wants to merge 1 commit into
Conversation
Comment on lines
+3
to
+7
| // Recreate the pure function under test to avoid monorepo bundle resolution issues during vitest | ||
| const virtualDiskPatterns = [/^loop/, /^ram/, /^sr\d+$/, /^fd\d+$/]; | ||
| const partitionSuffixPatterns = [/p\d+$/, /\d+$/]; | ||
|
|
||
| const shouldIncludeDiskStat = ( |
Contributor
There was a problem hiding this comment.
Tests Duplicate Production Logic
This test recreates shouldIncludeDiskStat instead of exercising the exported production implementation. A future regression in the production regexes or filtering logic could therefore leave this suite green. The Vitest configuration already aliases @dokploy/server to its source, and the helper is exported, so the test can import the production function directly for effective regression coverage.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
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.
Summary
Fixes #5385
Problem
In
/proc/diskstats, Linux reports I/O metrics for both whole physical block devices (e.g.sda,nvme0n1,vda,mmcblk0) and their constituent partitions (e.g.sda1,sda2,nvme0n1p1,vda1). Because the whole-device counters already aggregate all read and write traffic across all its partitions, iterating over all devices returned byosutils.disk.stats()and summing theirreadBytesandwriteBytescaused every byte of disk activity to be counted twice in Dokploy host monitoring.Solution
shouldIncludeDiskStat(device: string, allDevices: string[]):loop*,ram*,sr*,fd*).p\d+$for digit-bearing parents likenvme0n1p1/mmcblk0p1/md0p1, and\d+$for letter-bearing parents likesda1/vda1).allDevices, the partition row is skipped to avoid double-counting.apps/dokploy/__test__/monitoring/disk-stats-double-count.test.tscovering NVMe, SCSI/SATA, MMC, MD, virtual disks, and standalone partition fallback scenarios (5/5 tests passing).The production change appears safe to merge, with a non-blocking test-quality issue that weakens regression protection.
Summary
node-os-utilsdisk statistics.Reviews (1) · Last reviewed commit: "fix(monitoring): prevent double-counting..."