network: fix crash when Wi-Fi or eth interface gets removed from the system #1789
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses https://bugs.launchpad.net/subiquity/+bug/2012659 and other private bugs with similar stracktraces.
When a network interface is disconnected from the system (e.g., physically removed if it's a USB adapter), probert asynchronously calls the del_link() method.
Upon receiving this notification, Subiquity server wants to send an update to the Subiquity clients. The update contains information about the interface that disappeared - which is obtained through a call to netdev_info.
Unfortunately, for Wi-Fi and Ethernet interfaces, netdev_info dereferences the NetworkDev.info variable. Interfaces that no longer exist on the system (and also interfaces that do not yet exist), have their "info" variable set to None - so an exception is raised when dereferencing it.
Wi-Fi interface:
Ethernet interface:
Fixed by making sure netdev_info does not raise if the dev.info variable is None. This is a valid use-case.
NOTE: The crash could occur very early - even when the user is still on the welcome screen - and for Wi-Fi or Ethernet interface (even if it is essentially unused).
During testing, I noticed that a crash would still occur if the network interface get disconnected while the user is on the network screen. The stacktrace is different and I will address it in a follow-on PR (possibly with a different LP).