Commit Graph

5380 Commits

Author SHA1 Message Date
Olivier Gayot 5f1f2ec431 cdrom: make sure we unmount the cdrom only once
Until recently, subiquity and curtin had shared ownership regarding
mounting/unmounting the cdrom to/from the target:

 * curtin was responsible for bind-mounting /cdrom to /target/cdrom
 * subiquity was responsible for unmounting /target/cdrom

We recently made subiquity responsible for bind-mounting the cdrom to
the target too, which is a good thing.

Unfortunately, we now attempt to unmount the cdrom from the target
twice, at the end of the installation:

 * once because we explicitly unmount the cdrom from the target before
   restoring the APT config on target
 * once because subiquity has a mechanism that automatically unmount
   everything that it mounted, in reverse order.

This leads to a crash at the end of the installation.

Fix this issue by making sure we only try to unmount the cdrom once. If
we unmount it before restoring the APT config, then we don't want to
unmount it automatically anymore.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-20 11:22:03 +02:00
Olivier Gayot 505318625e
Merge pull request #1418 from ogayot/LP#1988407
filesystem: fix crash when editing LVM logical volume
2022-09-20 10:04:34 +02:00
Michael Hudson-Doyle 3a55816ee1 rewrite serialization to make path tracking and errors cleaner 2022-09-20 14:11:21 +12:00
Carlos Nihelton 5331268600
Adds the added script to the snap
Following the same path and naming conventions as UDI.
That allows for reuse of the existing snap mounting/bootstrapping
approach.
2022-09-19 14:41:24 -03:00
Carlos Nihelton c0c4b3c7fe
Adds a bootstrapping script for WSL
Where we don't have a proper snapd support.
Approach similar to the one used in UDI.
For the case where we have Subiquity snap, but not UDI.
The script added is a stripped version of the UDI one.

Removed code related to:
 - GTK and GDK;
 - GI repository;
 - Xkb;

 Preserved:
 - Python;
 - XDG directory definitions;
 - font config;
2022-09-19 14:39:39 -03:00
Michael Hudson-Doyle a16f75b2b8 extend TestEndToEnd.test_defaults a bit 2022-09-19 14:56:54 +12:00
Olivier Gayot 83a7aff316 snaplist: do not automatically mark configured on failed GET request
When a client sends a GET /snaplist request and an error occurs on the
server side, we return a response of the following form:

 { "status": "FAILED", ... }

This effectively gives a chance to the client to retry the same request
and expect a different outcome (for instance when a temporary network
failure occurs).

Having said that, when the server returns "status": "FAILED", it also
automatically marks the snaplist model configured. This is wrong because
if the next GET /snaplist request succeeds, the user will be prompted to
select some snaps to install ; but the installation will already be
running in the background. Depending on the timing, it might or might
not install the snaps that the user selected.

Fixed by not marking the snaplist model configured automatically. The
client is made responsible from sending a POST /snaplist ; even in case
of error.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-16 15:46:28 +02:00
Michael Hudson-Doyle 6262d5cfbd subiquity.common.api: allow parts of the path to an API to be parameters
I've wanted to do this for ages and getting ready to talk to the snapd
API provided an excuse :-) (as, for example, to get info about a snap
you talk to the /v2/snaps/{snap_name} endpoint). As before, the server
part isn't strictly needed but I forgot about that and actually
implemented it first. Oh well, we'll need it if I implement my idea
described in a comment in apidef.py to make the network API more RESTish.
2022-09-16 17:25:21 +12:00
Michael Hudson-Doyle 63d52705bf subiquity.common.api: have make_client return an instance
I don't really remember why I didn't do it this way to start with, to be
honest.
2022-09-16 17:25:21 +12:00
Michael Hudson-Doyle ee674c0ed2 subiquity.common.api: add a way to not serialize query arguments
The snapd API does not JSON-encode query arguments, they are just all
strings. I only need the client side of this really but implementing it
server side might avoid confusion down the road.
2022-09-16 17:25:21 +12:00
Michael Hudson-Doyle 4b6e34454b subiquity.common.serialize: test that a certain style of embedding works
Some snapd APIs do this sort of thing. It works fine without code
changes, luckily.
2022-09-16 16:37:18 +12:00
Michael Hudson-Doyle 64acb295c9 subiquity.common.serialize: allow serializing enums by value
Similarly to field names, the snapd API returns objects with values that
should be part of an enumeration, but with values that are not all
Python identifiers (e.g. "system-seed"). To allow these to be mapped to
enum's in Python that are not insanely annoying to use, allow a
Serializer to serialize enum's to and from their values rather than
their names (which remains the default behaviour).
2022-09-16 16:31:35 +12:00
Michael Hudson-Doyle 0d17c2e135 subiquity.common.seralize: allow overriding field names
Many snapd APIs return JSON objects with field names that are not valid
Python identifiers (such as "display-name") so if we're going to
translate them to and from Python objects we need to be able to override
the field name in the serialized form.
2022-09-16 16:21:34 +12:00
Michael Hudson-Doyle 5e64fe1ca1 subiquity.common.serialize: allow ignoring unknown fields
Some snapd APIs return JSON objects with lots and lots of fields and I
don't want to have to declare the ones I am not interested in. Also, I
think snapd adds fields over time, so I don't want to be broken when
this happens.
2022-09-16 16:17:26 +12:00
Carlos Nihelton 2a598a8b5d
[WSL] Fixes wrong paramters being passed ...
to the WSLSetupOptions controller.

Misuse of the default_loader().
That's meant for loading /etc/wsl.conf.
WSLSetupOptions is by design not related to that config file.
2022-09-15 17:12:03 -03:00
Carlos Nihelton a04d93451b
Exercises the crash with an API test.
Required changes to make default_loader testable.
2022-09-15 17:12:03 -03:00
Carlos Nihelton b4734ad587
Makes the default_loader for wsl.conf testable 2022-09-15 16:24:18 -03:00
Michael Hudson-Doyle 60d6746a41
Merge pull request #1417 from mwhudson/install-step-refactor
refactor CurtinInstallStep a bit
2022-09-15 08:44:22 +12:00
Olivier Gayot ecb6cb6399 filesystem: fix crash when editing LVM logical volume
When editing a LVM logical volume (LV), Subiquity would crash with the
following error:

filesystem/gaps.py", line 244, in movable_trailing_partitions_and_gap_size
    pgs = parts_and_gaps(partition.device)
AttributeError: 'LVM_LogicalVolume' object has no attribute 'device'

When we changed the implementation to use
movable_trailing_partitions_and_gap_size, we did not pay attention to
the LVM use case.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-14 19:12:53 +02:00
Olivier Gayot b9f9aee399 mirror: only start configuring APT once source & mirror are configured
The mirror controller is responsible from creating the APT configuration
once its associated model is marked configured. However, the APT
configuration is also dependent on the source model being marked
configured.

When subiquity is used for the server installer, the client immediately
sends a POST /a/meta/client_variant request. This ends up marking the
source model as configured (even though the default value does not make
much sense). So we never end up in a scenario where the mirror model is
marked configured before the source model.

When Subiquity is used by a different client, such as the
ubuntu-desktop-installer, it is possible that we mark the mirror model
configured first. This ends up crashing the installer.

Fixed by adding a dependency on the source model so that we do not end
up creating the APT configuration too early.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-14 17:28:40 +02:00
Michael Hudson-Doyle 37500beaa1 lint 2022-09-14 22:55:55 +12:00
Michael Hudson-Doyle 7d716030b2 apply suggestion from review 2022-09-14 21:44:34 +12:00
Michael Hudson-Doyle 972c59a198 remove unused code 2022-09-14 21:14:17 +12:00
Michael Hudson-Doyle 6d724c0a5b use new flexibility to remove a bit of mystery code from SubiquityModel 2022-09-14 21:11:57 +12:00
Michael Hudson-Doyle c34f0a8bfa make CurtinInstallStep more self-contained 2022-09-14 12:01:00 +12:00
Carlos Nihelton 80869d23f2
Merge pull request #1416 from CarlosNihelton/fix-missing-common
Fix the missing `system_setup.common` error.
2022-09-13 16:18:18 -03:00
Carlos Nihelton 08d4c39387
Fix the missing `system_setup.common` error.
When Subiquity is packaged as its own snap, that subdirectory is not
present.
That is due the lack of an `__init__.py` file.
2022-09-13 15:56:37 -03:00
Olivier Gayot 3aee57f6d0
Merge pull request #1414 from ogayot/fix-ubuntu-pro-not-configured
ubuntu-pro: fixed model not being marked configured on LTS
2022-09-12 17:33:19 +02:00
Olivier Gayot ddddc4356d
Merge pull request #1413 from ogayot/LP#1986674
snaplist: avoid showing snaplist screen on failure
2022-09-12 17:32:41 +02:00
Olivier Gayot 8c7df86c29
Merge pull request #1411 from ogayot/FR-2404
keyboard: fix wrong keyboard layout in initramfs
2022-09-12 17:32:27 +02:00
Olivier Gayot dc272c512b ubuntu-pro: fixed model not being marked configured on LTS
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-12 14:46:18 +02:00
Olivier Gayot 3f47c469aa
Merge pull request #1408 from ogayot/ubuntu-pro-mypy
ubuntu-pro: fix type hints for contract selection callbacks
2022-09-12 11:40:16 +02:00
Olivier Gayot 0565e34552
Merge pull request #1412 from ogayot/snaplist-fix-try-again
snaplist: fix crash when pressing "Try again" on snaplist
2022-09-12 11:25:14 +02:00
Olivier Gayot 00801c3b68 keyboard: move setupcon to keyboard model
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-12 11:17:54 +02:00
Olivier Gayot dcb2420846 snaplist: avoid showing snaplist screen on failure
When creating the UI for snaplist, if the server returns a FAILED status
when we request the list of snaps, we want to move on to the next
screen.

However, calling self.next_screen in the make_ui function while also
returning an actual view triggers a race condition. Depending on the
order of execution of the instructions (which are asynchronous), the
snaplist view can end up being shown even though we moved to the next
screen. This ends up doing funny things upon clicking done.

Fixed by raising the Skip exception after making sure we mark snaplist
configured.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-09 15:11:19 +02:00
Olivier Gayot 3222a04fb4 snaplist: fix crash when pressing "Try again" on snaplist
When pressing the "Try again" button on the snaps list, Subiquity would
crash with:

TypeError: SnapListView.wait_load() takes 1 positional argument but 2
were given

This happens because urwid passes the sender to the callback - which we
need to discard or accept it in the signature.

Fixed by discarding the sender.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-09 10:51:04 +02:00
Olivier Gayot 870c99bcce keyboard: fix wrong keyboard layout in initramfs
During the installation, in the curthooks stage, curtin generates the
initramfs. Unfortunately, the generated initramfs did not honor the
keyboard mapping selected by the user during installation. Therefore,
when LUKS encryption is used for the root file-system, the prompt for
the passphrase ignores the keyboard layout set by the user.

To ensure that the initramfs uses the right keyboard layout, the
/etc/console-setup/cached_* files must be updated before the initramfs
gets created. At the beginning of the curthooks stage, we now call
setupcon --save-only in the target to refresh those files if needed.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-08 13:13:38 +02:00
Olivier Gayot 003127054f ubuntu-pro: don't use keyword arguments for callables
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-07 09:37:01 +02:00
Olivier Gayot da6dd3af41 ubuntu-pro: fix contract-selection callbacks signatures
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-07 09:36:56 +02:00
Dan Bungert 76b1faed1a
Merge pull request #1407 from dbungert/curtin-cryptsetup
snapcraft: rev curtin for cryptsetup fix
2022-09-06 18:48:34 -06:00
Dan Bungert 53a97f1156 snapcraft: rev curtin for cryptsetup fix 2022-09-06 18:02:11 -06:00
Dan Bungert e4a7f43658
Merge pull request #1406 from dbungert/lp-1983265-netplan-gateway
network: use routes instead of gateway directives
2022-09-06 17:35:20 -06:00
Dan Bungert 9e0a90fc22 network: use routes instead of gateway directives 2022-09-06 16:44:12 -06:00
Dan Bungert 9a651f57de
Merge pull request #1405 from CarlosNihelton/fix-api-test
Respects the output base dir on server.spawn() on API tests
2022-09-02 08:51:43 -06:00
Carlos Nihelton 73b9190a59
Respects the output base dir on server.spawn()
On API tests
2022-09-02 09:17:07 -03:00
Dan Bungert 3ec022f54b
Merge pull request #1404 from dbungert/fix-wipe
filesystem: restore previous wipe behavior
2022-09-01 15:26:12 -06:00
Dan Bungert 9aec674904 filesystem: restore previous wipe behavior 2022-09-01 15:12:57 -06:00
Dan Bungert 24ec78c670
Merge pull request #1359 from blackboxsw/cloud-init/validate-user-data-schema
subiquitymodel: validate merged cloud-config userdata_raw before reboot
2022-09-01 13:48:14 -06:00
Chad Smith 069f0c76a7 subiquity.controllers.userdata: validate autoinstall.user-data schema
Raise SchemaValidationError when any autoinstall.user-data config
is invalid cloud-init cloud-config schema.

If any deprecated config keys or values are provided under
autoinstall.user-data, log warnings about those deprecations.
2022-09-01 13:12:53 -06:00
Chad Smith 1e0291e5df subiquitymodel: validate merged cloud-config userdata_raw before reboot
Raise SchemaValidationErrors when invalid config is provided to
cloud-init as merged cloud-config for the installed target.

Log warnings if any deprecated cloud-config keys are present in
merged cloud-config.
2022-09-01 13:12:53 -06:00