Commit graph

2730 commits

Author SHA1 Message Date
Diaa Sami
e023fdec1b osbuild-depsolve-dnf: port weak dependencies
ported from d48da99a12
2024-02-08 00:12:32 +01:00
Michael Vogt
705397e7f6 test: add simple zipl_inst tests
Co-authored-by: Nikita Dubrovskii <nikita@linux.ibm.com>
2024-02-07 18:08:44 -05:00
Nikita Dubrovskii
e427289887 stages(zipl.inst): support appending kernel options
In some cases it could useful to add additional kernel options without
modifying BLS config, so any subsequent call to `zipl` would ignore them.
We are going to use this to append `ignition.firstboot` to kernel cmdline
for CoreOS on s390x.
2024-02-07 18:08:44 -05:00
Diaa Sami
c673eab2b5 osbuild-depsolve-dnf: port module_hotfixes support over
from 61e6f75281
2024-02-08 00:03:59 +01:00
Colin Walters
161c19601a container-deploy: Output stderr on failure
This stage was failing for me in bib, with this change I now
get more useful information from podman's stderr, e.g.:

```
RuntimeError: Failed to mount image (125): time="2024-02-06T14:23:06Z" level=error msg="Unmounting /var/lib/containers/storage/overlay/06456126e7c06cf1b21de024e08e64eddead2b8d03779be213e63aeeea9dec94/merged: invalid argument"
Error: creating overlay mount (...snip...)
fuse: device not found, try 'modprobe fuse' first
fuse-overlayfs: cannot mount: No such file or directory
```
2024-02-07 16:11:19 +01:00
Achilleas Koutsou
6e12f08a29 test: add bootupd.gen-metadata stage test
Since the stage depends on quite a specific tree state (ostree prepped
tree with boot files), we can't really unit test it any simpler than
generating a tree with and without running the stage and diffing the
tree.
2024-02-07 12:10:01 +01:00
Achilleas Koutsou
d75f43ff7b stages: add new org.osbuild.bootupd.gen-metadata stage
Runs bootupctl generate-update-metadata in the tree to transform
/usr/lib/ostree-boot into a bootupd-compatible update payload.

This stage should be run on the sysroot of an ostree deployment or
ostree-converted tree.
2024-02-07 12:10:01 +01:00
Dusty Mabe
011cf6851b stages(ostree.config): support setting sysroot.bootprefix
See https://github.com/ostreedev/ostree/pull/2705 and also
https://github.com/osbuild/osbuild/issues/1566.
2024-02-07 11:28:24 +01:00
Dusty Mabe
151b6e48ae stages(sgdisk): support label option
We only support `gpt` here so it would seem this option doesn't
make much sense to add, but it will make it so that the mpp-define-images
from osbuild-mpp can be passed in to `org.osbuild.sgdisk` just as it
can be passed in today to `org.osbuild.sfdisk`.
2024-02-06 17:44:31 +01:00
Nikita Dubrovskii
fc185dae8c support user-defined partition numbers for GPT disks
Partitions by default are indexed starting at 1, but in
some cases, such as CoreOS for IBM Z, it may be usefull
to set the 'partnum' for GPT disks explicitly, without
creating dummy partitions.

Now user can define an image:

```
    mpp-define-images:
      - id: image
        size: 10737418240
        table:
          uuid: 00000000-0000-4000-a000-000000000001
          label: gpt
          partitions:
            - name: boot
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 3
              size: 786432
            - name: root
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 4
              size: 4194304
```

So target disk would look like:

```
    Disklabel type: gpt
    Disk identifier: 00000000-0000-4000-A000-000000000001
    Device        Start     End Sectors  Size Type
    /dev/loop0p3   2048  788479  786432  384M Linux filesystem
    /dev/loop0p4 788480 4982783 4194304    2G Linux filesystem
```

This patch updates the osbuild-mpp tool and the sgdisk and sfdisk
stages to support this.

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
2024-02-06 17:44:31 +01:00
Michael Vogt
6b8c1872f6 fscache: use remove_lru() to reclaim space when the cache is full
This commit adds code that will remove the least recently used
entries when a store() operation does not succeeds because the
cache is full. To be more efficient it will try to free
twice the requested size (this can be configured in the code).
2024-02-06 17:16:48 +01:00
Michael Vogt
6096f999f3 fscache: add FsCache._remove_lru() to remove entries
The FsCache._remove_lru() removes the least recently used entry
from the cache.
2024-02-06 17:16:48 +01:00
Michael Vogt
b2a82beb75 fscache: add new `FsCache._last_used_objs()' helper
This commit adds a helper that can be used to get a sorted list
of cache entries. The list includes the name and the last_used
information.
2024-02-06 17:16:48 +01:00
Sanne Raymaekers
25df4d76a6 stages(tar): add unit test 2024-02-06 12:43:53 +01:00
Sanne Raymaekers
df663ada8a stages(tar): add paths option
This adds an optional `paths` option to the tar stage. If specified, the
paths will be included in the tarball in order.

The OVA image needs to have its contents in a specific order in the
archive.
2024-02-06 12:43:53 +01:00
Simon Steinbeiss
0b33adcec1 README: Drop alternative hyperlink markdown 2024-02-03 18:29:12 +01:00
Djebran Lezzoum
cdc410bb00 stages(kickstart): Add missing rootpw, initlabel, nohome
In the context of specific ostree installation we are missing some kickstart options:
1. rootpw option (despite we only need rootpw --lock, implement the full spec found here https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#rootpw)
2. initlabel a property of clearpart option
3. nohome a property of autopart
FIXES: https://issues.redhat.com/browse/THEEDGE-3835
2024-02-02 18:42:58 +01:00
Luke Yang
477a21043e Create stages/org.osbuild.chattr stage
Add or remove the immutable bit to the specified mount directory.

The need we have for this right now is for the CoreOS builds where
the immutable bit being set on an OSTree deployment root doesn't
survive the `cp -a --reflink=auto` in the org.osbuild.copy stage when
being copied from the directory tree into the mounted XFS filesystem
we created on the disk image. Thus we have to workaround this loss
of attribute by applying the attribute directly on the mounted
filesystem from the disk.
2024-01-31 16:46:01 -05:00
Dusty Mabe
bd6b8ffb83 mounts/ostree.deployment: support deployments on mount
Instead of operating directly on the tree for a stage we can operate
on a mount too. This is useful in the case where operating on the
directory tree of files isn't sufficient and the modifications need
to be made directly to the filesystems on the disk image that we are
creating.

One such example of this is we are having a problem right now where
the immutable bit being set on an OSTree deployment root doesn't
survive the `cp -a --reflink=auto` in the org.osbuild.copy stage when
being copied from the directory tree into the mounted XFS filesystem
we created on the disk image. Thus we have to workaround this loss
of attribute by applying the attribute directly on the mounted
filesystem from the disk.

In this change here we also add a check in osbuild/mounts.py to not
attempt a umount of the root of the mounts directory if that path
is no longer a mountpoint, which can happen when the umount -R
from the mounts/org.osbuild.ostree.deployment also removes the
overmount.

Here is an example of how this would be used:

```
  - type: org.osbuild.chattr
    options:
      immutable: true
      path: mount://root/
    devices:
      disk:
        type: org.osbuild.loopback
        options:
          filename: disk.img
          partscan: true
    mounts:
      - name: root
        type: org.osbuild.xfs
        source: disk
        partition:
          mpp-format-int: '{image.layout[''root''].partnum}'
        target: /
      - name: ostree.deployment
        type: org.osbuild.ostree.deployment
        options:
          source: mount
          deployment:
            osname: fedora-coreos
            ref: ostree/1/1/0
```

The initial mount on `/` is the filesystem from the root partition
on the disk. The second mount (of type org.osbuild.ostree.deployment)
then reconfigures things similar to how an OSTree system is set up.
2024-01-31 16:46:01 -05:00
Dusty Mabe
be90d8c36c mounts/ostree.deployment: use target instead of tree
We still target the tree here, but we open ourselves up to be able
to target something other than the tree in the future. This mostly
exchanges the `tree` variable for `target`.

We also update the comment to try to enhance clarity.
2024-01-31 16:46:01 -05:00
Dusty Mabe
e43abe1a9c mounts/ostree.deployment: rename var root -> deploy_root
It makes things a little more clear to know the variable is pointing
to the path of the deployment.
2024-01-31 16:46:01 -05:00
Dusty Mabe
0da68e9af5 mounts/ostree.deployment: rework unmounting
This unwinds part of a25ae2b. The way the code ended up both
self.tree and self.mountpoint ended up pointing to the exactly
same path and so we'd end up doing two `umount -R` operations
on the same path. This ended up being a duplicate unmount.

On Fedora 39 this yields an error like:

```
mount/ostree.deployment (org.osbuild.ostree.deployment): umount: /var/osbuild/store/stage/uuid-efaac9370d25455d9e8df6d847ecb5b3/data/tree: not mounted
mount/ostree.deployment (org.osbuild.ostree.deployment): Traceback (most recent call last):
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/var/b/shared/code/github.com/osbuild/osbuild/mounts/org.osbuild.ostree.deployment", line 136, in <module>
mount/ostree.deployment (org.osbuild.ostree.deployment):     main()
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/var/b/shared/code/github.com/osbuild/osbuild/mounts/org.osbuild.ostree.deployment", line 132, in main
mount/ostree.deployment (org.osbuild.ostree.deployment):     service.main()
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/var/b/shared/code/github.com/osbuild/osbuild/osbuild/host.py", line 252, in main
mount/ostree.deployment (org.osbuild.ostree.deployment):     self.stop()
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/var/b/shared/code/github.com/osbuild/osbuild/osbuild/mounts.py", line 126, in stop
mount/ostree.deployment (org.osbuild.ostree.deployment):     self.umount()
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/var/b/shared/code/github.com/osbuild/osbuild/mounts/org.osbuild.ostree.deployment", line 125, in umount
mount/ostree.deployment (org.osbuild.ostree.deployment):     subprocess.run(["umount", "-R", self.tree],
mount/ostree.deployment (org.osbuild.ostree.deployment):   File "/usr/lib64/python3.12/subprocess.py", line 571, in run
mount/ostree.deployment (org.osbuild.ostree.deployment):     raise CalledProcessError(retcode, process.args,
mount/ostree.deployment (org.osbuild.ostree.deployment): subprocess.CalledProcessError: Command '['umount', '-R', '/var/osbuild/store/stage/uuid-efaac9370d25455d9e8df6d847ecb5b3/data/tree']
' returned non-zero exit status 1.

⏱  Duration: 103s
```

I think this was necessary because of a bug in util-linux that
mean some of the accounting information got out of date when
doing a `mount --move` operation, which we use here. I think this
bug (or bugs) is now fixed [1][2] in util-linux v2.39 (in Fedora 39),
which is now causing the above pasted error on F39.

Let's just add code here that mentions the problem and workaround
it with a loop to keep unmounting (essentially what the umount -R
should have done to overmounted filesystems if the mountinfo/utab
was correct) and also mention when we should be able to drop this
workaround.

[1] a04149fbb7
[2] 8cf6c50757
2024-01-31 16:46:01 -05:00
schutzbot
21626926f7 Post release version bump
[skip ci]
2024-01-31 17:48:02 +00:00
Tomáš Hozza
2581160cfc stages/test: introduce 'stage_schema' fixture
Introduce a 'stage_schema' fixture, which will load the stage schema
by the stage name defined in the STAGE_NAME defined in the test module
and optionally provided schema version and return it. If no schema
version is specified, version "2" is assumed. Modify all stage unit
tests to use this fixture, instead of loading the stage schema on their
own.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-31 17:18:52 +01:00
Tomáš Hozza
23c8f5b432 stages/test: introduce 'stage_module' fixture
Introduce a 'stage_module' fixture, which will load the stage module by
its name defined in the test module STAGE_NAME variable. Modify all
stage unit tests to use this fixture, instead of loading the stage
module on their own.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-31 17:18:52 +01:00
Tomáš Hozza
73cb074f4b stages/cloud-init: test datasource_list dump format
Add a simple unit test, which ensures that the `datasource_list` key
is dumped in the configuration file on a single line if defined in
the stage options.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-31 17:18:52 +01:00
Tomáš Hozza
c6edc710f2 stages/cloud-init: fix dumping of datasource_list key
The stage dumps invalid cloud-init configuration, in case the
`datasource_list` key has a value assigned. The value is supposed to be
a list, but cloud-init documentation mandates that the value is always a
single line, with no newlines. This was not true in the past.

Fix #1554

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-01-31 17:18:52 +01:00
Jakub Rusz
5d0c69fe00 CI: update terraform SHA
We had to switch fedora-38-aarch64 image to an older one because the
current one was broken in AWS.
2024-01-31 12:34:57 +01:00
Michael Vogt
3ec0925bff test: drop -k from -k stages/test test matrix
With pytest 8.0.0 the `-k` option seem to have changed it's
behavior. Drop `-k` therefore.

Tests started to fail recently and it looks like this is because
pytest 8.0.0 changes the semantic of the `-k` option. We used
to pass `-k stages/test` but that seems to no longer work. So
pin pytest to the last good version until this is better
understood.
2024-01-31 09:24:59 +01:00
schutzbot
348438303e Post release version bump
[skip ci]
2024-01-31 08:13:08 +00:00
Simon de Vlieger
f9b55ff6a0 sources: rename download -> fetch_all
Not all sources download things and `fetch_all` is consistent with
`fetch_one`.
2024-01-26 09:58:48 +01:00
Simon de Vlieger
382ac8e960 sources(inline): remove threading
After some small benchmarks threading adds more overhead than
performance improvement for this source.
2024-01-26 09:58:48 +01:00
Simon de Vlieger
2c42c46c48 sources: move parallelisation into source
This moves the parallelisation decisions into the sources themselves,
making the `download` method abstract inside `osbuild` itself.
2024-01-26 09:58:48 +01:00
Brian C. Lane
18e5481ae8 osbuild-depsolve-dnf5: Add libdnf5 based depsolving for Fedora 40
dnf5-json will be used for building Fedora 40 and later.  RHEL and
Fedora < 40 will continue to use python3-libdnf via dnf-json.
2024-01-24 09:55:49 -08:00
Michael Vogt
a3192eb7c6 stages(container-deploy): add new exclude option
This commit adds a new `exclude` option to the container-deploy
stage. This is needed when we deploy `bootc` containers that are
used for the buildroot. Here the  `/sysroot` dir needs to be
excluded because it has conflicting selinux definitions for
files there and in the normal "root" dir.

See also https://github.com/osbuild/bootc-image-builder/pull/138
2024-01-24 18:32:25 +01:00
Michael Vogt
d8835150c2 osbuild: add "mypy-strict" check 2024-01-23 12:01:45 +01:00
Michael Vogt
a56afcb280 test: add new testutil.assert_jsonschema_error_contains() helper
This commit adds a new helper `assert_jsonschema_error_contains()`
to `testutil` and uses it everywhere where we check errors from
jsonschema.
2024-01-23 12:00:59 +01:00
Luke Yang
106681f41e stages/org.osbuild.mkfs.ext4: add ext4 options
Add optional flags to the org.osbuild.mkfs.ext4 stage enabling/disabling
the metadata_csum_seed and orphan_file features.
2024-01-22 13:00:52 -05:00
Dusty Mabe
408b101799 manifests: support container_imgref var in FCOS manifest
This makes it easier to see/change the value globally.
2024-01-19 17:15:23 -05:00
Dusty Mabe
d9363d4561 stages/ostree.aleph: don't manipulate image name from origin
It appears to work with the `docker://` prefix as well as the
`registry:` prefix.

```
$ ostree container image list --repo=/ostree/repo
docker://quay.io/fedora/fedora-coreos:rawhide
$
$ ostree container image metadata --repo=/ostree/repo docker://quay.io/fedora/fedora-coreos:rawhide | md5sum
aaf7fa84896358730f0a69c330db31a6  -
$ ostree container image metadata --repo=/ostree/repo registry:quay.io/fedora/fedora-coreos:rawhide | md5sum
aaf7fa84896358730f0a69c330db31a6  -
```

Let's just keep the name unmodified. This also fixes it so that
`registry:` doesn't get prepended to refs that aren't from a registry
like:

```
$ cat /ostree/deploy/rhcos/deploy/3824ff6c279d0f4ef043e80f448eeb0d24269d50e452224a5614f915ee73fb7e.0.origin
[origin]
container-image-reference=ostree-unverified-image:oci-archive:/rhcos-416.92.202401191512-0-ostree.x86_64.ociarchive
$ ostree container image metadata --repo=/ostree/repo oci-archive:/rhcos-416.92.202401191512-0-ostree.x86_64.ociarchive | wc -c
16292
```
2024-01-19 17:15:23 -05:00
Michael Vogt
f5d6d11f1d osbuild: error when {Device,Mount} is modified after creation
This is a drive-by change after spending some quality time with the
mount code. The `id` field of `Mount` is calculated only once and
only when creating a `Mount`. This seems slightly dangerous as
any change to an attribute after creation will not update the
id. This means two options:
1. dynamically update the `id` on changes
2. forbid changes after the `id` is calculcated

I went with (2) but happy to discuss of course but it seems more
the spirit of the class.

It also does the same change for "devices.Device"
2024-01-19 02:54:26 +01:00
Tom Koscielniak
4977501cc6 Switch rpmbuild to RHEL 8.9/9.3 GA 2024-01-18 19:19:23 +01:00
Michael Vogt
fd2079be60 test: fix test_libc_futimes_works
The test_libc_futimes_works() is failing under RHEL/Centos right
now. To make it more robust a tiny sleep and rounding of the
timestamps is introduced to ensure that we are not run into
floating point comaparison funnines.

The second part of the fix is to open the stamp_file in read-only
mode to ensure that the mtime is not modified by the open itself
which is what lead to the actual test failure.
2024-01-18 08:44:25 +01:00
Michael Vogt
94d8a1357f test: check that mkfs.fat has the -g option in test_fat
Older versions of RHEL/Centos do not have `mkfs.fat -g` yet so
this test will fail. Detect this and skip the test if mkfs.fat
is too old (see 7af2f1a for the original commit).
2024-01-18 08:44:15 +01:00
Michael Vogt
ff10cdb4db test: export schemas in testing_libdir_fixture
When constructing a minimal environment for osbuild the exported
dirs lacked "schemas" so the test_exports.py test failed on RHEL8.

This commit adds it (and also "assemblers" for good measure). With
that the test will pass.
2024-01-18 08:44:07 +01:00
Dusty Mabe
94b10403a0 schutzbot: add dustymabe SSH key to team_ssh_keys
This will allow me to access a CI runner for debugging a CI failure.
2024-01-17 19:54:19 +01:00
Michael Vogt
84059544e4 test: fix test_schema_validation_containers_storage_conf
The test starts failing because a new version of jsonschema (4.21.0)
changed the error messages for `minProperties: 1`.

To fix this we just use a regex and check for both possible values.
As a drive-by the commit also improves the error output in case
the match is not found.
2024-01-17 13:58:22 +01:00
schutzbot
c4ff215149 Post release version bump
[skip ci]
2024-01-16 13:48:47 +00:00
Michael Vogt
e0bbb3397d test: update test_mount.py for lsblk --json differences
Older version of `lsblk --json` will not have the plural `mountpoints`
but only a singular `mountpoint`. But newer version lost the
singular `mountpoint` in the json. Adjust the test accordingly.
2024-01-16 13:51:30 +01:00
Michael Vogt
d96f94fede test: fix new mount tests under rhel8
The new `create_image_with_partitions()` helper fails under rhel8
currently. The reason is that `mkfs.ext4 -E offset=` will warn
in older versions about a partition table and require user input.

This got fixed `e2fsprogs` 1.46.3 in Jul 2021 but RHEL8 still
has 1.45.

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989612
2024-01-16 13:51:30 +01:00