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

Fix undefined variable and warning message #134

Merged
merged 8 commits into from
Jun 25, 2020

Conversation

SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented Jun 16, 2020

- What I did

  • Fix undefined variable introduced in [Multi-asic]: Namespace support for LLDP and Sensor tables #131
  • Add fdb unit-test for namespace changes
  • Fix update_data() LocPortUpdater, LLDPRemManAddrUpdater and PhysicalTableMIBUpdater caused due to Namespace changes. The pubsub channel should not be created everytime on update-data and should be created only if it is not previously created. This causes a warning message and does not get any new changes in the subscribed key pattern.
sonic WARNING snmp#snmp-subagent [sonic_ax_impl] WARNING: Invalid interface name in TRANSCEIVER_INFO|*                      in STATE_DB, skipping
snmp#snmp-subagent [sonic_ax_impl] WARNING: Invalid interface name in *' in APP_DB, skipping

- How I did it

  • Added fdb unit-test for namespace changes
  • Made sure that the pubsub channel for each Namespace DB is created only once.

- How to verify it

  • Tested out on single asic and multiple asic platforms.
    Make sure that warning messages are not seen in syslog.

- Description for the changelog

Add namespace test case for fdb related MIB.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
functions. Multiple connect is causing an increase in run
time causing agentx connection to close.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@@ -536,18 +544,18 @@ def update_rem_if_mgmt(self, if_oid, if_name):
return
self.if_range.sort()

def _update_per_namespace_data(self, db_conn, pubsub):
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 18, 2020

Choose a reason for hiding this comment

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

_update_per_namespace_data [](start = 8, length = 26)

Original code seems better. Why change? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before namespace changes, self.pubsub was getting updated in update_data(). After namespace change, self.pubsub array was not updated as we pass the instance. By passing the array index, we can ensure that the array is directly getting udpated. So this fix is to make sure the code is as it was before namespace changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated description with the issue and why this fix is required.

Copy link
Contributor

@qiluo-msft qiluo-msft Jun 25, 2020

Choose a reason for hiding this comment

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

I see the bug in #131.

To make code cleaner, could you try add

db_conn = self.db_conn[inst]
pubsub = self.pubsub[inst]
if not pubsub:
    ...
    pubsub = redis_client.pubsub()
    self.pubsub[inst] = pubsub


In reply to: 441919551 [](ancestors = 441919551)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as per comments.

redis_client = self.statedb[inst].get_redis_client(self.statedb[inst].STATE_DB)
db = self.statedb[inst].get_dbid(self.statedb[inst].STATE_DB)
self.pubsub[inst] = redis_client.pubsub()
self.pubsub[inst].psubscribe("__keyspace@{}__:{}".format(db, self.TRANSCEIVER_KEY_PATTERN))
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 18, 2020

Choose a reason for hiding this comment

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

Duplicated code. Could you reuse? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicated with ieee802_1ab.py


In reply to: 441920582 [](ancestors = 441920582)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as per review comments.

@@ -104,6 +104,7 @@ def __init__(self):
super().__init__()

self.db_conn = Namespace.init_namespace_dbs()
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 18, 2020

Choose a reason for hiding this comment

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

Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB) [](start = 8, length = 53)

Original code could tolerate temporary or initial Redis not offline and recover whenever online. But the new code could not. Can you improve and test?
#Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do see that if redis-server process is stopped and started, the MIB walk does not get affected, as the connect is persistent_connect. But, I have reverted this change, I will raise a new PR to provide a clean fix to reduce runtime.

"SAI_BRIDGE_PORT_ATTR_TYPE": "SAI_BRIDGE_PORT_TYPE_PORT",
"SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x1000000000005",
"SAI_BRIDGE_PORT_ATTR_ADMIN_STATE": "true"
}
}
Copy link
Contributor

@qiluo-msft qiluo-msft Jun 18, 2020

Choose a reason for hiding this comment

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

If not related to the PR subject, could you submit another PR just for test cases? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test case is to test the code path where the undefined variable is fixed in this PR.

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

not created everytime in update_data but is created only if
the channel was not created previously.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@SuvarnaMeenakshi SuvarnaMeenakshi changed the title Fix undefined variable and reduce runtime Fix undefined variable and warning message Jun 24, 2020
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@qiluo-msft qiluo-msft merged commit eba1408 into sonic-net:master Jun 25, 2020
abdosi pushed a commit that referenced this pull request Jul 8, 2020
* Fix errors introduced.
Add namespace test case for fdb related MIB.
* Make sure that db connections are done in MIB class init
functions. Multiple connect is causing an increase in run
time causing agentx connection to close.
* Minor fix
* Add mock asic_db.
* Remove trailing whitespace.
* Revert "Make sure that db connections are done in MIB class init"
* Fix to make sure pubsub channel in LLDPRemManAddrUpdater is
not created everytime in update_data but is created only if
the channel was not created previously.
* Fix as per review comments.
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.

3 participants