Currently, the partition form stores the size as a human readable value.
(e.g., 123456K, 1.1G, 1.876G, 100G). When we exit the size field (i.e., upon
losing focus), we convert the value to a number of bytes and then align
it up to the nearest MiB (or whatever the alignment requirement is).
Unfortunately, after computing the aligned value, we turn it back into a
human-readable string and store it as is. It is not okay because the
conversion does not ensure that the alignment requirement is still
honored.
For instance, if the user types in 1.1G, we do the following:
* convert it to a number of bytes -> 1181116006.4 (surprise, it is not
even an integer).
* round it up to the nearest MiB -> 1181745152 (this is the correct
value)
* transform it into a human readable string and store it as is -> 1.1G
- which actually corresponds to the original value.
This leads to an exception later when creating the partition:
File "subiquity/models/filesystem.py", line 1841, in add_partition
raise Exception(
Exception: ('size %s or offset %s not aligned to %s', 1181116006, 1048576, 1048576)
Fixed by storing the actual size as a number of bytes - alongside the
human readable size.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
In a recent patch, we switched the mechanism used for running some
shutdown related commands. We used to lean on run_command() and we now
lean on runner.run().
runner.run() works a bit differently because it runs the command through
systemd-run - and by default does not capture the output (it goes into
the journal).
Another difference is that runner.run() would not forward the keyword
arguments (like stdout, stderr) to subprocess. Well, it would forward
those arguments to runner.start() which would raise an exception:
File "subiquity/server/controllers/shutdown.py", line 118, in copy_logs_to_target
await self.app.command_runner.run(
File "subiquity/server/runner.py", line 98, in run
proc = await self.start(cmd, **opts)
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: DryRunCommandRunner.start() got an unexpected keyword argument 'stdout'
We now ensure that those keyword arguments are properly forwarded to
subprocess (through astart_command).
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
When invoking kvm-test.py, one can pass the --with-tpm2 option so that
we emulate a TPM and make it available in the guest.
This requires the swtpm package which is available in jammy and more
recent versions of Ubuntu.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Attempt to load autoinstall from
/run/cloud-init/combined-cloud-config.json first, if present.
Fallback to existing methods, which requires that cloud-init in the snap
is able to unpickle the data created by cloud-init outside the snap.
See also LP: #2022102.