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 exception when running snmp subagent under python3.7 #130

Merged
merged 1 commit into from
May 6, 2020

Conversation

joyas-joseph
Copy link
Contributor

- What I did
As part of converting the snmp docker to buster, I observed that the snmp subagent exits after throwing an exception.

May  5 21:35:16.852142 sonic ERR snmp#snmp-subagent [sonic_ax_impl] ERROR: Uncaught exception in sonic_ax_impl.main#012Traceback (most recent call last):#012  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/main.py", line 70, in main#012    event_loop.run_until_complete(agent.run_in_event_loop())#012  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete#012    return future.result()#012  File "/usr/local/lib/python3.7/dist-packages/ax_interface/agent.py", line 37, in run_in_event_loop#012    background_task = self.mib_table.start_background_tasks(self.oid_updaters_enabled)#012  File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 276, in start_background_tasks#012    task = event._loop.create_task(fut)#012  File "/usr/lib/python3.7/asyncio/base_events.py", line 405, in create_task#012    task = tasks.Task(coro, loop=self)#012TypeError: a coroutine was expected, got <Task pending coro=<MIBUpdater.start() running at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:34> cb=[MIBTable._done_background_task_callback() at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:263]>

The change also addresses the issue where snmp subagent doesnt exit on SIGTERM.

- How I did it
Code change.

- How to verify it
Verify that subagent is running in the docker.
snmpwalk -c public -v2c .1.3.6.1.2.1.2.2.1.2

- Description for the changelog
Fix exception when running snmp subagent under python3.7

May  5 21:35:16.852142 sonic ERR snmp#snmp-subagent [sonic_ax_impl] ERROR: Uncaught exception in sonic_ax_impl.main#012Traceback (most recent call last):sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/main.py", line 70, in main#012    event_loop.run_until_complete(agent.run_in_event_loop())sonic-net#12  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete#012    return future.result()sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/ax_interface/agent.py", line 37, in run_in_event_loop#012    background_task = self.mib_table.start_background_tasks(self.oid_updaters_enabled)sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 276, in start_background_tasks#012    task = event._loop.create_task(fut)sonic-net#12  File "/usr/lib/python3.7/asyncio/base_events.py", line 405, in create_task#012    task = tasks.Task(coro, loop=self)#012TypeError: a coroutine was expected, got <Task pending coro=<MIBUpdater.start() running at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:34> cb=[MIBTable._done_background_task_callback() at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:263]>

We really do not need to wrap the future within a task.

This also addresses the issue where the subagent would not exit on
SIGTERM.

Signed-off-by: Joyas Joseph <[email protected]>
@joyas-joseph
Copy link
Contributor Author

This change has been verified in both pyhton3.6 and python3.7

$ snmpwalk -c public -v 2c 10.11.57.9 .1.3.6.1.2.1.2.2.1.2
iso.3.6.1.2.1.2.2.1.2.1 = STRING: "hundredGigE1/1"
iso.3.6.1.2.1.2.2.1.2.5 = STRING: "hundredGigE1/2"
iso.3.6.1.2.1.2.2.1.2.9 = STRING: "hundredGigE1/3"
iso.3.6.1.2.1.2.2.1.2.13 = STRING: "hundredGigE1/4"
iso.3.6.1.2.1.2.2.1.2.17 = STRING: "hundredGigE1/5"
iso.3.6.1.2.1.2.2.1.2.21 = STRING: "hundredGigE1/6"
iso.3.6.1.2.1.2.2.1.2.25 = STRING: "hundredGigE1/7"
iso.3.6.1.2.1.2.2.1.2.29 = STRING: "hundredGigE1/8"
iso.3.6.1.2.1.2.2.1.2.33 = STRING: "hundredGigE1/9"
iso.3.6.1.2.1.2.2.1.2.37 = STRING: "hundredGigE1/10"
iso.3.6.1.2.1.2.2.1.2.41 = STRING: "hundredGigE1/11"
iso.3.6.1.2.1.2.2.1.2.45 = STRING: "hundredGigE1/12"
iso.3.6.1.2.1.2.2.1.2.49 = STRING: "hundredGigE1/13"
iso.3.6.1.2.1.2.2.1.2.53 = STRING: "hundredGigE1/14"
iso.3.6.1.2.1.2.2.1.2.57 = STRING: "hundredGigE1/15"
iso.3.6.1.2.1.2.2.1.2.61 = STRING: "hundredGigE1/16"
iso.3.6.1.2.1.2.2.1.2.65 = STRING: "hundredGigE1/17"
iso.3.6.1.2.1.2.2.1.2.69 = STRING: "hundredGigE1/18"
iso.3.6.1.2.1.2.2.1.2.73 = STRING: "hundredGigE1/19"
iso.3.6.1.2.1.2.2.1.2.77 = STRING: "hundredGigE1/20"
iso.3.6.1.2.1.2.2.1.2.81 = STRING: "hundredGigE1/21"
iso.3.6.1.2.1.2.2.1.2.85 = STRING: "hundredGigE1/22"
iso.3.6.1.2.1.2.2.1.2.89 = STRING: "hundredGigE1/23"
iso.3.6.1.2.1.2.2.1.2.93 = STRING: "hundredGigE1/24"
iso.3.6.1.2.1.2.2.1.2.97 = STRING: "hundredGigE1/25"
iso.3.6.1.2.1.2.2.1.2.101 = STRING: "hundredGigE1/26"
iso.3.6.1.2.1.2.2.1.2.105 = STRING: "hundredGigE1/27"
iso.3.6.1.2.1.2.2.1.2.109 = STRING: "hundredGigE1/28"
iso.3.6.1.2.1.2.2.1.2.113 = STRING: "hundredGigE1/29"
iso.3.6.1.2.1.2.2.1.2.117 = STRING: "hundredGigE1/30"
iso.3.6.1.2.1.2.2.1.2.121 = STRING: "hundredGigE1/31"
iso.3.6.1.2.1.2.2.1.2.125 = STRING: "hundredGigE1/32"

@qiluo-msft qiluo-msft merged commit c8e5757 into sonic-net:master May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants