Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Pfcwd Queries #332

Merged

Conversation

zbud-msft
Copy link
Contributor

Why I did it

Pfcwd queries currently use PFC_WD_TABLE which is not the correct table name. Use PFC_WD instead.

Since Pfcwd are not crucial to other COUNTERS paths, if map creation of Pfcwd fails, we will fail gracefully and return empty json for Pfcwd instead of impacting all COUNTER_DB queries.

How I did it

Change table name

How to verify it

UT and manual testing

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

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

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

@mssonicbld
Copy link

/azp run

@zbud-msft zbud-msft requested a review from Copilot December 19, 2024 19:27
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

@zbud-msft zbud-msft requested a review from ganglyu December 19, 2024 19:27
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -149,7 +149,10 @@ func getPfcwdMap() (map[string]map[string]string, error) {
}

for _, key := range resp {
name := key[13:]
if strings.Contains(key, "GLOBAL") || strings.Contains(key, "global") { // ignore PFC_WD|global / PFC_WD|GLOBAL
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we ignore PFC_WD|global?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No counters associated with global since it is not a port. We are trying to create a mapping of oid from port name and pfc queue index which we will use to retrieve pfc wd counters. We ignore global since it serves no purpose for building the mapping since no port is associated with global

ganglyu
ganglyu previously approved these changes Dec 20, 2024
@@ -119,7 +119,7 @@ func initCountersPfcwdNameMap() error {
}

// Get the mapping between sonic interface name and oids of their PFC-WD enabled queues in COUNTERS_DB
func getPfcwdMap() (map[string]map[string]string, error) {
func GetPfcwdMap() (map[string]map[string]string, error) {

Choose a reason for hiding this comment

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

All other function names use camelcase format, should we go back to the previous name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this function public for testing. Capitalizing the first letter in the function name makes it public.

if strings.Contains(key, "GLOBAL") || strings.Contains(key, "global") { // ignore PFC_WD|global / PFC_WD|GLOBAL
continue
}
name := key[7:]

Choose a reason for hiding this comment

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

instead of "7", should we get the length of "PFC_WD|" using a function for future proof?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can make that change.

nn.TS = time.Unix(0, 200)
gotNoti = append(gotNoti, nn)
}
mutexGotNoti.Unlock()

Choose a reason for hiding this comment

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

connection close on error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have a defer statement that will stop the server connection, if there is an error, before the function exits, the defer statement will be called.

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zbud-msft zbud-msft merged commit a538f49 into sonic-net:master Jan 27, 2025
5 checks passed
@mssonicbld
Copy link

Cherry-pick PR to 202411: #347

hdwhdw pushed a commit to hdwhdw/sonic-gnmi that referenced this pull request Jan 28, 2025
Why I did it

Pfcwd queries currently use PFC_WD_TABLE which is not the correct table name. Use PFC_WD instead.

Since Pfcwd are not crucial to other COUNTERS paths, if map creation of Pfcwd fails, we will fail gracefully and return empty json for Pfcwd instead of impacting all COUNTER_DB queries.
hdwhdw pushed a commit to hdwhdw/sonic-gnmi that referenced this pull request Jan 28, 2025
Why I did it

Pfcwd queries currently use PFC_WD_TABLE which is not the correct table name. Use PFC_WD instead.

Since Pfcwd are not crucial to other COUNTERS paths, if map creation of Pfcwd fails, we will fail gracefully and return empty json for Pfcwd instead of impacting all COUNTER_DB queries.
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.

4 participants