Skip to content

[Namespace]: Fix SNMP AgentX socket connection timeout when using Namespace.get_all() - #140

Merged
abdosi merged 9 commits into
sonic-net:masterfrom
SuvarnaMeenakshi:dbs_get_time_fix
Jul 11, 2020
Merged

abdosi merged 9 commits into
sonic-net:masterfrom
SuvarnaMeenakshi:dbs_get_time_fix

Conversation

@SuvarnaMeenakshi

@SuvarnaMeenakshi SuvarnaMeenakshi commented Jul 10, 2020 •

Copy link
Copy Markdown
Contributor

Signed-off-by: SuvarnaMeenakshi sumeenak@microsoft.com

- What I did
To support namespaces, we added a Namespace class with functions to support getting data from all databases.
The Namespace dbs_get_all function , checks if the key exists in the database and does db connect before executing get_all.
Both of this operation causes additional time, which was causing agentx socket to disconnect.

- How I did it

  • Remove the additional check that was added to see if the key exists before doing a get all.
  • Remove db connect from dbs_get_all , as this was adding additional delay in dbs_get_all function, which is called during update_data. Instead, connect to all dbs during initialization, and connect to required dbs before invoking sync_d functions to ensure connection persists periodically.

- How to verify it
For single-asic platform and multi-asic, execute snmp queries to verify that the agentx socket does not disconnect and time issue is seen.

- Description for the changelog

to reduce time taken.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Comment thread src/sonic_ax_impl/mibs/__init__.py Outdated
Comment thread src/sonic_ax_impl/mibs/__init__.py Outdated
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

@abdosi abdosi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

abdosi
abdosi previously approved these changes Jul 10, 2020
sync_d functions to reduce time taken in dbs_get_all.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
The Namespace functions will be used for both single
and multi-asic platforms.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@abdosi abdosi changed the title [Namespace]: Remove exists check in Namespace get_all [Namespace]: Fix SNMP Agent X socket connection timeout when using Namespace.get_all() Jul 10, 2020
@qiluo-msft qiluo-msft changed the title [Namespace]: Fix SNMP Agent X socket connection timeout when using Namespace.get_all() [Namespace]: Fix SNMP AgentX socket connection timeout when using Namespace.get_all() Jul 10, 2020
Comment thread src/sonic_ax_impl/mibs/__init__.py Outdated
# If there are multiple namespaces, _hash might not be
# present in all namespace, ignore if not present in a
# specfic namespace.
if (len(dbs) > 1) : kwargs['blocking'] = False

@qiluo-msft qiluo-msft Jul 10, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

kwargs['blocking'] = False [](start = 28, length = 26)

Please move it in next line. #Closed

Copy link
Copy Markdown
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 comment.

Comment thread src/sonic_ax_impl/mibs/__init__.py Outdated
# If there are multiple namespaces, _hash might not be
# present in all namespace, ignore if not present in a
# specfic namespace.
if (len(dbs) > 1) : kwargs['blocking'] = False

@qiluo-msft qiluo-msft Jul 10, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

( [](start = 11, length = 1)

you can remove '()' #Closed

Copy link
Copy Markdown
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 comment.

Comment thread src/sonic_ax_impl/mibs/__init__.py Outdated
# If there are multiple namespaces, _hash might not be
# present in all namespace, ignore if not present in a
# specfic namespace.
if (len(dbs) > 1) : kwargs['blocking'] = False

@qiluo-msft qiluo-msft Jul 11, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

kwargs [](start = 28, length = 6)

This parameter is passed as reference, and it is mutable.
If you change it inside function, it will have side-effect to the caller's scope. Could you do not change it? #Closed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@qiluo-msft We were initially updating all the function call arguments and the changes were spread in multiple places. This approach looks better where only for Multi-Asic we are making blocking as False and for single asic behavior remains unchanged.
Also caller should not be impacted by this as it does not get used in caller scope and just passes the value to the library.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As per suggestion, instead of modifying kwargs directly, did a shallow copy to change.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
do a shallow copy instead.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@abdosi
abdosi merged commit 1d210d9 into sonic-net:master Jul 11, 2020
abdosi pushed a commit that referenced this pull request Jul 11, 2020
…espace.get_all() (#140)

* [Namespace]: Remove key exists check in dbs_get_all
to reduce time taken.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix as per review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Minor fix.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Connect to all required namespace dbs during init and periodic
sync_d functions to reduce time taken in dbs_get_all.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Change test_mibs to use generic wrapper function added.
The Namespace functions will be used for both single
and multi-asic platforms.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix as per review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Remove whitespace.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix review comment. Avoid modifying mutable object kwargs,
do a shallow copy instead.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
ssithaia-ebay pushed a commit to ssithaia-ebay/sonic-snmpagent that referenced this pull request May 23, 2025
…espace.get_all() (sonic-net#140)

* [Namespace]: Remove key exists check in dbs_get_all
to reduce time taken.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix as per review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Minor fix.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Connect to all required namespace dbs during init and periodic
sync_d functions to reduce time taken in dbs_get_all.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Change test_mibs to use generic wrapper function added.
The Namespace functions will be used for both single
and multi-asic platforms.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix as per review comment.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Remove whitespace.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>

* Fix review comment. Avoid modifying mutable object kwargs,
do a shallow copy instead.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
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