Skip to content

[yang] Change swss-event, dhcp-relay-event leafref to string#13326

Merged
qiluo-msft merged 4 commits intosonic-net:masterfrom
zbud-msft:reviseyangmodels
May 4, 2023
Merged

[yang] Change swss-event, dhcp-relay-event leafref to string#13326
qiluo-msft merged 4 commits intosonic-net:masterfrom
zbud-msft:reviseyangmodels

Conversation

@zbud-msft
Copy link
Copy Markdown
Contributor

Why I did it

Do not require leafref as part of yang. Only need string to compare whether string received from event matches what is possible for ifname.

How I did it

How to verify it

Run UT

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

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@zbud-msft zbud-msft added Request for 202211 Branch YANG YANG model related changes labels Jan 11, 2023
@zbud-msft zbud-msft requested a review from ganglyu January 11, 2023 01:05
@zbud-msft zbud-msft marked this pull request as ready for review January 11, 2023 01:05
@zbud-msft zbud-msft requested a review from qiluo-msft as a code owner January 11, 2023 01:05
path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name";
}
type string {
pattern 'Ethernet[0-9]{1,2}';
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 24, 2023

Choose a reason for hiding this comment

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

Ethernet

There is use case like Ethernet124 not covered by this pattern.
PortChannel may be a valid use case if there is PortChannel in Vlan. #Closed

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.

Changed pattern.

I checked with Kelly, for this event it should just be Ethernets, PortChannel is used for sending out packets

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you explain more about the disadvantage of using leafref PORT_LIST? The pattern string is not future proof.

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.

I initially had it as a leafref, but we can't use it for our use case, because we are getting events as a json format such as

              "stdout_lines": [
                   "2023-01-10 01:02:45,053 [INFO] CURRENT JSON_DATA: {"sonic-events-swss:sonic-events-swss":{", 
                   "  "sonic-events-swss:if-state": {", 
                   "    "ifname": "Ethernet8",", 
                   "    "status": "down",", 
                   "    "timestamp": "2023-01-10T01:02:30.349203Z"", 
                   "  }", 
                   "}}", 

In order to use a leafref I would need a reference such as the following as part of my json, which is not possible
      "sonic-port:sonic-port": {
            "sonic-port:PORT": {
                "PORT_LIST": [
                    {
                        "admin_status": "up",
                        "alias": "eth0",
                        "description": "Ethernet0",
                        "lanes": 65,
                        "mtu": 9000,
                        "name": "Ethernet0",
                        "speed": 25000
                    }
                ]
            }
        }, 

"2023-01-10 01:02:45,056 [INFO] Exception thrown: Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:name" of value "Ethernet8" points to a non-existing leaf." 

type leafref {
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name";
type string {
pattern 'Ethernet[0-9]{1,2}';
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 24, 2023

Choose a reason for hiding this comment

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

Ethernet

There is use case like Ethernet124 not covered by this pattern. #Closed

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.

Changed

@qiluo-msft qiluo-msft merged commit f239a83 into sonic-net:master May 4, 2023
mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Aug 11, 2023
…et#13326)

Why I did it
Do not require leafref as part of yang. Only need string to compare whether string received from event matches what is possible for ifname.

How I did it
How to verify it
Run UT
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202211: #16113

zbud-msft added a commit to zbud-msft/sonic-buildimage that referenced this pull request Aug 15, 2023
…et#13326)

Why I did it
Do not require leafref as part of yang. Only need string to compare whether string received from event matches what is possible for ifname.

How I did it
How to verify it
Run UT
StormLiangMS pushed a commit that referenced this pull request Aug 15, 2023
* [yang] Change swss-event, dhcp-relay-event leafref to string (#13326)

Why I did it
Do not require leafref as part of yang. Only need string to compare whether string received from event matches what is possible for ifname.

How I did it
How to verify it
Run UT

* Add fix to monit_regex.json for catching mem_usage and cpu_usage (#14954)

Why I did it
Current regex not able to capture logs, modify regex to capture syslog messages

Work item tracking
Microsoft ADO (number only): 13366345
How I did it
Code change

How to verify it
sonic-mgmt test case

* Update usage leaf in sonic-events-host yang models (#15805)

#### Why I did it

event yang models for usage currently use int as type for usage leaf, needs to be of type decimal64

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

#### How I did it

Update yang models and UT

#### How to verify it

UT
@zbud-msft zbud-msft deleted the reviseyangmodels branch February 12, 2025 18:10
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.

6 participants