Skip to content

in_node_exporter_metrics: Skip ipv6 metrics collection when disabled#11773

Merged
edsiper merged 1 commit intofluent:masterfrom
piwai:skip-ipv6-metrics-if-disabled
May 4, 2026
Merged

in_node_exporter_metrics: Skip ipv6 metrics collection when disabled#11773
edsiper merged 1 commit intofluent:masterfrom
piwai:skip-ipv6-metrics-if-disabled

Conversation

@piwai
Copy link
Copy Markdown
Contributor

@piwai piwai commented May 4, 2026

The stat() pre-check on /proc/net/sockstat6 will avoid having lots of "no such file or directory" errors when trying to collect ipv6 metrics on hosts where ipv6 is disabled.


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:

  • [N/A] Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • Backport to latest stable release.

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

  • Bug Fixes
    • Improved detection and error handling when IPv6 socket statistics are unavailable, avoiding erroneous failures on systems without IPv6 metrics.
    • Added safer path validation to prevent malformed IPv6 proc paths from causing errors and to skip missing files gracefully.

@piwai piwai requested review from cosmo0920 and edsiper as code owners May 4, 2026 13:58
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78ea4d1e-45f2-4124-a56d-10f8b2902a7e

📥 Commits

Reviewing files that changed from the base of the PR and between 2e0661e and 36ac632.

📒 Files selected for processing (1)
  • plugins/in_node_exporter_metrics/ne_sockstat_linux.c

📝 Walkthrough

Walkthrough

Adds filesystem existence checks for IPv6 sockstat in the Linux node exporter metrics plugin: includes system headers and updates sockstat_update() to construct the IPv6 procfs path, validate its length, call stat(), skip IPv6 collection on ENOENT, or proceed to read/parse when present. (50 words)

Changes

IPv6 Availability Detection

Layer / File(s) Summary
Header additions
plugins/in_node_exporter_metrics/ne_sockstat_linux.c
Adds #include <sys/stat.h>, #include <errno.h>, and #include <limits.h> to support path sizing and stat()/errno handling.
Local state / buffers
plugins/in_node_exporter_metrics/ne_sockstat_linux.c
Introduces path_len, ipv6_proc_path[PATH_MAX], and struct stat st in sockstat_update() for IPv6 proc path construction and stat() result storage.
IPv6 availability check
plugins/in_node_exporter_metrics/ne_sockstat_linux.c
Constructs ctx->path_procfs + "/net/sockstat6", validates snprintf length (returns -1 on overflow), calls stat() and returns 0 (with debug log) if stat() fails with ENOENT, otherwise continues.
Parsing continuation
plugins/in_node_exporter_metrics/ne_sockstat_linux.c
Keeps existing IPv6 parsing logic (tokenizing lines like TCP6:, UDP6:) but only executes it after the stat() guard and subject to ne_utils_file_read_lines() success.

Sequence Diagram(s)

(Skipped — changes are a small availability check and do not introduce multi-component sequential control flow warranting a diagram.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • edsiper
  • cosmo0920

Poem

🐰 I hop along the procfs lane,
I sniff sockstat6 for any gain,
If missing, I politely say "nope",
Else I read and parse with hope,
Metrics safe — and that's my refrain.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a pre-check to skip IPv6 metrics collection when IPv6 is disabled, which aligns with the stat() check on /proc/net/sockstat6.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e0661eeb0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/in_node_exporter_metrics/ne_sockstat_linux.c Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/in_node_exporter_metrics/ne_sockstat_linux.c`:
- Around line 172-175: The ipv6_proc_path buffer is fixed at 32 bytes which can
truncate path_procfs and the code currently treats any stat() error as IPv6
disabled; change ipv6_proc_path to use PATH_MAX, after snprintf() verify the
returned length fits (detect truncation) and handle that as an error, call
stat() and only treat ENOENT as "IPv6 disabled" (set ipv6_enabled = 0); for any
other stat() failures propagate/allow ne_utils_file_read_lines() to handle and
log them rather than returning early; update references in this function to use
the new PATH_MAX-sized ipv6_proc_path and the ENOENT check.
🪄 Autofix (Beta)

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

Run ID: 9ea4c733-18f5-4fe5-b804-bd7aec72de7c

📥 Commits

Reviewing files that changed from the base of the PR and between 1e69f37 and 2e0661e.

📒 Files selected for processing (1)
  • plugins/in_node_exporter_metrics/ne_sockstat_linux.c

Comment thread plugins/in_node_exporter_metrics/ne_sockstat_linux.c Outdated
The stat() pre-check on /proc/net/sockstat6 will avoid having lots of
"no such file or directory" errors when trying to collect ipv6
metrics on hosts where ipv6 is disabled.

Signed-off-by: Pierre-Yves Rofes <3604235+piwai@users.noreply.github.com>
@piwai
Copy link
Copy Markdown
Contributor Author

piwai commented May 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@edsiper edsiper added this to the Fluent Bit v5.0.5 milestone May 4, 2026
@edsiper edsiper merged commit 86ec64a into fluent:master May 4, 2026
53 checks passed
@edsiper
Copy link
Copy Markdown
Member

edsiper commented May 4, 2026

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants