Commit graph

2455 commits

Author SHA1 Message Date
Tomáš Hozza
9a47a56639 mockbuild.sh: retry dnf install up to 5 times
We have been observing a race condition in our CI when installing
packages at the beginning of the SUT setup. This happens only on RHEL
and it is caused by the `rhc` tool, which executes some Ansible
playbooks on system startup, which install packages using dnf. This
interferes with dnf commands ran by the `mockbuild.sh` script, which
results in a job failure.

Since there seems to be no way to determine if `rhc` finished "its
thing", let's retry dnf install of packages up to 5 times with
exponential backoff in between retries.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-05-29 15:53:24 +02:00
Tomáš Hozza
8aba0d196e Spec: use %forgeautosetup macro in %prep phase
Use %forgeautosetup macro to prepare sources in the %prep phase to
auto-apply any potential downstream patches just by listing them in the
spec file using `PatchX`. Otherwise, the macro needs to be modified each
time a downstream patch needs to be applied in downstream.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-05-26 14:10:51 +02:00
Tomáš Hozza
3e780762cb stages/sgdisk: option to not quote partition names passed to sgdisk
The partition name in the sgdisk stage was previously quoted when
passed to sgdisk as an argument. I think that this was done because
the sgdisk man page states that:

```
If you want to set a name that includes a space, enclose it in
quotation marks, as in sgdisk -c 1:"Sample Name" /dev/sdb.
```

However, this should apply only when sgdisk is run in a shell, so that
the argument is not split by shell into multiple arguments and passes
as a single string.

The stage is executing sgdisk using Python `subprocess` module, which
does not need strings with spaces to be quoted, because they are passed
to the command as separate items which are not split in any way.

The previous behavior of the stage was that these quotes became part of
the actual partition name in the partition table.

After a discussion within the team, we determined that this is a bug.
However, fixing it would result in osbuild producing a different
artifact for the same manifest, compared to osbuild version without such
fix. This is undesired.

For backward compatibility, a new `quote_partition_name` property is
added to the stage options, which can be used to make the stage not
quote the partition name when passed to `sgdisk`. As a result, the
partition name won't be quoted in the partition table.

The default stage behavior us kept.

Modify unit tests to use this option by default.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-05-26 08:43:52 +02:00
Eric Chanudet
267f3909bd stages/sfdisk: support changing GPT partition attribute bits
util-linux 2.38.1, at least, does not accept raw bit indexes for the
reserved bits (Bit0-2). The undefined ones are out of reach as well and
will have sfdisk throw an error. Only the GUID specific ones can be
passed as raw indexes. This can be verified with the --part-attrs
option. It replicates the format of the --dump output:

$ dd if=/dev/zero of=disk.img bs=$((4<<10)) count=$((32<<10)
$ sgdisk disk.img -n 0:0:+64M -t 0:0FC63DAF-8483-4772-8E79-3D69D8477DE4 -c 0:root
$ sgdisk disk.img -A1:set:{0,1,2,3,48}
$ sfdisk --dump disk.img
label: gpt
label-id: 7484F730-3429-47BF-8A72-3A7AE1F2D86C
device: disk.img
unit: sectors
first-lba: 34
last-lba: 262110
sector-size: 512

disk.img1 : start=        2048, size=      131072, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=404694AC-247D-43B3-9907-A468E5C038A3, name="root", attrs="RequiredPartition NoBlockIOProtocol LegacyBIOSBootable GUID:48"

$ sfdisk --part-attrs disk.img 1 0
unsupported GPT attribute bit '0'
sfdisk: disk.img: partition 1: failed to set partition attributes

While the --dump output prefixes the GUID specific bits with "GUID:",
that is not necessary for setting them, which is consistent with the
man-page.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
2023-05-25 14:57:28 +02:00
Eric Chanudet
9a42ce04ac tools/osbuild-mpp: mpp-define-image sfdisk attrs
Add the translation logic to handle the attrs field of sfdisk as
supported by org.osbuild.sfdisk and documented in its schema. With the
schema taking an int array, some translation is required to populate the
sfdisk command appropriately.

Amend the example schema to reflect the change.

Signed-off-by: Eric Chanudet <echanude@redhat.com>
2023-05-25 14:57:28 +02:00
schutzbot
a7b3ef3936 Post release version bump
[skip ci]
2023-05-24 08:13:14 +00:00
Thomas Lavocat
8669d0ad4c ci/parallelization: manifest tests run in parallel
To avoid hitting the 4h timeout.
2023-05-23 11:52:11 +02:00
SchutzBot
61f329a08c schutzfile: update manifest-db ref 2023-05-20 2023-05-23 11:52:11 +02:00
Simon de Vlieger
a348fe2d49 stages/isolinux: default list
Otherwise when `opts` (which isn't `required`) is left out we fail the
stage.
2023-05-23 10:13:15 +02:00
Michael Ho
621fa47563 runners: add fedora-38 specific logic
This fixes an issue where Fedora-38 hosts can not build CentOS-Stream-9
images due to an incompatible gpg key with the new default settings for
rpm.

On Fedora-38, rpm has changed to use a new backend for key verification
and by default does not support SHA1 anymore, although the support for
SHA1 can be re-enabled via a config file. The (current) CentOS-Stream-9
keys however still require SHA1 support in order to be importable. So
they are now unusable on Fedora-38 unless SHA1 support is re-enabled.

In OSBuild, the initial chroot does not contain the config files and so
SHA1 support is disabled when rpmkeys from the host is called. It does
not matter if the crypto-policies on the host machine is configured with
the exception to support SHA1 because the chroot filters that out. This
means it may not be possible to assemble CentOS-Stream-9 based images
without disabling the key check.

This patch adds an explicit conditional case for Fedora-38 to inject the
needed configuration file into /etc/crypto-policies/back-ends to enable
SHA1 support for rpm by default. It does this by copying the default
policies from /usr/share/crypto-policies. The result is OSBuild behaving
similar to the previous behaviour seen on Fedora-37 and earlier.
2023-05-16 13:19:44 +02:00
Alexander Larsson
3343696a7b org.osbuild.mkfs.ext4: Add verity option to
This allows enabling the ext4 "verity" feature (which is currently
default to off). This will be needed in the automotive work we're
doing.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2023-05-16 00:03:16 +02:00
schutzbot
4add41d50f Post release version bump
[skip ci]
2023-05-10 08:13:14 +00:00
Sanne Raymaekers
1fbd9d975f stages/org.osbuild.ovf: support older python3 versions
`str.removesuffix` was introduced in python3.9, yet el8 uses python3.6
by default.
2023-05-09 23:54:01 +02:00
Thomas Lavocat
dfcd847c8e osbuild/loop: fix typo 2023-05-05 15:42:47 +02:00
Thomas Lavocat
da11ef4eb0 loop: use LOOP_CONFIGURE instead of LOOP_SET_FD
LOOP_CONFIGURE allows to atomically configure the decive when opening
it. This avoid the possibility of a race condition where between set_fd
and set_status some operations are already accepted by the loopback
device. See https://lwn.net/Articles/820408/

This feature was included in the linux kernel 5.8 however it is safe to
not include any kind of fallback to the previous method as @obudai
points out that:

LOOP_CONFIGURE was backported into RHEL 8 kernel in RHEL 8.4 as a part
of https://bugzilla.redhat.com/show_bug.cgi?id=1881760 (block layer:
update to upstream v5.8).

Since RHEL 8.4 is currently the oldest supported release that we support
running osbuild on, it might be just fine implementing this without the
fallback.

From a centos stream 8 container:
kernel-4.18.0-448.el8.x86_64
- loop: Fix missing discard support when using LOOP_CONFIGURE (Ming Lei) [1997338]
- [block] loop: Set correct device size when using LOOP_CONFIGURE (Ming Lei) [1881760]
- [block] loop: unset GENHD_FL_NO_PART_SCAN on LOOP_CONFIGURE (Ming Lei) [1881760]
- [block] loop: Add LOOP_CONFIGURE ioctl (Ming Lei) [1881760]
2023-05-05 15:42:47 +02:00
Alexander Todorov
04eab998b7 Start building osbuild on RHEL 8.9 and 9.3 nightly 2023-05-04 13:34:35 +03:00
Gianluca Zuccarelli
586d6bbe43 stages/yum.repo: add sslverify field
Add `sslverify` field to the yum.repo stage.
2023-05-03 20:53:52 +02:00
Jakub Rusz
f2163dd950 Update terraform SHA
Centos-stream-9 images are gone for some reason, let's use new ones.
2023-05-03 16:47:47 +03:00
Alexander Todorov
67ee98c22b Test OSTree Images on 8.8 & 9.2 nightly runners 2023-05-03 12:00:35 +03:00
Tomáš Hozza
b92168bc16 tools/tree-diff: don't pass file descriptor to os.scandir()
`os.scandir()` can accept file descriptors only since Python 3.7. The
tool would previously fail with exception when run using Python 3.6.
The solution is to provide a path, which is done using a symlink in
procfs (this is already used within the tool).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-28 22:02:35 +02:00
Tomáš Hozza
5946a013ee Test: some tests depending on rpm-ostree were not checking its presence
Add conditional skip to some tests that depend on rpm-ostree
availability, but were not checking for its presence. These tests would
previously fail if rpm-ostree is not available. They will be skipped
now.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-28 22:02:35 +02:00
Tomáš Hozza
33f3adfe5d README: update required Python version to 3.6
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-26 11:43:13 +02:00
Tomáš Hozza
3100882019 Don't use directory argument with SimpleHTTPRequestHandler constructor
The `directory` argument has been added only since Python 3.7, which
breaks the unit test on Python 3.6.

Reimplement the intended behavior by overriding the `translate_path()`
method, which takes the `directory` value into account on newer Python
versions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-26 11:43:13 +02:00
Tomáš Hozza
eb427e2513 Don't use capture_output=True with subprocess.run()
The `capture_output` argument does not exist on Python 3.6 used by
default on RHEL-8.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-26 11:43:13 +02:00
schutzbot
1eb71723a0 Post release version bump
[skip ci]
2023-04-26 08:15:08 +00:00
Tomáš Hozza
feb216c07b mockbuild.sh: use dnf to install local package, not rpm
DNF has more elaborate locking system and can wait for other instances of
itself when installing packages. Using rpm directly to install local
package is causing failures in CI due to it not being able to acquire
lock on `/var/lib/rpm/.rpm.lock`.

Using DNF should improve the situation, although there is no good
documentation to link and support this claim for sure.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-24 21:04:45 +02:00
Tomáš Hozza
bb406d11fe CI: set up team SSH keys in before_script, not deploy.sh
This is how it is done also in osbuild-composer. The downside of doing
this in `deploy.sh` is that team SSH keys are not set as authorized for
mock-build jobs, which make it impossible to log into the machine and
debug anything.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-24 21:04:45 +02:00
Simon de Vlieger
c4040191b6 lint: provide bandit configuration
`bandit` is a fast Python vulnerability scanner, this provides a default
configuration file for it for those that want to run it.

`bandit --ini .bandit -r osbuild/` will get you results.
2023-04-23 21:44:46 +02:00
Tomáš Hozza
d9e97a4830 Test/assemblers/assertImageFile: don't set default argument values
Do not specify the default value for 'expected_size' argument in
assertImageFile() function declaration. Previously, it was set to
`None`, which was never taken into account. Moreover, all callers of the
function always provide an explicit value, so the default was never
really used.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-21 17:13:10 +02:00
Tomáš Hozza
ff6b96bee5 Test: add ability to skip tests for unsupported file-systems
Add a new optional pytest CLI argument `--unsupported-fs` allowing to
specify file-systems which should be treated as unsupported in the
platform where running tests. Any test cases dependent on such
file-system support will be sipped.

This will allow to run unit tests and selectively skipping test cases
for unsupported file-systems.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-21 17:13:10 +02:00
Tomáš Hozza
db89984465 Test: port assembler tests from unittest to pytest
Port assembler tests from unittest to pytest. In addition, use
parametrized tests when testing various filesystems and various
combinations.

This is important to be able to selectively skip the test for if a
specific filesystem is not supported by the kernel (e.g. btrfs is not
supported on RHEL). Skipping a unittest subtest is not possible, which
is the motivation to move away from it and use only pytest.

Test output is now also much nicer for parametrized test cases.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-21 17:13:10 +02:00
Tomáš Hozza
2d3ceab935 Good bye Lars and David 😢
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-21 16:30:56 +02:00
Ondřej Budai
f60a4e3c84 stages/lorax-script: add missing type of path to the schema
`path` has to be a string, let's make it explicit in the schema.
2023-04-19 12:42:27 +02:00
Ondřej Budai
ce196f287c stages/lorax-script: add missing default basearch to the schema
The code uses x86_64 as a default, see:

basearch = options.get("basearch", "x86_64")

Let's declare that explicitly in the schema to prevent any confusion.
2023-04-19 12:42:27 +02:00
Tomáš Hozza
7cd36f9797 CI: delete duplicate source code check from GitHub action
The test case was testing a subset of the functionality, which is
already tested by test case in `tests.yml`. Delete it, since it does not
add any value.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
bbdb4fbc32 CI: use latest osbuild-ci container when regenerating test data
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
bf3e096735 Fix errors reported by new version of mypy
Fix the following errors:

```
osbuild/util/lvm2.py:117: error: Only instance methods can be decorated with @property
osbuild/api.py:50: error: Only instance methods can be decorated with @property
osbuild/sources.py:85: error: Only instance methods can be decorated with @property
```

Chaining of `@classmethod` and `@property` has been deprecated since
Python 3.11 with a note that chaining didn't work correctly in some
cases.

Relevant links:
https://github.com/python/mypy/issues/13746
https://docs.python.org/3.11/whatsnew/3.11.html#language-builtins

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
c59c5c31de Test: use osbuild-ci container with dosfstools
The `test_mount` test case requires dosfstools to create a FAT
filesystem in a testing image.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
56987fdda4 Test: make run/test_mount.py not depend on installed osbuild
Previously, the unit test depended on osbuild modules being installed on
the system. As a result, this made the test not work in CI where we do
not install osbuild when running unit tests. In addition, the stage
executed by the unit test would use different version of osbuild
internals than the version that is being tests, which could result in
issues or not testing the intended code.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
975965510b Test: handle non-existence of /run/osbuild in test/run/test_mount.py
The directory does not exist when the unit test is run in CI. Handle
this case by ensuring that parent directories are created as needed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
1a2776bf1b Test: run all tests from test/run in CI
In CI, we list specific tests from `test/run` to run them in parallel.
This is different than what we do with tests in `test/mod` and
`test/src`.

It seems that as a result, we did not run tests from the following
files in CI:
 - `test_devices.py`
 - `test_mount.py`

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
schutzbot
1df905222e Post release version bump
[skip ci]
2023-04-12 08:13:49 +00:00
Sanne Raymaekers
33597e82a3 test/data/stages: add wsl.conf test 2023-04-11 10:11:08 +02:00
Sanne Raymaekers
028bf67a1d stages/org.osbuild.wsl.conf: add stage to configure WSL settings 2023-04-11 10:11:08 +02:00
Sanne Raymaekers
5dbf596ffa .gitlab-ci: drop fedora-35 2023-04-06 14:49:23 +02:00
Sanne Raymaekers
72db212a61 .gitlab-ci: remove RHEL 8.6/9.0 ga runners 2023-04-05 18:03:48 +02:00
Simon de Vlieger
12e4e541c3 stage/systemd.preset: be able to write a preset file
The right way to enable services is to use a preset file instead of
writing directly into /etc. This adds a new stage called
`org.osbuild.systemd.preset` to do so.
2023-04-05 14:34:39 +02:00
Sanne Raymaekers
93f90b9443 .gitlab-ci: use RHEL 87/91 GA in rpmbuild and ostree test stages 2023-04-04 20:35:57 +02:00
Sanne Raymaekers
efa038197d stages/org.osbuild.ovf: support older python3 versions
The `capture_output` option was added in python3.7, yet el8 has
python3.6 by default.
2023-04-04 20:35:57 +02:00
Simon de Vlieger
76a80bd8c5 ci: remove codecov
`codecov` often reports weird diffs and we rarely take action on a
codecov failure in CI.

This closes #1263.
2023-04-01 15:12:58 +02:00