drivers: do not consider overlay cleanup error fatal

For some reason that we have not yet determined, the overlay that we use
for the drivers code sometimes fails to unmount with EBUSY.

When it happens, the _list_drivers task would fail, making subsequent
GET calls to /drivers?wait=true fail as well and produce an error
report.

We now mark failures in the overlay unmount operation as non fatal.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-10-17 12:27:32 +02:00
parent aae52dd6ba
commit 6954b309e6
1 changed files with 14 additions and 10 deletions

View File

@ -21,6 +21,7 @@ from subiquitycore.context import with_context
from subiquity.common.apidef import API from subiquity.common.apidef import API
from subiquity.common.types import DriversPayload, DriversResponse from subiquity.common.types import DriversPayload, DriversResponse
from subiquity.server.apt import OverlayCleanupError
from subiquity.server.controller import SubiquityController from subiquity.server.controller import SubiquityController
from subiquity.server.types import InstallerChannels from subiquity.server.types import InstallerChannels
from subiquity.server.ubuntu_drivers import ( from subiquity.server.ubuntu_drivers import (
@ -83,16 +84,19 @@ class DriversController(SubiquityController):
await self.configured() await self.configured()
return return
apt = self.app.controllers.Mirror.apt_configurer apt = self.app.controllers.Mirror.apt_configurer
async with apt.overlay() as d: try:
try: async with apt.overlay() as d:
# Make sure ubuntu-drivers is available. try:
await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint) # Make sure ubuntu-drivers is available.
except CommandNotFoundError: await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint)
self.drivers = [] except CommandNotFoundError:
else: self.drivers = []
self.drivers = await self.ubuntu_drivers.list_drivers( else:
root_dir=d.mountpoint, self.drivers = await self.ubuntu_drivers.list_drivers(
context=context) root_dir=d.mountpoint,
context=context)
except OverlayCleanupError:
log.exception("Failed to cleanup overlay. Continuing anyway.")
log.debug("Available drivers to install: %s", self.drivers) log.debug("Available drivers to install: %s", self.drivers)
if not self.drivers: if not self.drivers:
await self.configured() await self.configured()