Commit graph

2342 commits

Author SHA1 Message Date
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
Achilleas Koutsou
532a4c1166 test: add manifest-list test for skopeo stage
Added another skopeo stage to skopeo/a.mpp.json with a skopeo source for
a container hosted on the osbuild-composer gitlab registry.  The name
points to a manifest list, which refers to two containers (amd64 and
arm64) that contain a single text file (README.md).  The `index` field
is enabled to include the manifest-list as an extra input to the stage.

The diff is updated with the new expected file list.
The containers were created with buildah:

  amd=$(buildah from --arch=amd64 scratch)
  arm=$(buildah from --arch=arm64 scratch)
  buildah config --created-by "Achilleas Koutsou" "${amd}"
  buildah config --created-by "Achilleas Koutsou" "${arm}"
  buildah copy "${amd}" README.md
  buildah copy "${arm}" README.md
  amdid=$(buildah commit --format=docker --rm "${amd}")
  armid=$(buildah commit --format=docker --rm "${arm}")
  name="registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/manifest-list-test"
  buildah manifest create "${name}" "${amdid}" "${armid}"

  podman manifest push --all "${name}" dir:container
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
3e94088e1f tools/osbuild-mpp: resolve manifest lists
Add support for resolving manifest lists in osbuild-mpp.
Adds an `index` boolean field to the container image struct for
mpp-resolve-images.  When enabled, the preprocessor will also store the
manifest-list digest as a separate skopeo-index source and add it to the
skopeo stage under the `manifest-lists` input.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
ac2f140d4c stages/skopeo: merge manifest into image directory
When a manifest list is matched with a container image, the skopeo
stage will merge the specified manifest into the container image dir
before copying it to the registry in the OS tree.

If there is no manifest to merge, we maintain the old behaviour of
symlinking the source to work around the ":" in filename issue.
Otherwise, we copy the container directory so that we can merge the
manifest in the new location.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
dd902311c2 stages/skopeo: add manifest-lists input
Add an extra optional input type to the skopeo stage called
`manifest-lists`.  This is a list of file-type inputs that must be a
list of manifest lists, downloaded by the skopeo-index source.

The manifests are parsed and automatically associated with an image from
the required `images` inputs.  If any manifest list is specified and not
used, this is an error.

Adding manifest-lists currently has no effect.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
3a717e170a sources: add org.osbuild.skopeo-index source
A new source module that can download a multi-image manifest list from a
container registry.  This module is very similar to the skopeo source,
but instead downloads a manifest list with `--multi-arch=index-only`.
The checksum of the source object must be the digest of the manifest
list that will be stored and the manifest that is downloaded must be a
manifest-list.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
b83fd8650c osbuild-mpp: extract is_manifest_list() function
Extract the is_manifest_list() function from the ImageManifest object in
osbuild-mpp into a util function to be reused by the skopeo source.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
ce29a4af73 sources/skopeo: change local container format
Change the local storage format for containers to the `dir` format.
The `dir` format will be used to retain signatures and manifests.

The remove-signatures option is removed since the storage format now
supports them.

The final move (os.rename()) at the end of the fetch_one() method now
creates the checksum directory if it doesn't exist and moves the child
archive into it, adding to any existing archives that might exist in
other formats (from a previous version downloading a `docker-archive`).

Dropped the .tar suffix from the symlink in the skopeo stage since it's
not necessary and the target of the link might be a directory now.

The parent class exists() method checks if there is a *file* in the
sources cache that matches the checksum.  For containers, this used to
be a file called container-image.tar under a directory that matches the
checksum, so for containers it always returned False.  Added an override
for the skopeo source that checks for the new directory archive.
2023-03-31 14:57:26 +02:00
Achilleas Koutsou
be76d6f355 sources/skopeo: fix comment typo 2023-03-31 14:57:26 +02:00
Achilleas Koutsou
5f76ec03a7 inputs/containers: change archive format to dir
The format so far was assumed to be `docker-archive` if the container
was coming from a source and `oci-archive` if it was coming from a
pipeline.  The source format will now be changed to `dir` instead of
`docker-archive`.  The pipeline format remains `oci-archive`.

With the new archive format being `dir`, the source can't be linked into
the build root and is bind mounted instead with the use of a MountGuard
created with the instance of the service, and torn down when the service
is stopped.

The _data field is removed from the map functions.  It was unused and
these functions aren't part of the abstract class so they don't need to
have consistent signatures.

Update the skopeo stage with support for the newly supported `dir`
format.
2023-03-31 14:57:26 +02:00
SchutzBot
998f640387 schutzfile: update manifest-db ref 2023-03-20 2023-03-31 13:28:32 +02:00
schutzbot
7f68136324 Post release version bump
[skip ci]
2023-03-29 08:14:39 +00:00
Sanne Raymaekers
bae4f77661 stages: add ovf stage
This stage generates an ovf descriptor and a manifest intended for
vSphere. The resulting artifacts can be tarred together with the vmdk
into an ova.
2023-03-28 23:07:38 +02:00
Jakub Rusz
cfed69adca CI: update fedora-38 images 2023-03-28 10:02:53 +02:00