Move create-only to yang - #28737
Open
bradleymoon-nexthop wants to merge 3 commits into
Open
Move create-only to yang#28737bradleymoon-nexthop wants to merge 3 commits into
bradleymoon-nexthop wants to merge 3 commits into
Conversation
Signed-off-by: bradleymoon-nexthop <bradleymoon@nexthop.ai>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Keep the upstream module description and add sonic-extension for ext:create-only on lanes. Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
CI cannot fetch 9d57664 from sonic-net/sonic-mgmt-common. Keep buildimage independent until sonic-mgmt-common#234 merges. Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
bradleymoon-nexthop
marked this pull request as ready for review
July 30, 2026 20:41
bradleymoon-nexthop
requested review from
dgsudharsan,
praveen-li,
qiluo-msft and
venkatmahalingam
as code owners
July 30, 2026 20:41
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
Currently, the Generic Config Updater (GCU) in
sonic-utilities(specifically insidepatch_sorter.py) relies on a static, hardcoded list ofcreate-onlyfields to prevent users from modifying immutable attributes. This approach is rigid, hard to scale, and divorces schema properties from the actual YANG validation layer.To resolve this, we are transitioning to a declarative, schema-driven approach by moving the create-only configuration metadata out of hardcoded scripts and directly into YANG models as declarative annotations (
ext:create-only, see sonic-net/sonic-mgmt-common#234 and sonic-net/sonic-utilities#4733).How I did it
sonic-extension.yang.j2(and sample test models) to declare theext:create-onlyextension.ext:create-onlydecorator:sonic-port.yang(leaflanes)sonic-loopback-interface.yang(leafvrf_name)sonic-scheduler.yang(leaves:type,weight,cir,pir,cbs,pbs,meter_type)sonic-mirror-session.yang(containerMIRROR_SESSION)sonic-bgp-neighbor.yang(leaves onBGP_NEIGHBOR_LISTuses sites)sonic-bgp-monitor.yang(leaves onBGP_MONITORS_LISTuses sites)sonic-bgp-peerrange.yang(containerBGP_PEER_RANGE)sonic-bgp-sentinel.yang(containerBGP_SENTINELS)refineat individualusessites rather than on the shared groupings insonic-bgp-common.yang. This ensures that unrelated tables likeBGP_PEER_GROUP,BGP_INTERNAL_NEIGHBOR, andBGP_VOQ_CHASSIS_NEIGHBORdo not inherit these constraints.get_create_only_fields()method tosonic_yang_ext.pyinsonic-yang-mgmtto dynamically walk the compiled YANG models using the libyang schema tree and discover the annotated elements, replacing the static GCU list.src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py:test_get_create_only_fields_matches_expected_set: Asserts thatget_create_only_fields()on the installed models produces exactly the 26 expected patterns matching the original hardcoded fallback list.test_get_create_only_fields_direct_and_refine: Tests discovery mechanism on fixture models covering both direct leaf annotations andrefine-carried annotations.How to verify it
sonic-yang-mgmttest suite during image build or manually:Which release branch to backport (provide reason below if selected)