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 broken navoidverify on Linux #2737

Merged

Conversation

lunkwill42
Copy link
Member

While working on SNMPv3 implementation for the async/ipdevpoll parts of NAV, I incidentally found the navoidverify command to be broken before I started.

For the same reasons as documented in nav.ipdevpoll.epollreactor2, navoidverify seems to have stopped working (at least on Linux), due to incompatibilites between the default epollreactor implementation and pynetsnmp.

This change installs NAV's epollreactor2 in Twisted before any of the twisted imports run and install the default reactor. ipdevpoll does the same, but since this is an all-in-one script, this mucks about with code in between imports to ensure it runs before twisted, while a multi-module system like ipdevpoll can simply do it before calling the main() function.

Reference

def _remove(self, xer, primary, other, selectables, event, antievent):
"""
Private method for removing a descriptor from the event loop.
It does the inverse job of _add, and also add a check in case of the fd
has gone away.
It overrides the inherited epollreactor functionality to ensure that file
descriptors closed behind our back are ignored and properly removed from the
reactor's internal data structures. This is needed mostly because pynetsnmp
adds reactor readers for file descriptors that are managed by the NET-SNMP C
library. There is no way for Python code close these file descriptors in a
controlled way, wherein they are removed from the reactor first - the
NET-SNMP library will close them "behind our backs", so to speak.
Attempting to unregister a closed file descriptor from the epoll object will
cause an OSError that the original implementation left the client to handle -
but this also caused the internal data structures of the reactor to become
inconsistent.
"""

For the same reasons as documented in nav.ipdevpoll.epollreactor2,
navoidverify seems to have stopped working (at least on Linux), due
to incompatibilites between the default epollreactor implementation
and pynetsnmp.

This change installs NAV's epollreactor2 in Twisted before any
of the twisted imports run and install the default reactor.
@lunkwill42 lunkwill42 added the bug label Nov 14, 2023
@lunkwill42 lunkwill42 self-assigned this Nov 14, 2023
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

github-actions bot commented Nov 14, 2023

Test results

     12 files       12 suites   12m 27s ⏱️
3 228 tests 3 228 ✔️ 0 💤 0
9 159 runs  9 159 ✔️ 0 💤 0

Results for commit 5356a3e.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0388823) 55.32% compared to head (5356a3e) 55.32%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2737   +/-   ##
=======================================
  Coverage   55.32%   55.32%           
=======================================
  Files         567      567           
  Lines       41052    41052           
=======================================
  Hits        22713    22713           
  Misses      18339    18339           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

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

What happens on FreeBSD? Is this only a problem on Linux?

@lunkwill42
Copy link
Member Author

What happens on FreeBSD? Is this only a problem on Linux?

I have not heard any complaints from UiT, which run NAV on FreeBSD (i.e. the only complaint was that ipdevpoll installed the epollreactor2 regardless of the OS, and it doesn't work on FreeBSD).

Apparently, this problem is exclusive to Twisted's built-in epollreactor, which it selects by default on Linux systems.

It might also be that a newer version of Twisted would work better (after all, we are locked to an older version atm).

@lunkwill42 lunkwill42 merged commit 75a6331 into Uninett:master Nov 16, 2023
@lunkwill42 lunkwill42 deleted the bugfix/navoidverify-epollreactor branch November 16, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants