-
Notifications
You must be signed in to change notification settings - Fork 113
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
[Namespace]: Fix SAI_ID key used in cpfcIfTable and csqIfQosGroupStatsTable implementation #138
[Namespace]: Fix SAI_ID key used in cpfcIfTable and csqIfQosGroupStatsTable implementation #138
Conversation
unique across the device. The SAI object ID is unique for asic or within a namespace. Modify the existing code to make sure that data structures using SAI OID, it is not used as a key directly. Modify implementation for MIB tables using COUNTER_DB and ASIC_DB so that SAI OID is used to retrieve data only from a single namespace. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
This pull request introduces 4 alerts when merging 7a02ecc into eba1408 - view on LGTM.com new alerts:
|
{sai_id: Namespace.dbs_get_all(self.db_conn, mibs.COUNTERS_DB, mibs.counter_table(sai_id), blocking=True) | ||
for sai_id in self.if_id_map} | ||
{if_idx: self.db_conn[self.if_oid_namespace[if_idx]].get_all( | ||
mibs.COUNTERS_DB, mibs.counter_table(self.oid_sai_map[if_idx]), blocking=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing for loop of retrieving if_idx. Apply for all below files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the loop.
@@ -1,11 +1,11 @@ | |||
{ | |||
"ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bridge_id\":\"oid:0x0\",\"bridge_type\":\"SAI_FDB_ENTRY_BRIDGE_TYPE_1Q\",\"mac\":\"7C:FE:90:80:9F:10\",\"switch_id\":\"oid:0x21000000000000\",\"vlan\":\"1000\"}": { | |||
"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID": "oid:0x3a0000000006208", | |||
"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID": "oid:0x3a000000000616", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what trigger this changes ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified namespace mock dbs to reflect the idea that SAI ID will be repeated across namespaces.
@@ -320,7 +320,8 @@ def init_sync_d_queue_tables(db_conn): | |||
queue_stat_name = queue_table(sai_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queue_stat_name [](start = 8, length = 15)
SAI Object ID is unique in this db_conn
. So the original implementation of init_sync_d_queue_tables
makes sense.
Let's block this PR and continue exploration the dbs dict strategy, as also discussed in another PR (#137) #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the data will eventually merged together , we have to make sure that the keys are unique in these dictionaries.
So in maps which use SAI ID as key, modified it to use a combination of if_idx and SAI ID.
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Revert FDB MIB namespace related changes. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
This pull request introduces 2 alerts when merging 7657c72 into 90e9f2e - view on LGTM.com new alerts:
|
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
src/sonic_ax_impl/mibs/__init__.py
Outdated
@@ -339,8 +339,8 @@ def init_sync_d_queue_tables(db_conn): | |||
logger.debug("Queue name map:\n" + pprint.pformat(queue_name_map, indent=2)) | |||
|
|||
# Parse the queue_name_map and create the following maps: | |||
# port_queues_map -> {"if_index : queue_index" : sai_oid} | |||
# queue_stat_map -> {queue stat table name : {counter name : value}} | |||
# port_queues_map -> {"if_name : queue_index" : sai_oid} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if_name [](start = 27, length = 7)
It should be "port_index"? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this, it should be port_index and not port_name.
@@ -65,6 +65,7 @@ def __init__(self): | |||
self.mib_oid_list = [] | |||
|
|||
self.queue_type_map = {} | |||
self.if_id_namespace = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if_ [](start = 13, length = 3)
The concept in this MIB is port, not interface. Suggest rename if_*
to port_*
#Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified the naming in this file.
Fix variable name used in ciscoSwitchQosMIB and queue related init function. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
queue_stat = Namespace.dbs_get_all(self.db_conn, mibs.COUNTERS_DB, queue_stat_name, blocking=False) | ||
if_index, _ = queue_key.split(':') | ||
queue_stat_idx = mibs.queue_key(if_index, queue_stat_name) | ||
queue_stat = self.queue_stat_map.get(queue_stat_idx, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can queue_stat be None ? Do we have to do this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can queue_stat be None ? Do we have to do this check
We have a check in the line below to check if queue_stat is not None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my point was can it be ever None ? do we need to put if condition ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, none check is required the same as in: https://github.com/SuvarnaMeenakshi/sonic-snmpagent/blob/counters_fix/src/sonic_ax_impl/mibs/__init__.py#L358.
I have fixed the code to do a get_all to get the updated stats.
The previous code was providing the correct results as each time reinit_data was invoked, the stats was getting updated.
But update data is called more frequently, and update_data also should do a get_all each time, after which the None check will be required.
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
queue_stat_idx = mibs.queue_key(port_index, queue_stat_name) | ||
namespace = self.port_index_namespace[int(port_index)] | ||
queue_stat = self.namespace_db_map[namespace].get_all( \ | ||
mibs.COUNTERS_DB, queue_stat_name, blocking=False) | ||
if queue_stat is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if queue_stat is not None [](start = 12, length = 25)
Otherwise, del the index from self.queue_stat_map
#Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if queue_stat is not None [](start = 12, length = 25)
Otherwise, del the index from
self.queue_stat_map
Added as per comment.
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@@ -88,13 +91,12 @@ def _get_counter(self, oid, counter_name): | |||
:param counter_name: the redis table (either IntEnum or string literal) to query. | |||
:return: the counter for the respective sub_id/table. | |||
""" | |||
sai_id = self.oid_sai_map[oid] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is oid_sai_map is being used or this can be removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed oid_sai_map as it is not required. The required information can be retrieved from oid_name_map.
The required data can be retrieved from oid_name_map data structure. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Retest this please |
…sTable implementation (#138) In multi-asic platform, SAI OID is not unique for the whole device. It is unique for an asic and within a single namespace. This PR is to make sure that data structures that use SAI Object ID as a key to retrieve data from COUNTERS_DB updated so that a combination of SAI Object ID and port index is used as a key. Update data structure to use combination SAI Object ID and port index as a key to retrieve data from COUNTERS_DB. Update Unit-test mock DB in namespaces, to reflect the scenario where SAI Object is same across different namespaces. Updates done to MIB implementation for the below MIB tables to get data from the right database instances: cpfcIfTable csqIfQosGroupStatsTable * Remove usage of oid_sai_map data structure as it is not being used. The required data can be retrieved from oid_name_map data structure. Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi sumeenak@microsoft.com
- What I did
In multi-asic platform, SAI OID is not unique for the whole device. It is unique for an asic and within a single namespace.
This PR is to make sure that data structures that use SAI Object ID as a key to retrieve data from COUNTERS_DB updated so that a combination of SAI Object ID and port index is used as a key.
- How I did it
- How to verify it
- Description for the changelog