Skip to content

Updates to handle addition and removal of interfaces#12

Merged
rtibbles merged 4 commits into
learningequality:masterfrom
bjester:update-interfaces
Sep 30, 2021
Merged

Updates to handle addition and removal of interfaces#12
rtibbles merged 4 commits into
learningequality:masterfrom
bjester:update-interfaces

Conversation

@bjester
Copy link
Copy Markdown
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

Comment thread zeroconf.py
try:
return e.args[0]
except IndexError:
return None
Copy link
Copy Markdown
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.

Comment thread 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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants