Commit Graph

20 Commits

Author SHA1 Message Date
Fredrik Lönnegren f132230beb Update copyright year (2025)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2025-01-07 16:43:28 +01:00
Andrea Mazzotti fa2306d632
Implement state subcommand (#2182)
* Implement state subcommand

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
2024-09-13 08:59:30 +02:00
David Cassany Viladomat 15a10cc4f5
Make EFI partition size configurable at install time (#2105)
* Make EFI partition size configurable at install time
* Add a custom EFI size test
* Rename efi to bootloader partition in config.yaml
* Rename EFI variable to Boot
* Rename constants

Signed-off-by: David Cassany <dcassany@suse.com>
2024-06-19 06:23:33 +02:00
Andrea Mazzotti 2c5be14ee1
Add upgrade-recovery subcommand (#1974)
* Implement to upgrade-recovery sub command

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>

* Update Upgrade documentation

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>

---------

Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
2024-02-29 16:12:14 +01:00
Fredrik Lönnegren 698bf2a950 Regenerate docs
There was an error-code duplicate which made the docs-publishing error
out.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-02-22 12:42:29 +01:00
David Cassany Viladomat 8f802fa84b
Btrfs snapshotter implementation (#1957)
* Implementation of Btrfs snapshotter
* Btrfs based examples
* Refined and adapt features
* Update build-disk to new snapshotter and prevent including State partition on expandable images
* Remove /oem bind mount in initramfs, already mounted by mount command
* Adapt unit tests
* Add mount command unit tests
* Make grubfallback test more generic
* Adding btrfs snapshotter unit tests and fixing default snapshotter config constructor
* Add utils test
* Fix upgrade ENV variables mapping
* Include transactional-update package in example
* Fix persistent bind mounts
* Make sure state is RW mounted upgrading from legacy
* Remove unused passive symlinks for loopdevice
* Fix upgrade from older version

Signed-off-by: David Cassany <dcassany@suse.com>
2024-02-21 14:04:05 +01:00
David Cassany Viladomat 4cab6a0eae
Refactor to switch to snapshotter interface (#1906)
* Refactor to switch to snapshotter interface

This commit adopts snapshotter interface in install,
reset and upgrade commands. The change implies changes
to the respective specs, grub configuration and dracut
modules.

This commit also changes the behavior of recovery system
upgrades. Now recovery upgrades are an optional step
of a system upgrade. Recovery image can't be upgraded
without upgrading the active system.

Finally build-disk command is also changed to be better
aligned with upgrade and install procedures. Expandable
disks are an unprivileged build and non expandable ones
require privileges as they relay on snapshotter.

* Attempting to fix integration tests

* Adding a migration path from legacy deployments

* Omit /etc/resolv.conf for dir:// paths

* Adaptations after rebase

* Make sure we also mount EFI in upgrades if it was not already mounted

* Default maximum number of snapshots is 2

* Upgrade grub to EFI partition

* Improve recovery management

* Recovery back to ext2 by default

* Adapt upgrade after rebase


Signed-off-by: David Cassany <dcassany@suse.com>
2024-01-31 11:03:24 +01:00
Fredrik Lönnegren cd4e009b88 Update copyright year (2024)
Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2024-01-09 09:44:34 +01:00
David Cassany Viladomat 3ea9d757e4
build-disk command (#1794)
This commit adds in elemental client the build-disk command. With this command we can eventually build an image that includes partitions:

* EFI
* OEM
* Recovery
* State

Having State partition to match the minimum size (to reduce resulting image size), only includes config files no image.

Then the State partition could be expanded on first boot to desired size (build-disk command already pre-appends the required cloud-config files for that to happen) and then the Persistent partition created at the end with all the available space (or some desired specific size too).

This setup can be executed without running a single mount (thanks to squashfs usage), meaning this disk could be built in a container or Dockerfile (like we do with ISOs).

Building full disks including all partitions with an specified size is still possible, however this approach requires mount privileges and because of that it can't be executed inside non privileged containers.


Signed-off-by: David Cassany <dcassany@suse.com>
2023-10-17 14:26:19 +02:00
Fredrik Lönnegren 5f4381a0e3
Update documentation (#1778)
* Update documentation

Remove old usages of luet/luet-makeiso and channel.

Goes through the Examples and updates the usage to reflect the latest
changes of the toolkit.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Changes to golangci-config

Disable all linters by default and add back the current default ones.

This is done in order to prevent new default linters in the
golangci-lint to take effect without noticing.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Also push elemental-cli on release to ghcr.io

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

---------

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2023-06-02 14:40:49 +02:00
Fredrik Lönnegren 19a9832efe
Set labels used by grub to find system disks (#414)
* Set labels used by grub to find system disks

This commit sets GRUB persistent variables for filesystem labels after
install/upgrade/reset. These labels are used in the new GRUB
configuration when booting the system.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Changes to recovery/system grub-labels

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Add grub persisten_label

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Try fixing test panic

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Refactor GRUB labels

Add spec->map conversion and tests.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Use same constants package in install action

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Add upgrade tests for grub labels

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

* Add reset test for grub labels

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>

---------

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2023-02-07 10:29:40 +00:00
David Cassany Viladomat 7b348b5134
Refactor elemental (#404)
* Elemental image deploy refactor

This commit refactors elemental image deploy procedure to always create
and prepare the root tree in a temporary folder before synching it to
a filesystem image most likely as a mounted loop device.

This change has a couple of immediate benefits:

1. We can precompute the root tree size before creating the filesystem
   image. Hence image sizes can be adjusted to root-tree size.

2. There is no path differentiation between filesystems. The root tree
   is prepared following the same logic independently of the target
   filesystem. Squashfs is no longer an exception, building the image
   follows the same logic as it was any other writable filesystem.

We also can argue this is a simple, robust and flexible logic compared
with the previous code.

The counter part is having to prepare the root-tree to later on copy it
to the final image, this causes the root-tree to be written twice, one
to prepare it and another one to sync it to the target location.

* Preserve file mode in CopyFile
* Adapt unit tests
* Fix typo

Signed-off-by: David Cassany <dcassany@suse.com>
2023-01-17 09:56:03 +01:00
David Cassany be54c0707f Use year range in copyright headers instead of just bumping the year
Signed-off-by: David Cassany <dcassany@suse.com>
2023-01-12 11:13:33 +01:00
David Cassany 408d2ab56f Bump year in copyright headers
Signed-off-by: David Cassany <dcassany@suse.com>
2023-01-12 11:13:33 +01:00
David Cassany Viladomat 9cd3799936
Add post-* hooks (#399)
This commit adds post-* hooks where the after hooks were originally
defined. After hooks are moved to happen straight in sequence after the
after-*-chroot hooks.

The main motivation for such a change is having a hook that includes the
partition, the running system and the deployed image all mounted and
easily accessible.

Signed-off-by: David Cassany <dcassany@suse.com>
2022-12-20 15:26:45 +01:00
Fredrik Lönnegren d145f9f0da
More exit codes (#376)
Use elemental-error in new, run-stage, pull-image, cloud-init, convert-disk and build-iso commands.

Fixes #366, #369, #367, #363, #364, #361

If duplicate exit-codes are used in pkg/errors/exit-codes.go the `make
build_docs` will now exit with an error.

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2022-11-18 08:18:22 +00:00
Fredrik Lönnegren 18efe016d3
cli: Add exit-codes for reset command (#375)
cli: Add exit-codes for reset command

Fixes #368

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2022-11-16 09:18:37 +01:00
Fredrik Lönnegren 1ad96868c0
cli: Add exit-codes to install command (#374)
cli: Add exit-codes to install command

Fixes #365

* Refactor power-action for upgrade and install because of gocyclo lint
* Refactor build-disk to use regular error

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2022-11-15 15:24:49 +01:00
Fredrik Lönnegren 3b2e929455
cli: Add exit-codes to upgrade cmd (#371)
cli: Add exit-codes to upgrade cmd

Uses the new elemental error to add exit-codes for error paths in the
upgrade command and upgrade action.

Fixes #370

Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com>
2022-11-14 12:54:08 +01:00
Itxaka bc06830a49
Introduce ElementalError and exit codes (#355)
* Introduce ElementalError and exit codes

 - ElementalError is an enhaced error interface that rbings along the
   exit code so we can exit properly from the main cmd command
 - Exit codes are stored along the error package
 - Build-disk command and related, but confined functions are all using
   the new ElementalError to propagate the exit code

Signed-off-by: Itxaka <igarcia@suse.com>

* Add comments to exit error constants

This should result in godoc automatically adding them to the
documentation visible on https://pkg.go.dev/

Signed-off-by: Itxaka <igarcia@suse.com>

* Rename files to sync with the rest of the repo

Signed-off-by: Itxaka <igarcia@suse.com>

* Add more info to exit codes for the docs

Signed-off-by: Itxaka <igarcia@suse.com>

* Maintain numerical order for ease of look

Signed-off-by: Itxaka <igarcia@suse.com>

* Generate the exit-codes md file automatically

This uses the go AST parser to parse the exit-codes.go file and extract
the exit value and the comment, and generate an md file with a nice
table with all the exit codes and its comment, where the comment is mean
to eexplain at a glance what the error came from (file open failed,
download failed, etc...) NOT a big explanation, that is what the logs
are for.

Also the list is ORDERED by error code, so no problems adding extra
codes in the future, the list will keep the order

Signed-off-by: Itxaka <igarcia@suse.com>

Signed-off-by: Itxaka <igarcia@suse.com>
2022-11-09 09:50:50 +01:00