fix NDB() instantiation

Description

PR: https://github.com/truenas/middleware/pull/7151

Fixes a few issues.

  • `with pyroute2.NDB().interfaces...` opened a netlink socket and left it dangling every time an interface was up/down'ed

  • NDB() is absurdly chatty (even only logging errors) and instantiating this class actually starts a thread which monitors kernel network events and will log lots of messages (repeatedly) to middlewared.log

  • `service.start/stop kubernetes` is causing a golang core dump (unrelated problem upstream) however it showed these problems

Fix this by:

  • instantiating a NDB() class on up()/down() respectively

  • use the correct context manager inside the class object so the changes that are pushed to the interface actually take effect so when the method returns, it's fully complete

  • turn off logging entirely and catch any exception

  • ensure we always close the netlink socket

Problem/Justification

None

Impact

None

is duplicated by

Activity

Show:
Complete
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Fix versions

Priority

More fields

Katalon Platform

Created July 14, 2021 at 3:35 PM
Updated July 6, 2022 at 9:00 PM
Resolved July 14, 2021 at 4:43 PM