Skip to content

[Fix]: Allow empty object lists in high-frequency-telemetry YANG model#23917

Merged
qiluo-msft merged 3 commits intosonic-net:masterfrom
Pterosaur:fix_hft_yang
Sep 9, 2025
Merged

[Fix]: Allow empty object lists in high-frequency-telemetry YANG model#23917
qiluo-msft merged 3 commits intosonic-net:masterfrom
Pterosaur:fix_hft_yang

Conversation

@Pterosaur
Copy link
Contributor

@Pterosaur Pterosaur commented Sep 6, 2025

Why I did it

We must have a dummy HFT table to support dynamically configuring HFT. This Yang model change is to support the dummy table.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  • Remove mandatory constraint for object_names list
  • Add test cases for empty lists and validation scenarios
  • Include high-frequency telemetry model

How to verify it

Check Azp status. This PR includes its test.

Which release branch to backport (provide reason below if selected)

  • 202412

Tested branch (Please provide the tested image version)

master

- Remove mandatory constraint for object_names list
- Add test cases for empty lists and validation scenarios
- Include high-frequency telemetry model

Signed-off-by: Ze Gan <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

'sonic-smart-switch.yang',
'sonic-spanning-tree.yang',
'sonic-srv6.yang',
'sonic-high-frequency-telemetry.yang',
Copy link
Contributor

Choose a reason for hiding this comment

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

let's put by alphabet order

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

]
}
},
"sonic-high-frequency-telemetry:sonic-high-frequency-telemetry": {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a test for empty object list? I don't think current YANG allowed empty list becasue there are still constraints here if group_name is PORT:
leaf-list object_names {
type string;
must "( ../group_name = 'PORT' and current() = /port:sonic-port/port:PORT/port:PORT_LIST/port:name )"
+ " or ( ../group_name = 'BUFFER_POOL' and current() = /bpl:sonic-buffer-pool/bpl:BUFFER_POOL/bpl:BUFFER_POOL_LIST/bpl:name )"
+ " or ( ../group_name = 'INGRESS_PRIORITY_GROUP' and substring-before(current(), '|') = /bpg:sonic-buffer-pg/bpg:BUFFER_PG/bpg:BUFFER_PG_LIST/bpg:port and re-match(substring-after(current(), '|'), '[0-9]+') )"
+ " or ( ../group_name = 'QUEUE' and substring-before(current(), '|') = /bql:sonic-buffer-queue/bql:BUFFER_QUEUE/bql:BUFFER_QUEUE_LIST/bql:port and re-match(substring-after(current(), '|'), '[0-9]+') )";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@wen587 wen587 Sep 8, 2025

Choose a reason for hiding this comment

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

The test in the link still have elements in object_names

                 "profile_name": "partial_objects",
                        "group_name": "PORT",
                        "object_names": [
                            "Ethernet0"
                        ],

I mean empty object_names what ndm will generates. such as:

   "profile_name": "partial_objects",
                        "group_name": "PORT",
                        "object_names": [],

or

 "profile_name": "partial_objects",
                        "group_name": "PORT",
                        "object_names": "",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that our SONiC YANG parser doesn't support the structure like:

"object_names": [],

It will raise an error from Yang parser.

libyang[0]: Invalid JSON data (unexpected value). (path: /sonic-high-frequency-telemetry:sonic-high-frequency-telemetry/HIGH_FREQUENCY_TELEMETRY_GROUP/HIGH_FREQUENCY_TELEMETRY_GROUP_LIST[profile_name='dummy_profile'][group_name='PORT']/object_names)
 Exception >Invalid JSON data (unexpected value). in not empty< in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:278

IMHO, its schema is defined by us, so we can define we only support a json without these fields.

Copy link
Contributor

@wen587 wen587 Sep 8, 2025

Choose a reason for hiding this comment

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

Hi @Pterosaur , right. That's what i am concerned. e.g. if NDM liquid provides "" for object_names and object_counters. Such config will still fail yang validation after we remove must "count(object_names) > 0"; .

liquid is using "" for field value:
https://msazure.visualstudio.com/One/_git/Networking-Metadata?path=/src/data/Network/DeviceConfigTemplates/Sonic_HIGH_FREQUENCY_TELEMETRY_GROUP_Template.liquid&version=GBmaster&_a=contents

To support such field for NDM, should we remove the constraints? such as

                leaf-list object_names {
                   type string;
                   must "( ../group_name = 'PORT' and current() = /port:sonic-port/port:PORT/port:PORT_LIST/port:name )"

I am not sure if "" applies to leaf-list. or we should pick [] instead for NDM

Copy link
Contributor Author

@Pterosaur Pterosaur Sep 8, 2025

Choose a reason for hiding this comment

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

Gotch, I add two negative test cases, please check it. We need to update the NDM code later.


must "count(object_names) > 0";

leaf-list object_counters {
Copy link
Contributor

Choose a reason for hiding this comment

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

please also include such config in sample_config_db.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Ze Gan <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Pterosaur Pterosaur requested a review from wen587 September 7, 2025 12:08
Signed-off-by: Ze Gan <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wen587 wen587 requested a review from ganglyu September 9, 2025 02:16
+ " or ( ../group_name = 'QUEUE' and substring-before(current(), '|') = /bql:sonic-buffer-queue/bql:BUFFER_QUEUE/bql:BUFFER_QUEUE_LIST/bql:port and re-match(substring-after(current(), '|'), '[0-9]+') )";
}

must "count(object_names) > 0";
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use min-elements for what? I removed this condition because I want to support no explicate fields in HFT_GROUP object. such as:

"dummy_table|PORT": {}

@qiluo-msft qiluo-msft merged commit 67d24be into sonic-net:master Sep 9, 2025
20 checks passed
Pterosaur added a commit to Azure/sonic-buildimage-msft that referenced this pull request Sep 10, 2025
#1593)

Origin PR: sonic-net/sonic-buildimage#23917

#### Why I did it
We must have a dummy HFT table to support dynamically configuring HFT.
This Yang model change is to support the dummy table.

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it
- Remove mandatory constraint for object_names list
- Add test cases for empty lists and validation scenarios
- Include high-frequency telemetry model
- 
#### How to verify it

Check Azp status. This PR includes its test.

#### Which release branch to backport (provide reason below if selected)

- [x] 202412

#### Tested branch (Please provide the tested image version)

master
r12f pushed a commit to Azure/sonic-buildimage-msft that referenced this pull request Oct 26, 2025
#1593)

Origin PR: sonic-net/sonic-buildimage#23917

#### Why I did it
We must have a dummy HFT table to support dynamically configuring HFT.
This Yang model change is to support the dummy table.

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it
- Remove mandatory constraint for object_names list
- Add test cases for empty lists and validation scenarios
- Include high-frequency telemetry model
- 
#### How to verify it

Check Azp status. This PR includes its test.

#### Which release branch to backport (provide reason below if selected)

- [x] 202412

#### Tested branch (Please provide the tested image version)

master
FengPan-Frank pushed a commit to FengPan-Frank/sonic-buildimage that referenced this pull request Dec 4, 2025
sonic-net#23917)

Why I did it
We must have a dummy HFT table to support dynamically configuring HFT. This Yang model change is to support the dummy table.

How I did it
Remove mandatory constraint for object_names list
Add test cases for empty lists and validation scenarios
Include high-frequency telemetry model
How to verify it
Check Azp status. This PR includes its test.

Signed-off-by: Feng Pan <[email protected]>
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.

5 participants