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

[intfstat] Fix logic in RIF counters to print right stats #1732

Merged
merged 1 commit into from
Aug 27, 2021

Conversation

noaOrMlnx
Copy link
Collaborator

@noaOrMlnx noaOrMlnx commented Jul 29, 2021

What I did

Fix logic in scripts/intfstat file.
Before the change:
If a user cleared all counters using sonic-clear rifcounters command and then queried for rif counters with a certain interface (e.g. show interfaces counters rif Ethernet0), the user would see the older stats. meaning the clear was not performed.
The reason for this is that when we do sonic-clear rifcounters, the counters are not really being cleared, but current stats are saved into a file, and in the next counters query, it will calculate the diff between current counters and the saved counters.
If the clear was performed in general (without an interface name), it's saved to a general file (e.g. 0).
If the clear was performed for a certain interface, it's saved to an interface file (e.g. 0-Ethernet0).
so when we clear in one method and then query for the other, we can receive the info from the wrong file and display different stats.

Fix issue - sonic-net/sonic-buildimage#8394

How I did it

Add the logic:
when deleting for a certain interface, add the info to the general file.
when querying for a certain interface, check the general file as well.

How to verify it

  • send traffic to interface

  • check general rif table (show interfaces counters rif)

  • clear general rifcounters (sonic-clear rifcounters)

  • check that the specific interface table is also updated (show interfaces counters rif Ethernet0)

  • send traffic to interface

  • clear interface table (sonic-clear rifcounters Ethernet0)

  • check that general table is updated as well (show interfaces counters rif)

Previous command output (if the output of a command-line utility has changed)

N/A

New command output (if the output of a command-line utility has changed)

N/A

@BasimShalata
Copy link
Contributor

@liat-grozovik FYI.
@dgsudharsan can you please review.

scripts/intfstat Outdated
Comment on lines 321 to 329
pickle.dump(cnstat_dict, open(cnstat_fqn_file, 'wb'))
except IOError as e:
sys.exit(e.errno)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are making the general file upto date, can you please explain the need for the interface specific file? In my opinion one file should be good enough to save stats.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is another feature we need to take into consideration - tag_name.
If a user wants to clear counters with a certain tag, we need to keep stats in this tag file.
so I removed the interface name in file which is indeed unneeded, but changed the logic in the script to not brake tag_name logic.

@noaOrMlnx
Copy link
Collaborator Author

/azpw run

Copy link
Collaborator

@dgsudharsan dgsudharsan left a comment

Choose a reason for hiding this comment

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

scripts/intfstat Show resolved Hide resolved
dgsudharsan
dgsudharsan previously approved these changes Aug 7, 2021
@prsunny prsunny merged commit 83309c6 into sonic-net:master Aug 27, 2021
qiluo-msft pushed a commit that referenced this pull request Aug 30, 2021
*when deleting for a certain interface, add the info to the general file.
*when querying for a certain interface, check the general file as well.
judyjoseph pushed a commit that referenced this pull request Sep 2, 2021
*when deleting for a certain interface, add the info to the general file.
*when querying for a certain interface, check the general file as well.
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
…627)

7041400 [config reload] Call systemctl reset-failed for snmp,telemetry,mgmt-framework services (sonic-net#1773) (sonic-net#1786)
399d370 Fix logic in RIF counters print (sonic-net#1732)
8329544 [vnet_route_check] don't hardcode prefix length of /24 (sonic-net#1756)
193b028 [neighbor-advertiser] delete the tunnel maps appropriately (sonic-net#1663)
2c82bcf [neighbor_advertiser] Use existing tunnel if present for creating tunnel mappings (sonic-net#1589)
8e22960 [202012][Config] Update config command of Kdump. (sonic-net#1778)
be3e5c6 [show][config] cli refactor for muxcable with abstract class implementation from vendors (sonic-net#1722) (sonic-net#1782)
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