Skip to content

Commit

Permalink
Merge pull request #1454 from dbungert/kinetic-merge-2022-10-17
Browse files Browse the repository at this point in the history
Kinetic merge 2022-10-17
  • Loading branch information
dbungert authored Oct 17, 2022
2 parents 2df2f4e + b72e8c7 commit b852a5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ parts:
plugin: python
source-type: git
source: https://git.launchpad.net/curtin
source-commit: 47c222681c81110a185497a64749f23596e29b16
source-commit: 1fc717df52ec15f616d26fff3c10bff181599b30
build-packages:
- shared-mime-info
- zlib1g-dev
Expand Down
10 changes: 9 additions & 1 deletion subiquity/server/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
import os
import shutil
import subprocess
import tempfile
from typing import List, Optional, Union

Expand All @@ -34,6 +35,10 @@
log = logging.getLogger('subiquity.server.apt')


class OverlayCleanupError(Exception):
""" Exception to raise when an overlay could not be cleaned up. """


class _MountBase:

def p(self, *args: str) -> str:
Expand Down Expand Up @@ -245,7 +250,10 @@ async def overlay(self):
# Mountpoint object and (thanks to attr.s) make sure that it
# compares equal to the one we discarded earlier.
# But really, there should be better ways to handle this.
await self.unmount(Mountpoint(mountpoint=overlay.mountpoint))
try:
await self.unmount(Mountpoint(mountpoint=overlay.mountpoint))
except subprocess.CalledProcessError as exc:
raise OverlayCleanupError from exc

async def cleanup(self):
for m in reversed(self._mounts):
Expand Down
24 changes: 14 additions & 10 deletions subiquity/server/controllers/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from subiquity.common.apidef import API
from subiquity.common.types import DriversPayload, DriversResponse
from subiquity.server.apt import OverlayCleanupError
from subiquity.server.controller import SubiquityController
from subiquity.server.types import InstallerChannels
from subiquity.server.ubuntu_drivers import (
Expand Down Expand Up @@ -83,16 +84,19 @@ async def _list_drivers(self, context):
await self.configured()
return
apt = self.app.controllers.Mirror.apt_configurer
async with apt.overlay() as d:
try:
# Make sure ubuntu-drivers is available.
await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint)
except CommandNotFoundError:
self.drivers = []
else:
self.drivers = await self.ubuntu_drivers.list_drivers(
root_dir=d.mountpoint,
context=context)
try:
async with apt.overlay() as d:
try:
# Make sure ubuntu-drivers is available.
await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint)
except CommandNotFoundError:
self.drivers = []
else:
self.drivers = await self.ubuntu_drivers.list_drivers(
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)
if not self.drivers:
await self.configured()
Expand Down

0 comments on commit b852a5d

Please sign in to comment.