Moved create-only to YANG - #4733
Open
bradleymoon-nexthop wants to merge 4 commits into
Open
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
bradleymoon-nexthop
force-pushed
the
moved-create-only-to-yang
branch
from
July 30, 2026 17:43
3080294 to
6a2c2b5
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
bradleymoon-nexthop
force-pushed
the
moved-create-only-to-yang
branch
from
July 30, 2026 17:46
6a2c2b5 to
501c037
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
bradleymoon-nexthop
force-pushed
the
moved-create-only-to-yang
branch
from
July 30, 2026 17:51
32dac5a to
5701059
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
bradleymoon-nexthop
marked this pull request as ready for review
July 30, 2026 17:52
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
/azp run |
Signed-off-by: bradleymoon-nexthop <bradleymoon@nexthop.ai> Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
Keep YANG create-only discovery with the fallback floor, and drop the unused private-only GCU_FIELD_OP_CONF_FILE constant from the public port. Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
Signed-off-by: Bradley Moon <bradleymoon@nexthop.ai>
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
bradleymoon-nexthop
force-pushed
the
moved-create-only-to-yang
branch
from
July 30, 2026 17:57
ec5a12d to
99c7b88
Compare
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
10 tasks
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.
PR Description: Move create-only Fields to YANG Models
Why I did it
Currently, the
CreateOnlyFilterinsidegeneric_config_updater/patch_sorter.pyutilizes a static, hardcoded list of lists (self.patterns) to identify which table fields are immutable (create-only). This makes the system rigid, difficult to maintain, and divorces schema properties from the validation layer as new tables or attributes are added to SONiC.To solve this, this PR refactors
CreateOnlyFilterto dynamically discover create-only annotations directly from the compiled YANG models using the customext:create-onlyYANG extension introduced in sonic-net/sonic-mgmt-common/pull/234How I did it
libyanginsidesonic-utilities(conforming to.semgrep/no-direct-libyang.ymlisolation guidelines). Instead, delegated all recursive schema-walking logic to thesonic_yangmodule through the newsy.get_create_only_fields()accessor._CREATE_ONLY_FIELDS_FALLBACKto act as a fallback floor._CREATE_ONLY_FIELDS_FALLBACK. This ensures that if the system has an incomplete/partially annotated model set (e.g., during separate backports or transition windows on release branches), the baseline create-only protection remains active while logging a warning for any missing annotations.AttributeErrorcatch block in_discover_create_only_fieldsto safely handle environments whereconfig_wrapperisNone(such as bare CLI contexts or unit test runs), defaulting cleanly to the fallback list.PathAddressinginstance across the three create-only filtering classes. This ensures that the schema subtree is walked once per process rather than multiple times per patch operation, avoiding FFI/libyang traversal overhead.How to verify it
spec=[]mock exercises the fallback-only path safely whenget_create_only_fields()is unavailable on-box during the migration window.sonic_yangis initialized but the model package hasn't been upgraded.