Commit Graph

4585 Commits

Author SHA1 Message Date
Michael Hudson-Doyle 56ddf178e4
Merge pull request #1170 from ogayot/FR-1983
Fix hanging when network is the last postinst model configured
2022-01-21 10:25:54 +13:00
Dan Bungert f0907971ed
Merge pull request #1145 from dbungert/os-prober-snap
snapcraft: add os-prober
2022-01-20 12:34:09 -07:00
Dan Bungert 583659270c
Merge pull request #1168 from ogayot/use-fuse
Add --use-fuse switch to kvm-test --install so it can run as non-root
2022-01-20 10:21:59 -07:00
Dan Bungert c9f389d1ca
Merge pull request #1169 from mwhudson/configure_once-oops
initialize MirrorController.configure_once to False
2022-01-20 10:18:26 -07:00
Olivier Gayot 81bc59019c Remove --use-fuse switch and make it the default
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-20 12:01:44 +01:00
Olivier Gayot 37f286ac93 Fix hanging when network is the last postinst model configured
When running an autoinstallation with only “network” as an interactive
section, the installation hanged after the following steps:

  finalizing installation
    running 'curtin hook'
      curtin command hook
  executing late commands

where in normal conditions, the next step is:

  final system configuration

Also, querying the meta/status endpoint at this point shows that the app
is in POST_WAIT state.

The problem is:

the network model is declared as both an “install” model and a
“postinstall” model (it is the only one we have AFAIK)
when calling .configured() for a given model, we only trigger /at max/
one event. Either:
 * install_event (if the model is an “install” model - and it is the
   last one configured)
 * postinstall_event (if the model is a “postinstall” model but not an
   “install” model - and it is the last one configured)
 * no event (as in most cases)

So when we call .configured() for the network model, we /can/ trigger
the install_event but can never trigger the postinstall event.
Therefore Subiquity, will wait forever until something triggers the
postinstall_event

Fixed by accepting to trigger the install_event and the
postinstall_event in a single call to .configured.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-20 11:35:11 +01:00
Michael Hudson-Doyle 6c2a20663b initialize MirrorController.configure_once to False
oops :/
2022-01-20 16:24:25 +13:00
Olivier Gayot f1119b02a6 Add --use-fuse switch to kvm-test --install so it can run as non-root
Passing --use-fuse to scripts/kvm-test.py allows to run as non-root.

It requires installation of the package fuseiso so the switch is
disabled by default.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-19 10:10:33 +01:00
Dan Bungert efea0c5391
Merge pull request #1162 from ogayot/fix-obvious-typing-issues
Fix some typing issues reported by mypy, including potential crash when comparing snap versions
2022-01-18 18:19:17 -07:00
Michael Hudson-Doyle 96c8b51a2e
Merge pull request #1166 from dbungert/umount-hack
mirror: don't call apt cleanup
2022-01-19 14:11:21 +13:00
Dan Bungert 213928d0f9 mirror: don't call apt cleanup
* apt cleanup often fails due to the temporary apt instances still being
  around.  Skip the cleanup step, sadly, until that bug is addressed.
2022-01-18 17:21:57 -07:00
Carlos Nihelton 0d30deac7f
Promotes the "--no-checks" to outside of dry-run
Tests in real WSL2 environment revealed that update-locale checks fails but with the "--no-checks" option it updates the locale files accordingly and when the image restarts the locale is correctly set.
2022-01-18 10:18:45 -03:00
Carlos Nihelton a14a143d55 Fix l-s-c behavior under SNAP environment.
- By passing the datadir command line option.
2022-01-17 11:57:04 -03:00
Carlos Nihelton 957d56a52f FIx unbound variable in live run 2022-01-17 10:48:58 -03:00
Olivier Gayot f196db8cd1 Fix potential crash when comparing snap versions
When comparing two snap versions that meet the following conditions, a
TypeError was raised:

 * a.major == b.major
 * a.minor == b.minor
 * a.git_build_id is None and b.git_build_id is None

Fixed by first converting the git_build_id of both variables to a float
before comapring them.

Also added a unit-test to cover this scenario.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 14:06:01 +01:00
Olivier Gayot de19b3abee Add type hinting for controller base class attributes
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 13:02:44 +01:00
Olivier Gayot 3d3994f3f3 Fix return type of __recommended_languages_pack
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 13:02:25 +01:00
Olivier Gayot 2708ed21e5 Fix typing for ubuntu advantage services
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 13:02:12 +01:00
Olivier Gayot f294a49f0b Add self argument to non-static method
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-14 11:28:38 +01:00
Dan Bungert b312a24468
Merge pull request #1161 from dbungert/udi-fixes
Fix two bug reports from ubuntu-desktop-installer
2022-01-13 13:31:10 -07:00
Dan Bungert 7f3f928cfd apt: fix lowerdir handling
lowerdir is a str, not a list
2022-01-13 13:23:45 -07:00
Dan Bungert 94eab6fc84 mirror: add missing await 2022-01-13 13:22:20 -07:00
Dan Bungert 4a672e071e
Merge pull request #1158 from ogayot/bind-uac-into-subiquity-snap
Embed ubuntu-advantage-tools into Subiquity snap and use it
2022-01-13 13:01:03 -07:00
Dan Bungert 0a5c7f585a
Merge pull request #1157 from ogayot/ui-fixes-ua
Small improvements for Ubuntu Advantage dialogs
2022-01-13 12:40:35 -07:00
Dan Bungert 2fb74e5e03
Merge pull request #1160 from ogayot/fix-kvm-test-drive
Fix -drive option and -append option from kvm-test.sh
2022-01-13 12:40:17 -07:00
Olivier Gayot 82aeeecbc6 Fix kernel command line from kvm-test.sh
Since 06ac3f92, we invoke kvm directly through subprocess.run.
Therefore, we must not add extra quotes around the -append options,
otherwise they persist and are passed in the kernel command line:

  $ cat /proc/cmdline
  "autoinstall subiquity-channel=stable" initrd=initrd

Later on, we fail to parse "autoinstall" and "subiquity-channel=stable"
as two distinct options.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 12:33:50 -07:00
Olivier Gayot ed0e6861aa Fix -drive option from kvm-test.sh
The function drive() used to return a string in the following format:

  "-drive file=/path/to/iso,..."

However, qemu/kvm expects "-drive" to be an argument and
"file=/path/to/iso,..." to be another argument.

The command was constructed as below since the beginning:

  kvm = [
     "kvm",
     "-cdrom", "custom.iso",          # <- OK
     "-drive file=/path/to/iso,...",  # <- NOK
  ]

Before 06ac3f92, we would join all the arguments using spaces before
executing the kvm command. Therefore we would luckily end up with a
correct command:

  " ".join(kvm)  ->  "kvm -cdrom custom.iso -drive file=/path/to/iso,..."

However, now that we supply the command to subprocess.run directly, the
problem shows up.

Fixed by returning a tuple("-drive", "file=/path/to/iso,...") from
the drive() function.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 12:33:47 -07:00
Dan Bungert 79b0c41b65
Merge pull request #1159 from dbungert/kvm-test-ctd
kvm-test: proxy, livefs_edit, debug
2022-01-13 12:29:58 -07:00
Dan Bungert 3a696ca459
Update scripts/kvm-test.py
Co-authored-by: Olivier Gayot <duskcoder@gmail.com>
2022-01-13 12:25:12 -07:00
Dan Bungert aae3e420b0
Merge pull request #1156 from ogayot/FR-1746
Add support for APT preferences through autoinstall in Subiquity
2022-01-13 12:24:15 -07:00
Olivier Gayot 0cce67a87f Small improvements for Ubuntu Advantage dialogs
* select the relevant button by default when applicable
* make the list of services scroll properly
* add empty lines consistently
* mention that services can be enabled through `ua` (after installation)

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 16:08:59 +01:00
Olivier Gayot b03034887c Run ubuntu-advantage from the snap rather from the base ISO
The UAClientUAInterfaceStrategy can now optionally be initialized with
the path to the ubuntu-advantage entry point. Additionally, one can also
specify which Python interpreter should run it.

We leverage on this to force the use of:
 * the Python installation from the Subiquity snap
 * the ubuntu-advantage-tools integrated to the Subiquity snap

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 15:35:39 +01:00
Olivier Gayot 6e0c9821fe snapcraft: pickup curtin's support for apt_preferences
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-13 09:32:42 +01:00
Dan Bungert 98bf2943aa kvm-test: pep8 fixes 2022-01-12 14:56:58 -07:00
Dan Bungert e5e5d69a2d kvm-test: proxy, livefs_edit, debug
* add http_proxy recognition.  Picks up from DEBOOTSTRAP_PROXY.
* fix livefs_edit invocation
* include --debug in snap construction
2022-01-12 14:56:58 -07:00
Dan Bungert 7bdeb6707c os-prober: patch instead of sed 2022-01-12 13:33:07 -07:00
Dan Bungert 6bf9b8f734 snapcraft: rev probert for os-prober 2022-01-11 14:34:08 -07:00
Dan Bungert 05c8c70483 snapcraft: +os-prober 2022-01-11 14:34:08 -07:00
Olivier Gayot 9e7bc5053b Add support for APT preferences through autoinstall in Subiquity
The autoinstall schema for "apt" now supports the "preferences"
configuration. Each preference element should contain the properties
described below, that 1:1 map with the keywords from apt_preferences(5):

  * package      <-> Package:
  * pin          <-> Pin:
  * pin-priority <-> Pin-Priority:

These preferences are forwarded to curtin through
subiquity-curtin-apt.conf. Support for these rules must be added to
curtin as well.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-11 18:42:40 +01:00
Olivier Gayot 1995dd002a Add ubuntu-advantage-tools as stage-package
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-11 11:12:10 +01:00
Dan Bungert 5ae52c000b
Merge pull request #1151 from ogayot/FR-1652
Validate UA token & list available services
2022-01-10 10:02:41 -07:00
Dan Bungert 96a53eff14
Merge pull request #1154 from dbungert/autoinstall-disable-components
apt: fix disable_components w/ autoinstall
2022-01-10 09:45:49 -07:00
Dan Bungert 540049143d
Merge pull request #1146 from mwhudson/lp-1954848
do not accept probert results after user has submitted a filesystem config
2022-01-10 08:51:45 -07:00
Olivier Gayot f8704aa246 Merge branch 'main' into FR-1652
Resolve conflicts in PR 1151.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-10 10:53:51 +01:00
Dan Bungert 3d10a71d3c
Merge pull request #1153 from ogayot/ua-with-autoinstall
Add support for ubuntu-advantage with autoinstall
2022-01-07 15:27:41 -07:00
Dan Bungert 2a37cf5efb
Merge pull request #1155 from ogayot/fix-run-tests
Fix language packs detection in integration tests
2022-01-07 15:26:42 -07:00
Olivier Gayot 1a079ecddd Fix extraction of default locale when running integration tests
When running integration tests, the LANG variable in
.subiquity/etc/default/locale is unquoted. The pattern that we use
expects quotes so it does not match.

Fixed by making the test work with or without quotes.

In case quotes are not present, the final part of the pipeline will fail
to find a delimiter so it will print the line unchanged

excerpt from cut(1)

   -f, --fields=LIST
          select  only these fields;  also print any line that contains
          no delimiter character, unless the -s option is specified

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-07 10:42:53 +01:00
Olivier Gayot 27ac4b43b1 Fix language pack detection when running integration tests
Looking at the logs, we can observe that the below command does
not do what it is intended to do:

  if [ -z "$( ls .subiquity/var/cache/apt/archives/) | grep $lang" ] ; then

  ++ ls .subiquity/var/cache/apt/archives/
  + '[' -z 'language-pack-en:amd64
  wamerican:amd64
  wbritish:amd64 | grep ' ']'

The "| grep $lang" part does not execute because it is outside the $()
construct. Therefore, the -z check is always false.

We can fix it by moving the "| grep $lang" part inside the subshell
construct but I took the opportunity to drop the use of the subshell.

Also added --fixed-strings and --quiet options to grep.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 12:05:03 +01:00
Olivier Gayot 81c67780ff Add basics checks for token validity in the autoinstall JSON schema
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 10:54:08 +01:00
Dan Bungert 8ad8feec31
Merge pull request #1148 from CarlosNihelton/fix-wsl-shutdown
[SystemSetup] Moving pieces of configuration from Subiquity to WSL Launcher
2022-01-05 13:31:22 -07:00