Commit Graph

5475 Commits

Author SHA1 Message Date
Michael Hudson-Doyle b57139de9c the publisher is not returned by the API for a unasserted snap 2022-10-05 15:29:52 +13:00
Michael Hudson-Doyle faf78a1be1 Revert "Merge pull request #1442 from mwhudson/main"
This reverts commit cc33a668a2, reversing
changes made to f219cd717e.
2022-10-05 15:28:39 +13:00
Michael Hudson-Doyle f5dd2ec01f
Merge pull request #1431 from mwhudson/cleaner-cdrom-cleanup
remove special cases around mounting/unmounting /target/cdrom
2022-10-05 15:01:59 +13:00
Michael Hudson-Doyle cc33a668a2
Merge pull request #1442 from mwhudson/main
Revert "Merge pull request #1435 from mwhudson/snapdapi"
2022-10-05 14:47:58 +13:00
Michael Hudson-Doyle 1a68b4759c Revert "Merge pull request #1435 from mwhudson/snapdapi"
This reverts commit f219cd717e, reversing
changes made to 7fe070dec3.
2022-10-05 14:37:34 +13:00
Michael Hudson-Doyle f219cd717e
Merge pull request #1435 from mwhudson/snapdapi
create and use a more richly typed snapd api
2022-10-05 14:14:23 +13:00
Michael Hudson-Doyle 7fe070dec3
Merge pull request #1440 from mwhudson/small-serialization-tweaks
small serialization and api tweaks
2022-10-05 13:53:18 +13:00
Olivier Gayot 9232561393
Merge pull request #1433 from ogayot/LP1989977-extended-partition-no-size
filesystem: accept extended partition with size -1 in autoinstall
2022-10-04 10:39:50 +02:00
Olivier Gayot 73d9ecd1be filesystem: fix logical part. using gap outside extended
When defining a partition with size: -1, the partition should expand to
the size of the largest gap. To determine which gap to use, we call the
function largest_gap(partition.disk).

That being said, the gap returned is sometimes bigger than expected when
using a msdos partition table. This happens because we return the
largest gap without checking if it is inside or outside the extended
partition.

Fixed by making sure that:

* for a logical partition, we pick the largest gap within the extended
  partition
* for a primary partition, we pick the largest gap outside the extended
  partition (if any).

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-10-04 09:39:12 +02:00
Olivier Gayot 45a00c0864 gaps: mark ptable as dos for tests with extended partitions
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-10-04 09:39:12 +02:00
Olivier Gayot 721d6bae67 filesystem: accept extended partition with size -1 in autoinstall
Our documentation of autoinstall mentions that one can specify the size
of a partition as -1 to use the remaining space on the disk.

Because it only makes sense in practice to support this option for the
right-most partition of a given disk, specifying size: -1 is only
accepted when defining the last partition of the disk.

Having said that, when making an autoinstall configuration that includes
an extended partition, the user must define the logical partitions after
the extended partition.

For the following configuration:

|                                  disk                                |
+--------------+--------------+--------------+-------------------------|
| p1 (primary) | p2 (primary) | p3 (primary) | p4 (extended)           |
|              |              |              | p5 (logic) | p6 (logic) |

, the representation in Subiquity will be analogous to:

[
  Partition(p1, "primary"),
  Partition(p2, "primary"),
  Partition(p3, "primary"),
  Partition(p4, "extended"),
  Partition(p5, "logical"),
  Partition(p6, "logical"),
]

This means that specifying size: -1 on p4 gets rejected because it is
not the last partition defined.p6 is the last partition defined.

This is however a valid use-case because p5 and p6 are contained within
p4. So p4 should be able to use the remaining space and there is no
reason to reject this configuration

Fixed by ignoring logical partitions when checking if a size of -1 is
allowed on an extended partition.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-10-04 09:39:12 +02:00
Michael Hudson-Doyle 90bc1eab98 use rich snapd api in refresh code 2022-10-04 16:18:22 +13:00
Michael Hudson-Doyle 750db28f19 Add a way to talk to snapd using a richly typed API 2022-10-04 16:16:04 +13:00
Michael Hudson-Doyle 521e7026de tweak AsyncSnapd api slightly
also remove dry-run delay for requests to /v2/change/{id}
2022-10-04 16:15:19 +13:00
Michael Hudson-Doyle 97c276faca Support typing.Any as a seralization annotation 2022-10-04 16:01:06 +13:00
Michael Hudson-Doyle ff8bb0c8ba APIs that do not serialize query args can have rich payloads of course 2022-10-04 16:00:22 +13:00
Olivier Gayot d5182af065
Merge pull request #1421 from ogayot/kvm-test-cloud-config
kvm-test: allow to specify a cloud-init file not meant for autoinstall
2022-09-29 14:31:47 +02:00
Dan Bungert ea9732fcc0
Merge pull request #1438 from dbungert/revert-fs-id-uglification
Revert "filesystem: part ids are not part nums"
2022-09-28 15:25:44 -06:00
Dan Bungert 9fb1b32e1d
Merge pull request #1436 from dbungert/runtests-exit-message
runtests: ensure message shown at end
2022-09-28 15:18:54 -06:00
Dan Bungert bd79c1d0a7 Revert "filesystem: part ids are not part nums"
This reverts commit 5fcd6776c1.
2022-09-28 13:36:44 -06:00
Dan Bungert 2928ab88ce runtests: ensure message shown at end
The second `trap ... EXIT` registration meant that the first one, the
one repsonsible for providing a clear PASS / FAIL at the end, was not
being shown.
2022-09-28 10:02:04 -06:00
Carlos Nihelton a434bdd311
Merge pull request #1434 from EduardGomezEscandell/fix-wsl-snap-version-bug
Fix unset SNAP_VERSION in WSL
2022-09-27 09:46:23 -03:00
Edu Gómez Escandell b939b0e552 Fix 2022-09-27 14:13:36 +02:00
Olivier Gayot b59141304e
Merge pull request #1430 from ogayot/LP#1987341
reserved-usernames: add groups created by udev (src:systemd)
2022-09-27 14:05:45 +02:00
Olivier Gayot d4f76d1ce8
Merge pull request #1426 from ogayot/fix-snaplist
Make snaplist more robust to races and fix snap info prefetch
2022-09-22 15:18:31 +02:00
Olivier Gayot 15151675d6 snaplist: fix cancellation of loader preventing retry
The SingleInstanceTask does not allow us to control cancellation the way
we want. We now use a standard asyncio.Task to execute the coroutine
that fetches the list of snaps.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 15:02:18 +02:00
Olivier Gayot 507b025059 snaplist: make list snap task raise on error
The list snaps task used to return successfully even in case of error.

To make the distinction between and error and a successful fetch, we
used to rely on the task to set an attribute at the loader level:
 * failed = True; or
 * failed = False

The task was responsible for setting this attribute and there were
scenarios where it would not set the attribute properly. Usually, this
was when an exception was raised in the task.

We now raise an exception when an error occurs in the task ; instead of
returning. This is better because we can know if the task:
 * got cancelled - by calling "task.cancelled()"
 * finished successfully - by calling "task.done() and not
   task.exception()"
 * failed - by calling "task.done() and task.exception()"
 * has not finished - by calling "not task.done()"

This also allows us to detect errors and retry

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 15:02:18 +02:00
Olivier Gayot beb2d46d3f snaplist: prefetch snaps info after list of snaps is retrieved
Once we have access to the list of snaps, we can start prefetching
information. We need to wait for the list snaps task to be completed
first.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 15:02:18 +02:00
Olivier Gayot d770b37859
Merge pull request #1432 from mwhudson/serialize-date-argh
fix deserializing date fields
2022-09-22 14:41:47 +02:00
Michael Hudson-Doyle fa8bc2f7f1 fix deserializing date fields 2022-09-22 14:30:52 +02:00
Olivier Gayot 62a2f3104c kvm-test: allow to specify a cloud-init file not meant for autoinstall
The --cloud-config option now replaces the old --autoinstall-file
option.

The use of --autoinstall-file always made kvm-test pass the autoinstall
argument to the kernel command line. With the --cloud-config option, we
now determine if the autoinstall argument is needed by reading the cloud
config and checking if an autoinstall section is present.

The two new options --force-autoinstall and --force-no-autoinstall can
be used to override this behaviour.

The --autoinstall option is also dropped. If we want to use the default,
hardcoded cloud-config, one can use --cloud-config-default.

This can be useful to ease debugging of the VM using a config that looks
like:

    #cloud-config
    users:
        - default
        - name: root
          ssh_import_id: lp:ogayot

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 13:09:59 +02:00
Olivier Gayot aff9ed0a7c reserved-usernames: add sgx group ahead of ubuntu
sgx is not yet in reserved-usernames in Ubuntu but I submitted a
.debdiff to get it added:

https://bugs.launchpad.net/ubuntu/+source/user-setup/+bug/1990488

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 11:09:30 +02:00
Olivier Gayot dea6cea4ef reserved-usernames: refresh local copy using upstream
Refresh the reserved-usernames local copy using:

https://git.launchpad.net/ubuntu/+source/user-setup/plain/reserved-usernames

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 11:08:50 +02:00
Olivier Gayot b45f47acf2 reserved-usernames: build using latest version from user-setup.git
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 11:07:10 +02:00
Michael Hudson-Doyle 9f32abd8f4 remove special cases around mounting/unmounting /target/cdrom 2022-09-22 13:54:03 +12:00
Michael Hudson-Doyle 3a95193905
Merge pull request #1423 from mwhudson/serialization-enhancements
serialization enhancements in preparation for talking to snapd api
2022-09-22 12:07:05 +12:00
Carlos Nihelton ef5984b1be
Merge pull request #1427 from CarlosNihelton/2stage-snap-wsl-87
[WSL] Two stage snap launching
2022-09-21 21:05:29 -03:00
Dan Bungert e16f81293c
Merge pull request #1428 from dbungert/lp-1989353-ai-vs-kernel
kernel: fix autoinstall and run file
2022-09-21 07:51:24 -06:00
Carlos Nihelton 09bc1b7386
Ensures this script only runs in WSL
To prevent issues with desktop or server.
2022-09-21 09:26:13 -03:00
Michael Hudson-Doyle c063717897
Merge pull request #1424 from mwhudson/api-enhancements
api extensions needed to talk to snapd API
2022-09-21 14:24:25 +12:00
Dan Bungert 884f29627c kernel: fix autoinstall and run file 2022-09-20 08:43:08 -06:00
Dan Bungert 5c636acc30
Merge pull request #1429 from ogayot/LP#1990239
cdrom: make sure we unmount the cdrom only once
2022-09-20 08:39:29 -06:00
Carlos Nihelton 0ad27c2052
Merge pull request #1422 from CarlosNihelton/fix-wrong-parameters-loaded
[WSL] Fixes wrong parameters being passed to init WslSetupOptions
2022-09-20 08:59:02 -03:00
Olivier Gayot 474491567a
Merge pull request #1419 from ogayot/LP#1980584
mirror: only start configuring APT once source & mirror are configured
2022-09-20 11:33:30 +02:00
Olivier Gayot 74cad94efa
Merge pull request #1425 from ogayot/fix-try-again-not-waiting
snaplist: do not automatically mark configured on failed GET request
2022-09-20 11:32:26 +02:00
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