Skip to content

Commit

Permalink
Fix Queue stat unavailable error seen during SNMP service start (soni…
Browse files Browse the repository at this point in the history
…c-net#238)

- What I did

Ideally SNMP service starts only after swss/syncd comes up.
But due to timing of bring up, It could happen that SNMP is trying to retrieve queue stat counter before it is update by syncd.
This is only seen once when the SNMP service comes up, as from the next iteration, syncd has updated the queue stats and it is available for SNMP to use.
ERR snmp#snmp-subagent [sonic_ax_impl] ERROR: No queue stat counters found in the Counter DB. SyncD database is incoherent.
This message is seen only once in all the cases observed, which means that once the counters are populated, snmp is able to retrieve the counters.
- How I did it
If counters are not found, return empty dicts since SNMP is just supposed to collect data and provide the data it has.

- How to verify it
Added unit-test.
If counters_db is not update, querying the QueueStats MIB should not return any output.
  • Loading branch information
SuvarnaMeenakshi committed Jan 4, 2022
1 parent b8ea609 commit 3013597
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

redis_kwargs = {'unix_socket_path': '/var/run/redis/redis.sock'}


def get_neigh_info(neigh_key):
"""
split neigh_key string of the format:
Expand Down Expand Up @@ -455,9 +454,9 @@ def init_sync_d_queue_tables(db_conn):
if not port_queues_map:
logger.debug("Counters DB does not contain ports")
return {}, {}, {}
elif not queue_stat_map:
logger.error("No queue stat counters found in the Counter DB. SyncD database is incoherent.")
raise RuntimeError('The queue_stat_map is not defined')
if not queue_stat_map:
logger.debug("No queue stat counters found in the Counter DB.")
return {}, {}, {}

for queues in port_queue_list_map.values():
queues.sort()
Expand Down
12 changes: 12 additions & 0 deletions tests/test_mibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest import TestCase

import tests.mock_tables.dbconnector
from sonic_ax_impl import mibs

if sys.version_info.major == 3:
from unittest import mock
Expand Down Expand Up @@ -50,3 +51,14 @@ def test_init_sync_d_interface_tables(self):
self.assertTrue(if_alias_map == {})
self.assertTrue(if_id_map == {})
self.assertTrue(oid_name_map == {})

@mock.patch('swsssdk.dbconnector.SonicV2Connector.get_all', mock.MagicMock(return_value=({})))
def test_init_sync_d_queue_tables(self):
mock_queue_stat_map = {}
db_conn = Namespace.init_namespace_dbs()

port_queues_map, queue_stat_map, port_queue_list_map = \
Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_queue_tables, db_conn)
self.assertTrue(port_queues_map == {})
self.assertTrue(queue_stat_map == {})
self.assertTrue(port_queue_list_map == {})

0 comments on commit 3013597

Please sign in to comment.