Skip to content

sonic/config_generator: use "up" for BGP_NEIGHBOR_AF admin_status#2261

Open
berendt wants to merge 1 commit intomainfrom
fix-sonic-2
Open

sonic/config_generator: use "up" for BGP_NEIGHBOR_AF admin_status#2261
berendt wants to merge 1 commit intomainfrom
fix-sonic-2

Conversation

@berendt
Copy link
Copy Markdown
Member

@berendt berendt commented May 5, 2026

_add_bgp_configurations wrote "admin_status": "true" for every BGP_NEIGHBOR_AF row it generated: ipv4_unicast, ipv6_unicast and l2vpn_evpn keys for both interfaces and port channels, plus the VLAN peer ipv4_unicast row. The schema enforced by the new Pydantic validator (BgpNeighborAfListRow.admin_status) is Literal["up", "down"], so validation rejected every generated row with "Input should be 'up' or 'down'".

Replace the literal "true" with "up" at all seven call sites. Same fix pattern as #2260, which aligned other generated values with the schema.

AI-assisted: Claude Code

Copy link
Copy Markdown

@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 - I've left some high level feedback:

  • Since admin_status is now constrained to "up"/"down", consider centralizing these values in a small helper or constant to avoid future drift if the schema changes again.
  • It may be worth scanning for any remaining hard-coded boolean-like strings in related BGP config generation paths to ensure they consistently match the new Pydantic Literal["up", "down"] expectations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `admin_status` is now constrained to "up"/"down", consider centralizing these values in a small helper or constant to avoid future drift if the schema changes again.
- It may be worth scanning for any remaining hard-coded boolean-like strings in related BGP config generation paths to ensure they consistently match the new Pydantic `Literal["up", "down"]` expectations.

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.

_add_bgp_configurations wrote "admin_status": "true" for every
BGP_NEIGHBOR_AF row it generated: ipv4_unicast, ipv6_unicast and
l2vpn_evpn keys for both interfaces and port channels, plus the
VLAN peer ipv4_unicast row. The schema enforced by the new Pydantic
validator (BgpNeighborAfListRow.admin_status) is Literal["up", "down"],
so validation rejected every generated row with "Input should be 'up'
or 'down'". Same fix pattern as #2260.

Replace the literal "true" with "up" at all seven BGP call sites,
and centralise the schema-allowed values as ADMIN_STATUS_UP /
ADMIN_STATUS_DOWN constants in sonic/constants.py so future drift
fails at import time rather than at validation. Switch the remaining
admin_status producers (MGMT_INTERFACE, INTERFACE incl. breakout
ports, VLAN, VLAN_INTERFACE, LOOPBACK, and the PORTCHANNEL row built
in sonic/interface.py) to the same constants for consistency.

AI-assisted: Claude Code

Signed-off-by: Christian Berendt <berendt@osism.tech>
@berendt
Copy link
Copy Markdown
Member Author

berendt commented May 5, 2026

Depends on #2258

@berendt berendt requested a review from osfrickler May 5, 2026 06:38
Copy link
Copy Markdown
Member

@osfrickler osfrickler left a comment

Choose a reason for hiding this comment

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

I'm not convinced that this is a good idea, operationally it is better to stick to the values that a config save on the running switch generates, so that it is easy to spot actual config changes. If the scheme we use for verification doesn't match this, then IMO the scheme is wrong, not the generated config.

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