Skip to content

[master] Avoid use of deprecated net-tools and add support for ip neighbour - #64351

Merged
Ch3LL merged 10 commits into
saltstack:masterfrom
dmurphy18:net-tools-upd-57541
Jun 9, 2023
Merged

Ch3LL merged 10 commits into
saltstack:masterfrom
dmurphy18:net-tools-upd-57541

Conversation

@dmurphy18

Copy link
Copy Markdown
Contributor

What does this PR do?

Avoids use of deprecated net-tools and add support for ip neighbour with IPv4 ip_neighs and IPv6 ip_neighs6, similar to ip_addrs and ip_addrs6

What issues does this PR fix or reference?

Fixes: #57541

New Behavior

Added support for ip neighbour with IPv4 ip_neighs and IPv6 ip_neighs6, and ensured that deprecated net-tools are no longer used when possible.

Also ported unittests to pytests and added tests for ip_neighs and ip_neighs6.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@dmurphy18
dmurphy18 requested a review from a team as a code owner May 24, 2023 21:48
@dmurphy18
dmurphy18 requested review from dwoz and removed request for a team May 24, 2023 21:48
@salt-project-bot-prod-environment salt-project-bot-prod-environment Bot changed the title Avoid use of deprecated net-tools and add support for ip neighbour [master] Avoid use of deprecated net-tools and add support for ip neighbour May 24, 2023
@dmurphy18 dmurphy18 added this to the Chlorine v3007.0 milestone May 24, 2023
@dmurphy18
dmurphy18 temporarily deployed to ci May 24, 2023 22:31 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci May 24, 2023 22:32 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci May 24, 2023 22:32 — with GitHub Actions Inactive
Comment thread salt/modules/network.py Resolved
Comment thread salt/modules/vagrant.py Resolved
@dmurphy18
dmurphy18 requested a review from s0undt3ch June 6, 2023 16:13
s0undt3ch
s0undt3ch previously approved these changes Jun 6, 2023
twangboy
twangboy previously approved these changes Jun 6, 2023
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 16:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 16:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 16:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 16:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 17:06 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 17:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 6, 2023 18:22 — with GitHub Actions Inactive
Comment thread salt/modules/network.py Resolved
Comment thread salt/modules/network.py Resolved
@dmurphy18
dmurphy18 dismissed stale reviews from twangboy and s0undt3ch via 6b6cc5d June 6, 2023 19:01
@dmurphy18
dmurphy18 requested a review from Ch3LL June 6, 2023 19:02
Ch3LL
Ch3LL previously approved these changes Jun 6, 2023
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 00:05 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 00:05 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 00:23 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 00:29 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 01:32 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 8, 2023 01:34 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 14:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 14:48 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 14:49 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 14:49 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 15:09 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 15:13 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@dmurphy18
dmurphy18 temporarily deployed to ci June 9, 2023 16:08 — with GitHub Actions Inactive
@Ch3LL
Ch3LL merged commit 7916ffb into saltstack:master Jun 9, 2023
@dmurphy18
dmurphy18 deleted the net-tools-upd-57541 branch March 13, 2024 17:59
dwoz pushed a commit that referenced this pull request Jul 3, 2026
) (#69621)

* network.arp: fall back to ip neigh when net-tools is absent

network.arp() was guarded by @salt.utils.decorators.path.which("arp"),
which raises CommandNotFoundError when the net-tools arp command is not
installed. net-tools is deprecated (since 2011) and absent by default on
modern distributions, so network.arp broke on those systems with no
fallback.

PR #64351 migrated network.netstat/network.routes to iproute2 with a
which()-based fallback (ss / ip route) and added network.ip_neighs, but
left the public network.arp() on net-tools. This completes that work:
on Linux, when the arp command is unavailable, arp() now dispatches to
ip_neighs() (ip neigh show), which returns the same {mac: ip} mapping.
Non-Linux kernels (SunOS/OpenBSD/AIX) keep using their native arp
command, mirroring how network.netstat() is structured.

Refs #57541, #64351.

Validated on AlmaLinux 8, 9 and 10: net-tools is absent by default, and
network.arp returns the neighbour table via the ip neigh fallback.

* Patch loader dunders in legacy test_arp for the ip neigh fallback

network.arp now checks __grains__["kernel"] and __utils__["path.which"]
before choosing between arp -an and ip neigh. The legacy unittest still
patched the module-level salt.utils.path.which (only used by the old
decorator) and left the grains dict empty, so arp() raised
KeyError: 'kernel'. Patch the dunders the code actually reads, pinning
the test to the net-tools branch it was written for.

* Migrate legacy unit/modules/test_network.py into the pytest suite

Every test in tests/unit/modules/test_network.py already has a
same-named twin in tests/pytests/unit/modules/test_network.py with
identical mocks, inputs, and expected values, under equivalent loader
wiring. Keeping both copies means fixes only land in one, which is
exactly how test_arp broke on this branch: arp() gained the ip neigh
fallback and only the pytest copy was updated.

The one gap was test___virtual__is_windows_false, whose pytest twin had
been weakened from assertEqual(result, True) to a bare truthiness
assert that would also pass for the (False, reason) failure tuple.
Restore the strict check and remove the legacy file, leaving a single
canonical home for these tests.

This branch was previously deployed

1 inactive deployment
ci — 5863861c Deployed Jun 9, 2023 by dmurphy18
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.

[Tech-Debt] Avoid use of deprecated net-tools

4 participants