Skip to content

Commit 3013597

Browse files
Fix Queue stat unavailable error seen during SNMP service start (sonic-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.
1 parent b8ea609 commit 3013597

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/sonic_ax_impl/mibs/__init__.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

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

47-
4847
def get_neigh_info(neigh_key):
4948
"""
5049
split neigh_key string of the format:
@@ -455,9 +454,9 @@ def init_sync_d_queue_tables(db_conn):
455454
if not port_queues_map:
456455
logger.debug("Counters DB does not contain ports")
457456
return {}, {}, {}
458-
elif not queue_stat_map:
459-
logger.error("No queue stat counters found in the Counter DB. SyncD database is incoherent.")
460-
raise RuntimeError('The queue_stat_map is not defined')
457+
if not queue_stat_map:
458+
logger.debug("No queue stat counters found in the Counter DB.")
459+
return {}, {}, {}
461460

462461
for queues in port_queue_list_map.values():
463462
queues.sort()

tests/test_mibs.py

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest import TestCase
44

55
import tests.mock_tables.dbconnector
6+
from sonic_ax_impl import mibs
67

78
if sys.version_info.major == 3:
89
from unittest import mock
@@ -50,3 +51,14 @@ def test_init_sync_d_interface_tables(self):
5051
self.assertTrue(if_alias_map == {})
5152
self.assertTrue(if_id_map == {})
5253
self.assertTrue(oid_name_map == {})
54+
55+
@mock.patch('swsssdk.dbconnector.SonicV2Connector.get_all', mock.MagicMock(return_value=({})))
56+
def test_init_sync_d_queue_tables(self):
57+
mock_queue_stat_map = {}
58+
db_conn = Namespace.init_namespace_dbs()
59+
60+
port_queues_map, queue_stat_map, port_queue_list_map = \
61+
Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_queue_tables, db_conn)
62+
self.assertTrue(port_queues_map == {})
63+
self.assertTrue(queue_stat_map == {})
64+
self.assertTrue(port_queue_list_map == {})

0 commit comments

Comments
 (0)