Skip to content

Conversation

@richm
Copy link
Contributor

@richm richm commented Jun 20, 2025

In some cases, the interface given in MAC_ADDR_MATCH_INTERFACE can be an
alias or altname. The test cannot use the altname, it must use the "real"
interface name.

For example, on some systems, if MAC_ADDR_MATCH_INTERFACE=enX1, the test
will fail because it is an altname for ens4:

+ ip addr show enX1
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:12:34:57 brd ff:ff:ff:ff:ff:ff
    altname enp0s4
    altname enx525400123457
    altname enX1

The test will now parse the output of ip addr show $name to get the real interface name.

Also, improve the fallback method to look for common secondary interface names
such as eth1 and ens4 in case MAC_ADDR_MATCH_INTERFACE is not one of these.

Signed-off-by: Rich Megginson [email protected]

Summary by Sourcery

Improve detection of secondary network interfaces in MAC address match tests to handle alias names and provide common fallbacks.

Tests:

  • Introduce a merged interfaces_to_check list combining the default interface and common names for lookup
  • Update test loop to iterate over all candidate interfaces from interfaces_to_check
  • Extract the real interface name from ip addr show output and default to UNKNOWN_DEVICE if none is found

@richm richm requested a review from liangwen12year as a code owner June 20, 2025 22:59
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 20, 2025

Reviewer's Guide

Test playbook now dynamically determines the actual network interface name (not just aliases) by parsing “ip addr show” output and expands its fallback search to include common secondary interfaces (eth1, ens4).

File-Level Changes

Change Details Files
Expanded interface candidate list
  • Added interfaces_to_check var combining default_interface with eth1 and ens4
  • Replaced hardcoded loop arguments with interfaces_to_check iteration
tests/playbooks/tests_mac_address_match.yml
Resolved interface alias mapping and fallback
  • Within loop, parsed real interface name using awk on ip addr show output
  • Introduced real_iface defaulting to UNKNOWN_DEVICE when none matched
  • Updated echo to print real_iface instead of the raw alias
tests/playbooks/tests_mac_address_match.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @richm - I've reviewed your changes - here's some feedback:

  • Avoid calling ip addr show twice per interface by capturing its output once for parsing, which will simplify the logic and reduce overhead.
  • Consider using ip -o link show or ip -j link for easier and more robust extraction of the real interface name instead of relying on awk over indented lines.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Avoid calling `ip addr show` twice per interface by capturing its output once for parsing, which will simplify the logic and reduce overhead.
- Consider using `ip -o link show` or `ip -j link` for easier and more robust extraction of the real interface name instead of relying on `awk` over indented lines.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.25%. Comparing base (1b57520) to head (8c45acf).
Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #792      +/-   ##
==========================================
+ Coverage   43.11%   43.25%   +0.13%     
==========================================
  Files          12       12              
  Lines        3124     3121       -3     
==========================================
+ Hits         1347     1350       +3     
+ Misses       1777     1771       -6     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@richm
Copy link
Contributor Author

richm commented Jun 20, 2025

Ignore ansible-lint failures for now:

Error: Task name 'Configure the ethernet device eth1 with dhcp4 configured' is not unique. It was first used on line 156.

They added a new check - task names must be unique in a given file - this is not urgent to fix.

@richm
Copy link
Contributor Author

richm commented Jun 20, 2025

[citest]

@richm
Copy link
Contributor Author

richm commented Jun 20, 2025

The centos-10 failures are known - 802.1x tests are not working

The fedora 42 failures are known - ansible 2.19 issues

In some cases, the interface given in MAC_ADDR_MATCH_INTERFACE can be an
alias or altname.  The test cannot use the altname, it must use the "real"
interface name.

For example, on some systems, if `MAC_ADDR_MATCH_INTERFACE=enX1`, the test
will fail because it is an altname for `ens4`:

```
+ ip addr show enX1
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:12:34:57 brd ff:ff:ff:ff:ff:ff
    altname enp0s4
    altname enx525400123457
    altname enX1
```

The test will now parse the output of `ip addr show $name` to get the real interface name.

Also, improve the fallback method to look for common secondary interface names
such as eth1 and ens4 in case MAC_ADDR_MATCH_INTERFACE is not one of these.

Signed-off-by: Rich Megginson <[email protected]>
@richm richm force-pushed the tags-extra-interface branch from 478502d to 8c45acf Compare June 20, 2025 23:45
@richm
Copy link
Contributor Author

richm commented Jun 21, 2025

[citest]

@richm richm merged commit 14f9044 into linux-system-roles:main Jun 25, 2025
32 of 38 checks passed
@richm richm deleted the tags-extra-interface branch June 25, 2025 13:38
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