Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
'sonic-smart-switch.yang',
'sonic-spanning-tree.yang',
'sonic-srv6.yang',
'sonic-high-frequency-telemetry.yang',
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

]

class my_build_py(build_py):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"HIGH_FREQUENCY_TELEMETRY_VALID_CASE": {
"desc": "Valid high frequency telemetry configuration."
},
"HIGH_FREQUENCY_TELEMETRY_INVALID_PORT": {
"desc": "Invalid port.",
"eStrKey": "Must"
},
"HIGH_FREQUENCY_TELEMETRY_INVALID_STATS": {
"desc": "Invalid stats.",
"eStrKey": "Must"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
"name": "high_frequency_counters",
"stream_state": "enabled",
"poll_interval": 100
},
{
"name": "partial_objects",
"stream_state": "disabled",
"poll_interval": 100000
},
{
"name": "dummy_profile",
"stream_state": "disabled",
"poll_interval": 100000
}
]
},
Expand Down Expand Up @@ -120,6 +130,110 @@
"CURR_OCCUPANCY_BYTES",
"XOFF_ROOM_WATERMARK_BYTES"
]
},
{
"profile_name": "partial_objects",
"group_name": "PORT",
"object_names": [
"Ethernet0"
],
"object_counters": [
"IF_IN_OCTETS",
"OUT_CURR_OCCUPANCY_BYTES"
]
},
{
"profile_name": "dummy_profile",
"group_name": "PORT"
}
]
}
}
},
"HIGH_FREQUENCY_TELEMETRY_INVALID_PORT": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"lanes": "0",
"speed": 25000
},
{
"name": "Ethernet4",
"lanes": "4",
"speed": 25000
}
]
}
},
"sonic-high-frequency-telemetry:sonic-high-frequency-telemetry": {
"sonic-high-frequency-telemetry:HIGH_FREQUENCY_TELEMETRY_PROFILE": {
"HIGH_FREQUENCY_TELEMETRY_PROFILE_LIST": [
{
"name": "invalid_port",
"stream_state": "enabled",
"poll_interval": 100
}
]
},
"sonic-high-frequency-telemetry:HIGH_FREQUENCY_TELEMETRY_GROUP": {
"HIGH_FREQUENCY_TELEMETRY_GROUP_LIST": [
{
"profile_name": "invalid_port",
"group_name": "PORT",
"object_names": [
"Ethernet1"
],
"object_counters": [
"IF_IN_OCTETS",
"OUT_CURR_OCCUPANCY_BYTES"
]
}
]
}
}
},
"HIGH_FREQUENCY_TELEMETRY_INVALID_STATS": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"lanes": "0",
"speed": 25000
},
{
"name": "Ethernet4",
"lanes": "4",
"speed": 25000
}
]
}
},
"sonic-high-frequency-telemetry:sonic-high-frequency-telemetry": {
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

"sonic-high-frequency-telemetry:HIGH_FREQUENCY_TELEMETRY_PROFILE": {
"HIGH_FREQUENCY_TELEMETRY_PROFILE_LIST": [
{
"name": "invalid_stats",
"stream_state": "enabled",
"poll_interval": 100
}
]
},
"sonic-high-frequency-telemetry:HIGH_FREQUENCY_TELEMETRY_GROUP": {
"HIGH_FREQUENCY_TELEMETRY_GROUP_LIST": [
{
"profile_name": "invalid_stats",
"group_name": "PORT",
"object_names": [
"Ethernet0"
],
"object_counters": [
"IF_IN_OCTETS",
"OUT_CURR_OCCUPANCY_BYTES",
"INVALID_STAT"
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ module sonic-high-frequency-telemetry {
+ " 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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": {}


leaf-list object_counters {
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

type string;
must "( ../group_name = 'PORT' and re-match(current(), 'IF_IN_OCTETS|IF_IN_UCAST_PKTS|IF_IN_DISCARDS|IF_IN_ERRORS|IN_CURR_OCCUPANCY_BYTES|IF_OUT_OCTETS|IF_OUT_DISCARDS|IF_OUT_ERRORS|IF_OUT_UCAST_PKTS|OUT_CURR_OCCUPANCY_BYTES|TRIM_PACKETS') )"
Expand Down
Loading