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

Updates to handle addition and removal of interfaces #12

Merged
merged 4 commits into from
Sep 30, 2021

Conversation

bjester
Copy link
Member

@bjester bjester commented Sep 17, 2021

Changes

  • Converts some usage of assert that should likely persist if python -O is used
  • Breaks out interface attachment from Zeroconf.__init__ into its own method _add_interfaces
  • Adds corresponding behavior for removing interfaces, along the lines of how _add_interfaces functions but in reverse
  • Exposes new public method Zeroconf.update_interfaces which triggers add or removal of interfaces compared with already attached interfaces
  • Prevents stack trace reporting of errors that occur because the network is unreachable, errno.ENETUNREACH
  • Updates Zeroconf.send to accept an interface on which filter the interfaces it sends the messages on, such that adding and removing interfaces can attempt to send add/remove messages when the interface is removed
    • Note: in Kolibri this will have little effect as we update the interfaces we detect the network has already changed, which will output warnings like WARNING: Network unreachable on interface 10.8.0.21
  • Adds new integration test ensuring above behavior

Notes

  • When the network is disconnected in Kolibri, it may take up to the TTL for events to occur on client and server
  • With additional changes in my Kolibri PR to handle update_service events, I believe the following scenario is handled:
    • When the client is registered (connected to the VPN), drops out (disconnects from VPN), and rejoins with a new IP (reconnects with different VPN config) all within the TTL, the server may not have the correct information
  • Kolibri PR: Sync resumption for SoUD syncs and cleanup handling kolibri#8183

try:
return e.args[0]
except IndexError:
return None
Copy link
Member Author

Choose a reason for hiding this comment

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

It appeared that the OSError, socket.error exceptions had an explicit errno attribute so I made this match that, and also be defensive since the previous assert could be removed with python -O.

zeroconf.py Outdated
self.log_exception_warning()
except Exception as e: # TODO stop catching all Exceptions
if get_errno(e) == errno.ENETUNREACH:
self.log_warning_once("Network unreachable on interface {}".format(interface))
Copy link
Member Author

Choose a reason for hiding this comment

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

A fix to log socket write errors as simple warnings, as observed when interface becomes disconnected.

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Tests pass, new test makes sense, new functionality is awesome!

@rtibbles rtibbles merged commit adeb0a6 into learningequality:master Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants