in_node_exporter_metrics: fix incorrect pointer arithmetic in diskstats metric cache - #12255
Open
ngillen wants to merge 1 commit into
Open
in_node_exporter_metrics: fix incorrect pointer arithmetic in diskstats metric cache#12255ngillen wants to merge 1 commit into
ngillen wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe diskstats plugin now uses contiguous metric caches on Linux and Darwin. Linux disk time metrics use a shared millisecond-to-second conversion constant. ChangesDiskstats metrics
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugins/in_node_exporter_metrics/ne_diskstats_linux.c`:
- Around line 85-91: Update metric_cache_set and metric_cache_update in
ne_diskstats_darwin.c to cast ctx->dt_metrics to struct dt_metric * rather than
struct dt_metric **, and access entries directly by cache[id] without deriving m
from &cache[id]. Preserve the existing metric and factor updates while using the
flat struct-sized layout.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 789ba633-26ec-47c6-a4bc-b1e19ea71284
📒 Files selected for processing (1)
plugins/in_node_exporter_metrics/ne_diskstats_linux.c
ngillen
force-pushed
the
fix/in_node_exporter_metrics-diskstats
branch
from
August 10, 2026 09:53
c16ed84 to
73ad335
Compare
ngillen
force-pushed
the
fix/in_node_exporter_metrics-diskstats
branch
from
August 10, 2026 09:56
73ad335 to
b216f2c
Compare
ctx->dt_metrics is a flat array of 'struct dt_metric', but metric_cache_set()/metric_cache_update() indexed it as an array of pointers, causing every entry past id=0 to read/write at the wrong offset. This corrupts both the scaling factor and the metric pointer, producing wildly incorrect node_disk_* values on Linux and a corrupted counter target on Darwin. Also extract the repeated .001 ms-to-seconds factor into a named MS_TO_SECONDS constant. Signed-off-by: Nicolas Gillen <nicolas.gillen@agregio-solutions.com>
ngillen
force-pushed
the
fix/in_node_exporter_metrics-diskstats
branch
from
August 10, 2026 09:59
b216f2c to
5e7f546
Compare
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.
ctx->dt_metricsis a flat array ofstruct dt_metric, butmetric_cache_set()/metric_cache_update()indexed it as an array of pointers, causing every entry past id=0 to read/write at the wrong offset. This corrupts both the scaling factor and the metric pointer, producing wildly incorrectnode_disk_*values on Linux and a corrupted counter target on Darwin.Also extract the repeated
.001ms-to-seconds factor into a namedMS_TO_SECONDSconstant.Fixes: #7583
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
Refactor
Bug Fixes