subiquity/subiquity
Olivier Gayot cda6c54b87 filesystem: store the actual size in bytes alongside the human readable size
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>
2023-08-09 16:50:03 +02:00
..
client one-off format of long lines with black 2023-07-25 15:27:49 -06:00
cmd one-off format of long lines with black 2023-07-25 15:27:49 -06:00
common add support for 'dd' image sources 2023-08-03 09:07:06 +12:00
models do not remove old UEFI loaders 2023-08-08 21:22:26 +12:00
server Merge pull request #1758 from mwhudson/bootnext-rp 2023-08-09 10:52:55 +12:00
tests format with black + isort 2023-07-25 15:27:42 -06:00
ui filesystem: store the actual size in bytes alongside the human readable size 2023-08-09 16:50:03 +02:00
__init__.py format with black + isort 2023-07-25 15:27:42 -06:00
__main__.py format with black + isort 2023-07-25 15:27:42 -06:00
cloudinit.py cloudinit: tweak logs on combined json error cases 2023-07-25 17:28:47 -06:00
journald.py format with black + isort 2023-07-25 15:27:42 -06:00
lockfile.py format with black + isort 2023-07-25 15:27:42 -06:00