Skip to content

fix(commons): handle missing MAC addresses - #3335

Merged
imbajin merged 3 commits into
apache:masterfrom
hugegraph:fix/commons-network-mac
Oct 13, 2026
Merged

imbajin merged 3 commits into
apache:masterfrom
hugegraph:fix/commons-network-mac

Conversation

@imbajin

@imbajin imbajin commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Purpose of the PR

VPN and tunnel interfaces can have an IP address without a hardware address. Previously MAC discovery threw a NullPointerException and left an empty cache, hiding usable interfaces on the next call.

Main Changes

  • Skip unavailable hardware addresses when collecting MACs, while keeping direct lookups as explicit failures.
  • Publish the MAC cache only after the complete collection succeeds, so lookup errors remain retryable.

Normal MAC encoding, IP enumeration, public signatures and PD IP/MAC identity selection remain unchanged.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests.
  • Need tests and can be verified as follows:

Added real-JDK loopback and mixed-interface/deduplication controls, plus a deterministic retry regression. Commons and RPC consumer suites, full reactor compilation, formatting and a redacted real-interface before/after control pass.

Does this PR potentially affect the following parts?

  • Dependencies
  • Modify configurations
  • The public API
  • Other affects
  • Nope

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: this is an internal helper correction with no new configuration or website behavior.

PD REST identity-pairing acceptance remains a separate follow-up.

Summary by CodeRabbit

  • Bug 修复
    • 改进 MAC 地址获取的稳定性:遇到网卡未提供硬件地址、地址重复或查询失败时,不再因空值引发意外异常。
    • 无可用 MAC 地址时返回空结果;地址查询失败后再次调用可重新尝试获取。

Paired org PR: hugegraph#307

Conceptual overview

MAC 批量收集跳过缺失硬件地址,仅完整成功后发布缓存,单地址查询仍明确失败。

Conceptual illustration; not test or release-acceptance evidence.

MAC collection skips missing hardware addresses and publishes cache after success

- Skip interfaces without hardware addresses in MAC lists.
- Publish the MAC cache only after a complete lookup.
- Preserve direct lookup failures and cover real interface boundaries.
- Inject a controlled first enumeration failure.
- Recover with fixed input instead of live re-enumeration.
- Verify the retried result stays cached.
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.00%. Comparing base (62faab7) to head (661e8b3).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3335      +/-   ##
============================================
+ Coverage     52.80%   55.00%   +2.20%     
+ Complexity     6059      436    -5623     
============================================
  Files           762      511     -251     
  Lines         67674    48665   -19009     
  Branches       9189     6984    -2205     
============================================
- Hits          35736    26770    -8966     
+ Misses        28394    19214    -9180     
+ Partials       3544     2681     -863     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- keep required MAC validation outside lookup wrapping
- retain optional null MAC and retry cache behavior
- verify the existing loopback diagnostic regression
@imbajin
imbajin marked this pull request as ready for review October 13, 2026 16:34
@imbajin

imbajin commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

Addressed the outside-diff diagnostic comment. The required missing-hardware-address check now preserves its specific exception message through the existing PD message-only reporting path. Optional MAC aggregation still skips missing addresses and retains the original cache and retry behavior.

The existing loopback regression verifies the diagnosis, and the final Commons suite passes on the tested platform. The native interface tests retain their explicit platform assumptions; adding a production injection hook would expand this focused fix. All three independent reviewers checked the published two-file delta. New-head CI remains open.

@imbajin
imbajin merged commit 92af2f8 into apache:master Oct 13, 2026
4 of 10 checks passed
@imbajin
imbajin deleted the fix/commons-network-mac branch October 13, 2026 20:43
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.

2 participants