-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Stop reporting changes for configured alias (#51068) #63113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Made network.managed stop reporting changes when there are none. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -621,30 +621,16 @@ def managed(name, enabled=True, **kwargs): | |
|
|
||
| # Bring up/shutdown interface | ||
| try: | ||
| # Get Interface current status | ||
| # Get Interfaces information | ||
| interfaces = salt.utils.network.interfaces() | ||
| interface_status = False | ||
| if name in interfaces: | ||
| interface_status = interfaces[name].get("up") | ||
|
|
||
| # Check the interface current status | ||
| if name.split(":")[0] in interfaces: | ||
| interface_status = interfaces[name.split(":")[0]].get("up") | ||
| else: | ||
| for iface in interfaces: | ||
| if "secondary" in interfaces[iface]: | ||
| for second in interfaces[iface]["secondary"]: | ||
| if second.get("label", "") == name: | ||
| interface_status = True | ||
| if iface == "lo": | ||
| if "inet" in interfaces[iface]: | ||
| inet_data = interfaces[iface]["inet"] | ||
| if len(inet_data) > 1: | ||
| for data in inet_data: | ||
| if data.get("label", "") == name: | ||
| interface_status = True | ||
| if "inet6" in interfaces[iface]: | ||
| inet6_data = interfaces[iface]["inet6"] | ||
| if len(inet6_data) > 1: | ||
| for data in inet6_data: | ||
| if data.get("label", "") == name: | ||
| interface_status = True | ||
| interface_status = False | ||
|
|
||
| # Handle interface as desired | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unconditionally splitting the interface string on a colon breaks support for complex interface naming conventions (like VLAN tags and sub-interfaces) and incorrectly conflates a parent interface's status with its un-validated alias configurations. By completely deleting that section and substituting the raw split(":"), the code now blindly conflates the parent interface's operational status with the status of the alias itself. If the parent interface (eth0) is up, Salt will now automatically assume the alias (eth0:1) is up and up-to-date—even if the virtual IP allocation for that alias completely failed to bind on the host. That deleted code was the only mechanism verifying that the specific label (second.get("label") == name) was genuinely active in the system's runtime network state. Instead of an unconditional split(":"), Salt should use a targeted regex match to separate a true legacy sub-interface/alias label from a standard interface name. Then, it needs to query the actual nested secondary data structure to confirm that the specific virtual label is bound and active. # Bring up/shutdown interface
try:
# Get Interfaces information
interfaces = salt.utils.network.interfaces()
interface_status = False
# 1. Check if the exact interface name exists directly
if name in interfaces:
interface_status = interfaces[name].get("up", False)
# 2. Safely check for legacy alias structures (e.g., eth0:1, bond0:vlan1)
else:
import re
# Match standard interface naming followed by a numeric or label alias
match = re.match(r"^([a-zA-Z0-9.\-_]+):([a-zA-Z0-9_\-]+)$", name)
if match:
parent_iface = match.group(1)
if parent_iface in interfaces:
# Look for the explicit alias label in the secondary IP data structures
for family in ("secondary", "inet", "inet6"):
if family in interfaces[parent_iface]:
for data in interfaces[parent_iface][family]:
if data.get("label") == name:
interface_status = True
break
if interface_status:
break
interface_status = interface_status or False
# Handle interface as desired
if enabled: |
||
| if enabled: | ||
| if "noifupdown" not in kwargs: | ||
| if interface_status: | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.