Handle error seen when interface counter is not available in COUNTERS_DB#341
Merged
SuvarnaMeenakshi merged 9 commits intosonic-net:masterfrom Mar 4, 2025
Merged
Conversation
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
qiluo-msft
reviewed
Jan 14, 2025
| for lag_member in self.lag_name_if_name_map[self.oid_lag_name_map[port_oid]]: | ||
| counter_value += self._get_counter(mibs.get_index_from_str(lag_member), counter_name) | ||
| member_counter = self._get_counter(mibs.get_index_from_str(lag_member), counter_name) | ||
| if member_counter: |
Contributor
Contributor
Author
There was a problem hiding this comment.
I see that "if member_counter" condition will hold good if member_counter is not None or is not zero.
In case a specific counter is 0, that will also drop to else condition.
I can do either:
if member_counter:
add ..
or
if member_counter is not None:
add...
else:
return None # this will handle the scenario where _get_counter returned None for any of its member interface.
There was a problem hiding this comment.
@SuvarnaMeenakshi , I think @qiluo-msft original comment is suggesting you to take on the second choice to return None. Please go ahead modify your PR accordingly and we can ask @qiluo-msft to help review it again.
Thanks!
Contributor
Author
There was a problem hiding this comment.
Updated as suggested and corresponding unit-test.
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com> (cherry picked from commit da06490cada1d4b83d44ec6e183e84b8fcd48b36)
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
qiluo-msft
approved these changes
Mar 4, 2025
ssithaia-ebay
pushed a commit
to ssithaia-ebay/sonic-snmpagent
that referenced
this pull request
May 23, 2025
…_DB (sonic-net#341) **- What I did** Fix to handle error seen: ``` snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()#012Traceback (most recent call last):sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/ax_interface/mib.py", line 194, in __call__#012 return self._callable_.__call__(sub_id, *self._callable_args)sonic-net#12 File "/usr/local/lib/python3.9/dist-packages/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py", line 248, in indications_per_priority#012 counter_value += self._get_counter(mibs.get_index_from_str(lag_member), counter_name)#012TypeError: unsupported operand type(s) for += ``` Above error log occurs when the services restarted, swss/syncd due to some crash/reboot/config reload, this will also cause snmp service to restart. During this time, it can happen that all interface COUNTERS are not yet available in COUNTERS_DB for a short period. At this point, if a SNMP query is made to retrieve interface/PFC counters, then this error syslog will show up until the COUNTERS_DB data is populated with counters for all interfaces. MSFT ADO 26506804 **- How I did it** Avoid adding up counters if _get_counter returns None. **- How to verify it** Before FIX: send a continuous query to get pfc counters for any of the configured port-channel interface: watch -n 1 snmpwalk -v2c -c <comm> <ip> 1.3.6.1.4.1.9.9.813.1.2.1.3.1103 on the device, execute config reload and we should see the error log on the device: After fix, perform same snmpwalk as above, SNMP ERR log will not be seen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
Fix to handle error seen:
Above error log occurs when the services restarted, swss/syncd due to some crash/reboot/config reload, this will also cause snmp service to restart. During this time, it can happen that all interface COUNTERS are not yet available in COUNTERS_DB for a short period. At this point, if a SNMP query is made to retrieve interface/PFC counters, then this error syslog will show up until the COUNTERS_DB data is populated with counters for all interfaces.
MSFT ADO 26506804
- How I did it
Avoid adding up counters if _get_counter returns None.
- How to verify it
Before FIX:
send a continuous query to get pfc counters for any of the configured port-channel interface:
on the device, execute config reload and we should see the error log on the device:
After fix
Perform same snmpwalk as above, SNMP ERR log will not be seen.
- Description for the changelog