Skip to content

fix: ensure unconfigured links are not used as default gateways - #574

Open
nehjoshi wants to merge 1 commit into
canonical:3.8from
nehjoshi:backport-lp2162993-3.8
Open

nehjoshi wants to merge 1 commit into
canonical:3.8from
nehjoshi:backport-lp2162993-3.8

Conversation

@nehjoshi

Copy link
Copy Markdown
Contributor

Note: This PR is being cherry-picked from commit 6ad3ba6.

LP#2162993 states that when an interface is set to "Unconfigured" (i.e. is not configured for an IP address), it still continues to act as the default gateway for a machine. Since the interface is unconfigured, this prevents the machine from receiving outbound network connectivity. Ideally, if there is another active and configured interface on a subnet with a valid gateway, MAAS should point the default_gateways reference to that interface.

  • This change can be made by excluding links with no IPs or are unconfigured when getting the default_gateways

Resolves LP:2162993

(Copied over from the original PR#555)

…nical#555)

[LP#2162993](https://bugs.launchpad.net/maas/+bug/2162993) states that
when an interface is set to "Unconfigured" (i.e. is not configured for
an IP address), it still continues to act as the default gateway for a
machine. Since the interface is unconfigured, this prevents the machine
from receiving outbound network connectivity. Ideally, if there is
another active and configured interface on a subnet with a valid
gateway, MAAS should point the default_gateways reference to that
interface.
- This change can be made by excluding links with no IPs or are
unconfigured when getting the default_gateways

Resolves [LP:2162993](https://bugs.launchpad.net/maas/+bug/2162993)
@nehjoshi nehjoshi added the bug label Aug 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[maas-code-reviewer review]

LLM-generated review from https://github.com/canonical/maas-code-reviewer.
Intended to assist a human reviewer, not replace one — suggestions may be
incorrect, please verify before acting.

The proposed changes correctly address LP#2162993 by preventing unconfigured (LINK_UP) interfaces from being selected or retained as default gateways. The implementation logic matches the issue description perfectly, correctly checking for alloc_type = 1 (STICKY) with a NULL IP in the raw SQL, and utilizing get_interface_link_type() to filter out explicit gateway links. The provided test accurately simulates the condition and guards against regressions.

staticip.alloc_type != 6 AND /* Ignore DISCOVERED */
/* Ignore LINK_UP / Unconfigured (STICKY with no IP), but keep
AUTO links that have no IP assigned yet (pre-deployment) */
NOT (staticip.alloc_type = 1 AND staticip.ip IS NULL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider replacing the hardcoded enum value 1 with a string formatting parameter using IPADDRESS_TYPE.STICKY (or its .value). While 5 and 6 are already hardcoded here, reducing the reliance on magic numbers in raw SQL improves maintainability and makes the query's intent even clearer without reading the comments.

@nehjoshi nehjoshi added the 3.8 label Sep 1, 2026
@skatsaounis

Copy link
Copy Markdown
Contributor

@AloizioMacedo is this something to merge or apply the "blocked" label? Could you please check?

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.

2 participants