Skip to content

fix(network-segment): make dual-stack metrics deterministic - #5632

Open
pbreton wants to merge 1 commit into
NVIDIA:mainfrom
pbreton:5402
Open

fix(network-segment): make dual-stack metrics deterministic#5632
pbreton wants to merge 1 commit into
NVIDIA:mainfrom
pbreton:5402

Conversation

@pbreton

@pbreton pbreton commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Network-segment compatibility metrics expose one prefix per segment. The controller selected prefixes[0], but database prefix aggregation does not guarantee row order, so a dual-stack segment could alternate between IPv4 and IPv6 labels and counts.

This change explicitly prefers the IPv4 prefix for the existing compatibility series and retains the IPv6 prefix for IPv6-only segments. Metric names and label names remain unchanged.

Related issues

Fixes #5402.

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Validation performed:

  • cargo test -p carbide-network-segment-controller
  • cargo clippy -p carbide-network-segment-controller --all-targets --all-features -- -D warnings
  • cargo +nightly fmt --all -- --check
  • cargo check -p carbide-api-core --lib --no-default-features
  • git diff --check

The reversed-prefix regression was confirmed to fail before the fix and pass afterward.

Additional Notes

This is an attempt at fully automated issue resolution using Codex.

@copy-pr-bot

copy-pr-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@pbreton

pbreton commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d24a18b8-2386-46ae-8073-971976773a0c

📥 Commits

Reviewing files that changed from the base of the PR and between 8149a4a and db503f6.

📒 Files selected for processing (1)
  • crates/network-segment-controller/src/handler.rs

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


Summary by CodeRabbit

  • Bug Fixes
    • Improved network-segment metrics for dual-stack configurations by consistently prioritizing IPv4 address ranges.
    • Added reliable fallback handling for IPv6-only configurations.
    • Corrected metric values and address-space calculations that could vary based on prefix ordering.
    • Improved consistency and accuracy of network capacity reporting across different segment configurations.

Walkthrough

The handler now selects an IPv4 prefix for network-segment metrics when available. IPv6-only segments use their first prefix. Tests cover dual-stack prefix order and IPv6 fallback.

Changes

Network-segment metrics

Layer / File(s) Summary
Compatibility prefix selection
crates/network-segment-controller/src/handler.rs
The handler prefers the first IPv4 prefix and falls back to the first available prefix.
Metric integration and validation
crates/network-segment-controller/src/handler.rs
Available IPs, reserved IPs, reported prefixes, and address-space calculations use the selected prefix. Tests cover dual-stack order independence and IPv6-only fallback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to db503

The change makes compatibility metrics deterministic while preserving the existing metric interface. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #5402 by removing prefix-order dependence, defining deterministic dual-stack selection, preserving IPv6-only behavior, and keeping metric names unchanged.
Out of Scope Changes check ✅ Passed The reported changes are limited to network-segment metric prefix selection and related regression tests. No unrelated code changes are identified.
Title check ✅ Passed The title clearly and concisely describes the primary change: deterministic dual-stack metrics for network segments.
Description check ✅ Passed The description directly explains the prefix-order bug, the IPv4 preference and IPv6 fallback, the compatibility constraints, and the validation performed.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@pbreton

pbreton commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@pbreton I will perform a complete review of #5632.

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@pbreton I will perform a complete review of #5632.

✅ Action performed

Full review finished.

@pbreton pbreton self-assigned this Sep 1, 2026
@pbreton
pbreton marked this pull request as ready for review September 1, 2026 19:42
@pbreton
pbreton requested a review from a team as a code owner September 1, 2026 19:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T19:44:16.039420Z db503f6 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Signed-off-by: Patrice Breton <pbreton@nvidia.com>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make network-segment metrics deterministic for dual-stack prefixes

1 participant