Skip to content

[yang] Add sonic-monitor-link-group model#27004

Open
srodd-nexthop wants to merge 6 commits into
sonic-net:masterfrom
nexthop-ai:srodd.monitor-link-yang
Open

[yang] Add sonic-monitor-link-group model#27004
srodd-nexthop wants to merge 6 commits into
sonic-net:masterfrom
nexthop-ai:srodd.monitor-link-yang

Conversation

@srodd-nexthop
Copy link
Copy Markdown

@srodd-nexthop srodd-nexthop commented Apr 27, 2026

What I did

Add a YANG model for the Monitor Link Group feature, defining the CONFIG_DB schema for the MONITOR_LINK_GROUP table.

Files changed:

File Change
yang-models/sonic-monitor-link-group.yang New YANG model
setup.py Register new model
tests/yang_model_tests/tests/monitor_link_group.json Validation test
tests/yang_model_tests/tests_config/monitor_link_group.json Test config
tests/files/sample_config_db.json Sample config entry

Why I did it

The Monitor Link Group feature requires a YANG model for CONFIG_DB schema validation on config load / config reload and for GCU (generic config updater) compatibility.

Design

The model defines a single list MONITOR_LINK_GROUP_LIST keyed by group_name, with:

  • uplinks / downlinks: leaf-list with union of leafrefs to sonic-port:PORT_LIST and sonic-portchannel:PORTCHANNEL_LIST, plus an empty-string option. Validates that configured interfaces exist.
  • min-uplinks: type string, default "1" — minimum operational uplinks for the group to be UP
  • link-up-delay: type string, default "0" — seconds to wait after threshold is met before bringing downlinks up
  • description: optional string

min-uplinks and link-up-delay use type string (not uint32) to match how SONiC CONFIG_DB stores all numeric values as strings, which avoids a GCU post-apply verification mismatch between integer patch values and string DB values.

How I verified it

  • YANG model validation tests pass
  • Sample config validates against the model

Companion PRs

  • sonic-swss-common: STATE_DB table name macros
  • sonic-swss: MonitorLinkGroupMgr implementation
  • sonic-utilities: show monitor-link CLI
  • SONiC/SONiC: HLD

HLD: sonic-net/SONiC#2308
swss: sonic-net/sonic-swss#4523
Show: sonic-net/sonic-utilities#4497
swss-common: sonic-net/sonic-swss-common#1181

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@srodd-nexthop srodd-nexthop force-pushed the srodd.monitor-link-yang branch from a3e5514 to d5a8e79 Compare April 28, 2026 08:01
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@srodd-nexthop srodd-nexthop marked this pull request as ready for review May 12, 2026 12:18
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Adds a YANG model for the Monitor Link Group feature, defining the
CONFIG_DB schema for the MONITOR_LINK_GROUP table.

The model defines a single list (MONITOR_LINK_GROUP_LIST) keyed by
group name, with leaf-list uplinks/downlinks of interface names and
the startup-delay / min-uplinks threshold parameters.

Tests:
- tests/yang_model_tests/tests/monitor_link_group.json and
  tests_config/monitor_link_group.json validate the model against a
  representative config.
- A sample config is added to tests/files/sample_config_db.json.

Companion PRs and motivation: see the Monitor Link Group HLD in
sonic-net/SONiC.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
…nk-up-delay

Remove TAM/TAM_COLLECTOR/TAM_FLOW_GROUP/TAM_SESSION entries from
sample_config_db.json that leaked in from an unrelated feature.

Rename startup-delay to link-up-delay throughout all monitor-link-group
test fixtures to match the YANG leaf name.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
An interface cannot be configured as both uplink and downlink in the
same monitor link group. Enforce this at config load time with a YANG
must constraint on MONITOR_LINK_GROUP_LIST.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
R-4 (terminology rename), R-7 (drop empty-string defaults), R-10 (extend
must constraint).

YANG model now uses monitored-links / managed-links / min-monitored-links
with adjusted must constraints:

  must "not(monitored-links[. = current()/managed-links])"  (disjointness)
  must "min-monitored-links <= count(monitored-links[. != ''])"  (R-10 bound)

The empty-string `default ""` on the two leaf-lists is dropped (R-7, D-D).
Revision bumped to 2026-05-12.

Test files updated to exercise the renamed leaf-lists.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
@srodd-nexthop srodd-nexthop force-pushed the srodd.monitor-link-yang branch from 2efc778 to 6132db1 Compare May 14, 2026 04:41
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

The leaf-list union for monitored-links/managed-links had three branches:
two leafrefs plus a fallback string with pattern "" (empty regex). The
empty pattern matches only the empty string, so every Ethernet/PortChannel
name fell through all three branches under strict-mode unit tests where
PORT/PORTCHANNEL tables are not in scope. Drop the empty-pattern branch
so leafref-only unions enforce that interface names exist in PORT or
PORTCHANNEL, and add the matching PORT_LIST/PORTCHANNEL_LIST entries to
each test fixture in tests_config/monitor_link_group.json.

link-up-delay and min-monitored-links were declared with no pattern, so
the *_PATTERN/*_NEGATIVE invalid tests for them could never trigger a
pattern failure. Add a numeric [0-9]+ pattern to both.

group_name had a custom error-message that replaced the libyang default
"Unsatisfied pattern" text. The YANG test framework hard-codes that
substring in its Pattern matcher, so the GROUP_NAME_PATTERN test failed
with the wrong text. Drop the custom message.

Flip eStrKey from Pattern to LeafRef on the six interface-list invalid
tests so the new leafref-only union produces matching expected errors.

Signed-off-by: Satishkumar Rodd <srodd@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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