Commit Graph

5652 Commits

Author SHA1 Message Date
Olivier Gayot ac98851b7c mirror: fix types hints in mirror screen
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-31 09:28:11 +01:00
Michael Hudson-Doyle 845e3971f7
Merge pull request #1542 from ogayot/with-pkgresources
snapcraft: add pkg_resources to the snap
2023-01-30 10:51:59 +13:00
Olivier Gayot 85af81718e snapcraft: add pkg_resources to the snap
From subiquity, we sometimes execute entry point python scripts such as:

 * usr/bin/ubuntu-advantage
 * usr/bin/ssh-import-id

Those scripts require pkg_resources on core20 to run properly:

  from pkg_resources import load_entry_point

On core22, the scripts will be a bit more flexible but for now, we need
python3-pkg-resources in the snap.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-27 10:43:56 +01:00
Olivier Gayot 32afc4b515
Merge pull request #1528 from ogayot/enable-pro
ubuntu-pro: enable for LTS releases
2023-01-27 10:02:11 +01:00
Olivier Gayot 1fa3679008
Merge pull request #1537 from ogayot/apt-work
Test the applied apt configuration (mirror testing)
2023-01-26 09:08:08 +01:00
Dan Bungert d9e9cf3ddd
Merge pull request #1540 from dbungert/make-view-request-fix
autoinstall: adjust x-make-view-request behavior
2023-01-24 17:08:53 -07:00
Dan Bungert cf63f2bf8e test/api: also check x-status 2023-01-24 16:54:18 -07:00
Dan Bungert ec38ae9120 test/api: example of x-make-view-request 2023-01-24 16:06:37 -07:00
Dan Bungert bf6f09efa8 server: adjust x-make-view-request
With autoinstall, a controller that was not interactive would decline
outright to provide the response to GET queries, with the notion that
the controller needed to be skipped.  Limit this behavior to only when
`x-make-view-request: yes` is set, which let's the client be able to get
the real response, or the skip info, depending on need.
2023-01-24 14:58:49 -07:00
Dan Bungert 7945c96a39
Merge pull request #1539 from dbungert/string-tweak
ui/guided: TPM string tweaks
2023-01-24 11:14:49 -07:00
Dan Bungert 0ae4585658 ui/guided: TPM string tweaks
LP: #1999117
2023-01-24 10:33:20 -07:00
Olivier Gayot bf61192f7c mirror: don't handle mirror check retries differently
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 70b90612d1 mirror: use run_bg_task instead of storing references to tasks
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot b0ced5afb0 async: add helper to run fire-and-forget tasks
calling asyncio.create_task(...) without storing a reference to the
result can lead to the task being garbage collected before it actually
executed.

https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task

The documentation gives an example of a reliable way to run
fire-and-forget background tasks.

This patch adds an helper to do exactly that.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 082e5d9f18 apt: retrieve list of index targets using apt_pkg
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot ab3d9be4c7 mirror: do not run mirror testing if network is not configured
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 3824734916 network: add network/has_network endpoint to check if we have network
Many views provide a different display based on whether the network is
available. Up to now, it was up to the controller corresponding to the
view to return the value of has_network.

We now have a dedicated /network/has_network endpoint that clients can
lean on.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 35db182e89 mirror: run mirror testing in autoinstall
For autoinstalls, we now perform mirror testing as well. Unlike in
interactive mode, if the mirror check fails, we wait 10 seconds and try
again. Only if the second check fails, we give up.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 707805691f mirror: run answers, wait for check to complete
For answers-based runs, we now wait for the mirror check to be complete
before submitting the form. This ensures that we don't get a
confirmation dialog if the check is successful.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 02c4eb59ff mirror: honor scale factor when fetching mirror check progress
From the mirror view, we used to call /mirror/check_mirror/progress
every second, we can now check more often according to the value of
SUBIQUITY_REPLAY_TIMESCALE.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot c49d93d988 mirror: fix displayed text in confirmation dialogs
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot d6c677552d mirror: use ask_confirmation and add dialog if mirror check has not started
For dialogs asking the user if they want to continue anyway (e.g., the
mirror check is still running or has failed), we now lean on
BaseView.ask_confirmation.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 3896ebbdde mirror: add different dry-run mechanisms for mirror checks
In dry-run mode, we can now define rules to control if the mirror check
should:

 * succeed (the output of APT is faked)
 * fail (the output of APT is faked)
 * randomly succeed or fail (the output of APT is faked)
 * run on the host (this will effectively bypass the apt parameters
   supplied)

The default rules are as follows:
 * https://archive.ubuntu.com/ubuntu will succeed
 * https://<country-code>.archive.ubuntu.com/ubuntu will succeed
 * any URL that ends in /success will succeed
 * any URL that ends in /fail or /failed will fail
 * any URL that ends in /rand or /random will randomly succeed or fail
 * any URL that ends in /host will run on the host (bypassing the URL
   configured)
 * anything else with run on the host

Different rules can be provided by supplying a --dry-run-config YAML
file.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 0d24ce3fc2 mirror: only check again if URL is different
Make sure the client only checks the mirror again if the provided URL is
different.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot c8fd3e40c2 mirror: allow to cancel ongoing check when starting a new one
Before, doing a POST request to /mirror/check_mirror/start when a mirror
test was already running resulted in an exception on the server side.

We now have a parameter to control whether any ongoing check should be
cancelled first.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot d18ebd826a mirror: add mirror URL in response to progress
The /mirror/check_mirror/progress endpoint now returns the URL of the
mirror being tested. This helps in the client side tofigure out if we
already have a check running for a given URL.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 3ed0156df4 mirror: only donwload index file for mirror testing
On slow connections, running a full apt-get update for the sole purpose
of mirror testing ; and discarding the result is a bad thing to do.

This can take minutes and consume over 50 MiB.

Instead, we use mwhudson's approach and only download the index files.
Instructing apt to do so is a bit clunky but it seems to be worth the
effort.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 9ab4b6e79f mirror: always show the box with the APT output
With the previous implementation, the box containing the APT output was
only shown when the test was in progress or failed. It seems simpler to
just display it at all times, so that warnings from APT can be noticed.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Michael Hudson-Doyle cbdb44b3f4 mirror: implement client side of mirror checking
[ Olivier Gayot ]

add glue to mwhudson's patch to make it work with current impl

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 5177a6a8f6 mirror: add new endpoint to submit mirror without marking configured
The POST handler for /mirror applies the URL passed but also marks the
model configured. That said, we want the ability to:

 1. supply a mirror URL
 2. run the mirror test
 3. mark the model configured if the test is successful

This patches creates a new endpoint: /mirror/candidate that does the
same as /mirror except that it does not mark the model configured.

It is therefore suitable for step 1.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:23 +01:00
Olivier Gayot 86fb20ec04 mirror: add API to run mirror checking
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-24 12:50:15 +01:00
Olivier Gayot 3dd648238b
Merge pull request #1538 from ogayot/warn-warning
logging: replace deprecated calls to log.warn by log.warning
2023-01-24 12:46:51 +01:00
Olivier Gayot 4d6e1340ad logging: replace deprecated calls to log.warn by log.warning
Since Python 3.3, log.warn has been deprecated in favor of log.warning.
Running the unit tests raises the following warning:

subiquity/server/tests/test_geoip.py::TestGeoIPBadData::test_lookup_error
  /home/olivier/dev/canonical/subiquity/subiquity/server/geoip.py:112:
DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    log.warn("geoip lookup failed: %r", le)

I replaced all the calls to log.warn by calls to log.warning

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 16:25:12 +01:00
Olivier Gayot fd9e4ace47 apt: create the partial directory before running apt-get update
apt-get complains if the var/lib/apt/lists/partial directory does not
exist or is not owned by the _apt user. Make sure that it is.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:52:48 +01:00
Olivier Gayot 0451c9de3b apt: allow to store output of apt config check
When running the apt config check, we can now pass a stream that will be
populated with the output of apt-get update (stdout + stderr combined).

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:51:51 +01:00
Olivier Gayot ed96088130 apt: add function to test currently applied apt configuration
The AptConfigurer object now has a method that runs apt-get update on
the applied configuration and returns the result Strictly speaking, it
does more than just checking if the mirror is in a good shape, thus the
naming shows "apt config" rather than "apt mirror".

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:49:35 +01:00
Olivier Gayot 8c29f34754 mirror: detach primary section from config object
Going forward, we need the mirror model to keep the data that it can
handle separately from what goes straight to curtin. This patch
separates the primary section from the config blob.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:49:14 +01:00
Olivier Gayot c13edb07f8 mirror: detach disabled-components from config
Going forward, we need the mirror model to the data that it can handle
separately from what goes straight to curtin. This patch separates the
disabled-components from the config blob.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:47:22 +01:00
Olivier Gayot 1decdffd75 mirror: add function to add country code to URI
Instead of transforming on the fly the archive URL into the country mirror URL
using string substitutions, we can now use the countrify_uri function that does
the job and has unit tests.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:44:23 +01:00
Olivier Gayot 927882c642 apt: make apt-configure tests not rely on DEFAULT
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:44:23 +01:00
Olivier Gayot 9b6405adc8 mounter: remove conflicting instructions about sources.list.d
In dry-run mode, when generating the fake overlay for apt, we copy the
content of /etc/apt from the host to the temporary directory.
For some reason, we then removed the sources.list.d directory in the
destination.

When I noticed the absence of sources.list.d in the fake overlay, I
added another call to cp(1) to get it populated. However, a more
sensible thing to do is to get rid of the instruction that removed
sources.list.d.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-20 10:44:23 +01:00
Dan Bungert c6564de0dc
Merge pull request #1535 from dbungert/no-except-on-geoip-failure
geoip: do not raise on geoip failure
2023-01-18 11:26:47 -07:00
Dan Bungert 11d89ec0b9 geoip: do not raise on geoip failure
This is non-fatal, and users find the Traceback confusing.

Sample log statement:
  2023-01-17 18:18:19,958 DEBUG subiquity.server.geoip:113 geoip lookup
  failed: ClientConnectorError(ConnectionKey(host='lmao', port=443,
  is_ssl=True, ssl=None, proxy=None, proxy_auth=None,
  proxy_headers_hash=None), gaierror(-5, 'No address associated with
  hostname'))
2023-01-18 11:02:03 -07:00
Carlos Nihelton d3099728ea
Merge pull request #1534 from CarlosNihelton/fix-none-wslsetupoptions
Fix wslsetupotions being None
2023-01-13 06:56:14 -03:00
Olivier Gayot 9aeb3d2bb3
Merge pull request #1531 from ogayot/fix-discarded-passphrase
storage: fix creation of encrypted VG in manual partitioning
2023-01-13 09:15:34 +01:00
Carlos Nihelton 41a2427704
Fix wslsetupotions being None
Recent changes in GUI turned possible to have that field as None,
leading to a crash.
This avoids the crash while preserving the default behavior of
installing the language packs.
2023-01-12 16:57:52 -03:00
Olivier Gayot 9612a7eafc storage: use "passphrase" for LVM/LUKS in the server
The client expected the LUKS passphrase to be called "passphrase" but
the server expected it to be called "password".

To keep the implementation consistent, we now use "passphrase"
everywhere except in the API (i.e., storage/guided and
storage/v2/guided) where "password" is still used for backward
compatibility reasons.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-01-12 10:21:56 +01:00
Olivier Gayot 8cb6318456
Merge pull request #1533 from ogayot/apt-dry-run-copy-sources.list.d
apt: in dry-run code, also copy etc/apt/sources.list.d
2023-01-12 09:20:38 +01:00
Michael Hudson-Doyle dd45be1457
Merge pull request #1526 from mwhudson/show-encryption-unavailable-reason
show the FDE "unavailable-reason" from snapd to the user
2023-01-12 15:17:37 +13:00
Michael Hudson-Doyle ef371a652b address review comments 2023-01-12 14:10:29 +13:00