network: fix crash upon accessing Help after creating a bond
When accessing the Help menu, Subiquity looks up the IP addresses currently configured - so it knows whether to show the "Help on SSH access" option. Unfortunately, it also looks for IP addresses on devices that were "configured" through the network screen but that still do not exist in the system. When such a device exist (e.g., a bond), the Subiquity client crashes with the following exception: Traceback (most recent call last): File "subiquity/common/api/server.py", line 164, in handler result = await implementation(**args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "subiquity/server/server.py", line 117, in ssh_info_GET ips.extend(map(str, dev.actual_global_ip_addresses)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "subiquitycore/models/network.py", line 394, in actual_global_ip_addresses for _, addr in sorted(self.info.addresses.items()) ^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'addresses' A similar crash is observed when calling /network/global_addresses after creating the bond. Fixed by only checking the IP addresses of devices that have a probert.network.Link instance (i.e., they exist in the system). Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
8e03050dbb
commit
dc26a1d252
|
@ -255,6 +255,8 @@ class NetworkController(BaseNetworkController, SubiquityController):
|
|||
async def global_addresses_GET(self) -> List[str]:
|
||||
ips: List[str] = []
|
||||
for dev in self.model.get_all_netdevs():
|
||||
if dev.info is None:
|
||||
continue
|
||||
ips.extend(map(str, dev.actual_global_ip_addresses))
|
||||
return ips
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ class MetaController:
|
|||
ips: List[str] = []
|
||||
if self.app.base_model.network:
|
||||
for dev in self.app.base_model.network.get_all_netdevs():
|
||||
if dev.info is None:
|
||||
continue
|
||||
ips.extend(map(str, dev.actual_global_ip_addresses))
|
||||
if not ips:
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue