Commit graph

2710 commits

Author SHA1 Message Date
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
Dusty Mabe
d50705249a osbuild-mpp: fix float correction
I mistakenly thought the .strip('.0') would strip off just '.0` but
in reality it strips off all instances of `.` or `0` on the end so
'4075520.0'.strip('.0') => '407552', which is clearly wrong.

This is a fixup for 5207e92.
2024-01-15 11:53:21 +01:00
Dusty Mabe
7d73c0e741 manifests: move osname to a var in fcos manifest
This makes it easier to see/change the value globally.
2024-01-15 11:53:21 +01:00
Dusty Mabe
d9fe4221b0 manifests: move boot/root fs uuid/label to var in fcos manifest
This makes it easier to see the important unique values in our
manifest.
2024-01-15 11:53:21 +01:00
Dusty Mabe
ac8a57c5a3 manifests: set sysroot.readonly config to true in fcos manifest
This is set in Fedora CoreOS today. Let's make it match here.
2024-01-15 11:53:21 +01:00
Dusty Mabe
7cf98cfbf1 manifests: remove partition UUIDs from fcos container manifest
We don't set the UUIDs today in COSA/create_disk.sh so let's not
statically set them here either. This means they'll get set to
something random.
2024-01-15 11:53:21 +01:00
Luke Yang
d089b429a7 stages/org.osbuild.ostree.config: support bls-append-except-default
Support setting the sysroot.bls-append-except-default value in the
OSTree config. This is used by CoreOS to support configuration used
for GRUB password support https://github.com/coreos/fedora-coreos-tracker/issues/1333
2024-01-11 12:55:12 -05:00
Michael Vogt
73ec3122f2 stages,test: update tests for new selinux.setfiles() calling 2024-01-11 10:23:25 +01:00
Michael Vogt
467a23ffa7 stages(selinux): use osbuild.util.selinux.setfiles()
Instead of calling `setfiles` manually just reuse the existing
helper. The tests validate that there is no functional change.
2024-01-11 10:23:25 +01:00
Michael Vogt
18159eceec test: add selinux stage test 2024-01-11 10:23:25 +01:00
Dusty Mabe
83a14886d3 add --break for requesting a debug shell
Similar to rd.break for dracut this allows a user to specify:

- --break or --break=*
    - to get a shell before each stage is run
- --break=stage.name
    - to get a shell each time the stage with that name is run
    - example: --break=org.osbuild.copy
- --break=stage.id
    - to get a shell each time the stage with that ID is run
    - get the ID for the stages for your manifest by running
      osbuild on the manifest with --inspect
    - example: --break=dc6e3a66fef3ebe7c815eb24d348215b9e5e2ed0cd808c15ebbe85fc73181a86

and get a bash shell where they can inspect the environment to debug
and develop OSBuild stages.
2024-01-10 08:39:27 -08:00
Michael Vogt
962b7f4d4b test: add test for export option 2024-01-10 11:24:01 +01:00
Dusty Mabe
8cce659ec5 stages/bootupd: support installing to a partition of a device
For ppc64le we need to pass in a partition (i.e. /dev/loop0p1) rather
than the root device (/dev/loop0) to the --device argument of bootupctl.
Let's add a partition field and find the device node based on the user
specified partition.

On ppc64le this would look something like:

```
      - type: org.osbuild.bootupd
        options:
          bios:
            device: disk
            partition:
              mpp-format-int: '{image.layout[''POWERPC-PREP-BOOT''].partnum}'
          static-configs: true
          deployment:
            osname: fedora-coreos
            ref: ostree/1/1/0
        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: boot
            type: org.osbuild.ext4
            source: disk
            partition:
              mpp-format-int: '{image.layout[''boot''].partnum}'
            target: /boot
```
2024-01-10 01:15:18 +01:00
Michael Vogt
492dc6021c stages(bootupd): refactor test to separately test behaviors
It now tests  bind_mounts and bootupd behavior separately.
2024-01-10 01:15:18 +01:00
Michael Vogt
dacf5733ea stages(bootupd): add tests for existing behavior
Also refactor bind mounts into a helper.
2024-01-10 01:15:18 +01:00
Michael Vogt
eb657b08b3 stages(bootupd): add schema test 2024-01-10 01:15:18 +01:00
Dusty Mabe
fdd5d25c1e tests/fedora-coreos-container: switch to testing FCOS
The stable stream currently doesn't have a new enough bootupd to pass
the tests for the bootupd stage. Let's update to `:testing` for now
and we'll switch back to `:stable` later.
2024-01-10 01:15:18 +01:00
Renata Ravanelli
cdcb4598bb create org.osbuild.bootupd stage
Add the bootupd stage to install GRUB on both BIOS and UEFI systems,
ensuring that your bootloader stays up-to-date.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-01-10 01:15:18 +01:00
Michael Vogt
c03e6be52a stages(grub2): allow pulling efi binaries from alternative efi roots
The EFI binaries are currently pulled from a hardcoded path in the
buildroot. When moving to containers as buildroots this will no
longer work as they have an alternative layout. This is an easy
"fix" - make the location of the `EFI/` directory configurable.

This allows us set `efi_src_dir` to `/usr/lib/bootupd/updates/EFI/`
and keep our existing `bootc-image-builder` workflow.

Note that this may actually not be the desired solution and instead
we want the new `bootupd`: https://github.com/osbuild/osbuild/pull/1519
2024-01-09 19:43:01 +01:00
Michael Vogt
cb02d0a4bc stages(container-deploy): ensure /var/tmp is available
This commit ensures that `/var/tmp` is available. Skopeo expects
this dir but the bwrap environment starts with a very minimal
`/var` so `/var/tmp` may not be available.
2024-01-09 12:54:11 +01:00
Dusty Mabe
c62e555202 tools/osbuild-mpp: run _process_format() for mpp-embed dict
So we can use something like mpp-format-string inside of mpp-embed. An
example would be below where we want to substitute the ociarchive var
in using `mpp-format-string: 'file://{ociarchive}'`.

```
version: '2'
mpp-vars:
  ociarchive: /path/to/fedora-coreos-39.20240104.dev.2-ostree.x86_64.ociarchive
pipelines:
  - name: oci-archive
    stages:
      - type: org.osbuild.copy
        inputs:
          inlinefile:
            type: org.osbuild.files
            origin: org.osbuild.source
            mpp-embed:
              id: fcos.ociarchive
              url:
                mpp-format-string: 'file://{ociarchive}'
        options:
          paths:
            - from:
                mpp-format-string: input://inlinefile/{embedded['fcos.ociarchive']}
              to: tree:///fcos.ociarchive
```
2024-01-05 18:57:43 +01:00