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

network: fix crash when Wi-Fi or eth interface gets removed from the system #1789

Merged
merged 1 commit into from Sep 7, 2023

Conversation

ogayot
Copy link
Member

@ogayot ogayot commented Sep 7, 2023

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:

    File "subiquitycore/models/network.py", line 227, in netdev_info
      scan_state=self.info.wlan['scan_state'],
  AttributeError: 'NoneType' object has no attribute 'wlan'

Ethernet interface:

    File "subiquitycore/models/network.py", line 201, in netdev_info
      is_connected = bool(self.info.is_connected)
  AttributeError: 'NoneType' object has no attribute 'is_connected'

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).

…system

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:

    File "subiquitycore/models/network.py", line 227, in netdev_info
      scan_state=self.info.wlan['scan_state'],
  AttributeError: 'NoneType' object has no attribute 'wlan'

Ethernet interface:

    File "subiquitycore/models/network.py", line 201, in netdev_info
      is_connected = bool(self.info.is_connected)
  AttributeError: 'NoneType' object has no attribute 'is_connected'

Fixed by making sure netdev_info does not raise if the dev.info variable
is None. This is a valid use-case.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot merged commit 16688c5 into canonical:main Sep 7, 2023
11 checks passed
@ogayot ogayot deleted the netdev-deleted branch September 7, 2023 11:47
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