Commit graph

2799 commits

Author SHA1 Message Date
Michael Vogt
b0091c0470 inputs: simplify/comment clean of test_containers_local_inputs_integration
Thanks to Ondrej fot the suggestions
2024-02-27 15:07:42 +01:00
Michael Vogt
82f2414637 sources: tweak ContainersStorageSources.exists to return False
When an images does not exist just return `False` instead of
raising a RuntimeError. If anything else goes wrong (unknown
output or hash mismatch) keep the RuntimeError as this is an
unexpected exception.
2024-02-27 15:07:42 +01:00
Michael Vogt
5ab0b41456 sources: add test for non-existing id in containers-storage 2024-02-27 15:07:42 +01:00
Michael Vogt
0ac05ecb55 sources: tweak docstring for containers-storage 2024-02-27 15:07:42 +01:00
Michael Vogt
c219160b8f osbuild: add warning when lazy umount in containers_storage_source fails 2024-02-27 15:07:42 +01:00
Michael Vogt
b5355c46ac inputs: tweak containers-storage implementation
This commit tweaks the excellent work from Gianluca in PR#1550 a
little bit. Now that the container inputs are their own input
type some of the code that used to be part of the original
`inputs/org.osbuild.containers` can be simplified.
2024-02-27 15:07:42 +01:00
Michael Vogt
882c9efbc1 inputs: add integration test for inputs/org.osbuild.containers-storage
Ensure that `ContainersInput.map()` work correctly with local
image store references.
2024-02-27 15:07:42 +01:00
Michael Vogt
2d71935a91 inputs: add new "inputs_module" fixture 2024-02-27 15:07:42 +01:00
schutzbot
3824c9c868 Post release version bump
[skip ci]
2024-02-26 15:06:35 +00:00
Renata Ravanelli
0b7dcf3cf4 Add coreos.platforms stage
- Process all necessary operations related to CoreOS
platforms is crucial and specific to CoreOS. This step
is essential for CoreOS exclusively.

- Our approach to handling 'platforms.json' may change as we
advance with the OSBuild work. However, we don't have a clear
vision about how it will be in the future yet, particularly as
we also manage similar components within the osbuild composer
to configure cloud parameters. We probably will know better
when we start working with the cloud artifacts.

As a summary, let's add it know to unblock us, and if we find a
better approach in the future, we can always go back and remove it.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-02-26 16:02:28 +01:00
Renata Ravanelli
ddf4478ea9 util: Add bls module
- Add functions for appending kernel parameters to the
Boot Loader Specification (BLS) as needed.

Signed-off-by: Renata Ravanelli <rravanel@redhat.com>
2024-02-26 16:02:28 +01:00
Tomáš Hozza
2b868fbe75 Sources/containers-storage: make the code Python 3.6 compliant
The source implementation used `subprocess.run()` argument
`capture_output`, which was added in Python 3.7. Since the minimum
supported Python version for osbuild on RHEL-8 is 3.6, the stage fails
with TypeError.

Example failure: https://artifacts.dev.testing-farm.io/c147b608-c40e-46ed-bf11-6b15ecf718dc/

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-25 09:27:23 +01:00
schutzbot
badca79801 Post release version bump
[skip ci]
2024-02-22 11:53:23 +00:00
Michael Vogt
322974695c stages(dracut): add small unittest for initoverlayfs
Small followup for https://github.com/osbuild/osbuild/pull/1586
that includes a basic check that the initoverlayfs option calls
the right binary.
2024-02-22 11:59:21 +01:00
Gianluca Zuccarelli
6b0d2d7a3c stages/ostree-container-deploy: mkdir /var/tmp
This stage crashes when using `containers-storage` if `/var/tmp`
doesn't exist, since the directory is required by `skopeo` for big
files. See:
4ad2f46269/storage/storage_src.go (L163)
2cb3c9d3c2/internal/tmpdir/tmpdir.go (L18)
2024-02-22 11:58:54 +01:00
Achilleas Koutsou
b42e1afddc github: change container storage driver inside test container
The default overlayfs doesn't work inside the container runner which
causes the test to fail with
  Invalid destination name
  containers-storage:localhost/osbuild-skopeo-test-...:
  'overlay' is not supported over overlayfs, a mount_program is
  required: backing file system is unsupported for this graph driver

Changing the driver to vfs solves the issue.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
e7400d2e59 test/stages: read expected data from manifest
Parse the manifest to dynamically discover the expected data in the
destination so we don't have to keep the test updated if the manifest
changes.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
700dc8ded3 test/stages: build manifest and check tree
Copy hello.img into the host storage, build the manifest, export the
tree, and check the storage in the tree for the expected files and data.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
78ea8405a4 test: add test manifest for containers-storage
A manifest (mpp and json) that uses the new source and input with the
skopeo stage.

This depends on the image we store at
./test/data/stages/skopeo/hello.img

The plan is to test this by pulling the hello.img into the host root
storage, build the manifest, delete the image from storage, and check
the tree.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
423819a80e util/containers: add the checksum to the image data
When parsing a container input, add the checksum to the data as well.

Usually with other inputs, the stage only needs to know the filepath
where it can find the source content.  In most (all, so far) cases, this
is a checksum appended to the content type.

In this case, the filepath is the location of the storage bind mount and
the checksum is needed to retrieve the container.  The name might only
be a destination name (a name to use for storing the container in the
image), so we can't rely on it being valid in the source.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
591593ea00 testutil: make_container context manager
Make make_container a context manager so we can reliably clean up
containers that were created in tests.
2024-02-21 17:55:37 +01:00
Michael Vogt
d6cd4b93ba test: add minimal test for ContainersStorageSource.from_args() 2024-02-21 17:55:37 +01:00
Michael Vogt
f7e4febb2c stage,test: extract make_container() test helper 2024-02-21 17:55:37 +01:00
Michael Vogt
119172e8dd test: add sources_module fixture for sources unit tests
Similar to the `stage_module` fixture for stage tests this adds
a fixture to test sources modules of osbuild.

The code from `stage_module` and `sources_module` is similar and
could be combined but pytest makes it hard to do this without
having a shared root dir. Given that it's just four lines it
seems easier to just life with the tiny bit of code duplication.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
6572b1b8e7 util: remove storage_conf arg from get_host_storage()
Let the caller decide if a reload of the storage configuration is needed
and simplify the storage configuration reader.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
2d779a14e4 util: fall back to /usr/share for storage.conf if no /etc config
The system-wide location for the containers storage.conf is
/usr/share/containers.  The existence of a file in /etc/containers
completely overrides this (see containers-storage.conf(5)).
If no file is found at /etc/containers/storage.conf then fall back to
reading the config from /usr/share/containers/storage.conf.

If neither file exists, this is an error since the default config should
be packaged with any tool that requires it (skopeo, podman, etc).
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
06801bb442 util/containers: mount storage
Containers with the `containers-storage` are bind mounted to
the osbuild store. This helper function bind mounts the
containers-storage from the store into the `/containers/storage`
so that stages that require containers can then make use of these
containers.
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
591341dfa6 inputs: new input type org.osbuild.containers-storage
An input that pairs with the org.osbuild.containers-storage source. It
makes the host container storage available to a stage and a container ID
for the stage to use.

Unlike all the other input types, this input does not refer to static
objects in the osbuild sources store but a dynamically mounted container
store that depends on the host storage configuration and the
availability of specific containers in that store.

Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
Co-authored-by: Gianluca Zuccarelli <gzuccare@redhat.com>
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
ac45c292e4 sources/containers-storage: call exists() when fetch()ing
Implement fetch_all() and fetch_one() as calls to exists() to make sure
we check that the containers are available every time they are needed.
2024-02-21 17:55:37 +01:00
Achilleas Koutsou
45510aeb64 sources: new source: containers-storage
This source checks for the existence of a local container in the host's
containers-storage. The source first reads the host's
`/etc/containers/storage.conf` file for the storage config and then
checks if the user has imported the desired container into the local
store.

Unlike the org.osbuild.containers stource, the
org.osbuild.containers-storage source doesn't need any extra data other
than the image ID.  The ID is all that is used to retrieve the
container.  The location and other information regarding the storage are
read from the host configuration and are not encoded in the manifest
There's no need to use the name to resolve it like we do in other
sources because containers in the local storage can be directly
referenced by their image id (config digest).

Other data such as the name of the container will only be relevant in
the stage that will use the container as input.

The source items are objects instead of simple strings of checksums
because we might, in the future, want to add specific options for each
source.

The content_type for this source is `containers-storage`, which defines
the location in the store where the source will bind mount the host's
container storage for stages to read.  We make this different from the
containers content because it will be treated differently enough to need
a separate input type.

Co-authored-by: Gianluca Zuccarelli <gzuccare@redhat.com>
Co-Authored-By: Michael Vogt <michael.vogt@gmail.com>
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
26aac90eb4 util/containers: read host config
Add utility function to read the host's container storage config.
2024-02-21 17:55:37 +01:00
Gianluca Zuccarelli
462c498dcf util/mnt: add explicit rw option
Under certain conditions a bind mount without a specified `rw` or `ro`
option gets mounted read-only.  We need a way to be explicit about
needing a rw mount.  We might want to change this in the future to be a
single option (mode optional?) with valid values "rw", "ro".

It's not entirely clear what the conditions are but it occurs when bind
mounting the containers storage into the osbuild store, which we will
need for the next few commits.
2024-02-21 17:55:37 +01:00
Tomáš Hozza
92e75c375c Stages/grub2.legacy: make config options a subset of grub2 stage
While integrating the changes to grub2 config stage options in the
`osbuild/images` repository, I noticed that the code for grub2.legacy
is embedding the grub2 stage config options struct in its own config
options struct [1]. However, the grub2 stage options contain also the
`default` entry, while the grub2.legacy stage does not allow this option
in its stage options.

This change fixes that and ensures that the grub2 stage options config
section is a subset of the grub2.legacy stage options config section.

[1] d5644f3115/pkg/osbuild/grub2_legacy_stage.go (L85)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-21 17:51:28 +01:00
Eric Curtin
134a4cca26 stages/dracut: Add functionality to build initoverlayfs with dracut
As an alternative to just initramfs. Upstream initoverlayfs project:

https://github.com/containers/initoverlayfs

Signed-off-by: Eric Curtin <ecurtin@redhat.com>
2024-02-21 11:53:48 +01:00
Adam Williamson
044d651b5a Fix developer guide link in README.md
Signed-off-by: Adam Williamson <awilliam@redhat.com>
2024-02-20 23:45:20 -08:00
Michael Vogt
efcecd3867 tools: make osbuild-depsolve-dnf5 pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
d4831a8924 tools: make osbuild-mpp pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
a2bb687d54 tools: make gen-stage-test-diff pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
2290aff94d check-snapshots: add log info when a download fails
When a requests.get() fails the exact nature of the error is
currently discarded. This commit adds a small print() to show
what exactly went wrong.
2024-02-20 14:52:23 -08:00
Michael Vogt
34cda2e1e3 check-snapshots: make exception for snapshot cache more targeted
The code in `check-snapshots` will print "No snapshots cache found
at ..." regardless of the error that happens when trying to open
the file. This can be misleading if e.g. the issue is permissions
to open the file or the file is corrupted. So make the exception
more targeted and only catch FileNotFound error and let python
how the full error for the other cases. Obviously this can be
done in many ways so I'm happy to tweak and e.g. keep catching
all exception but print the value etc.
2024-02-20 14:52:23 -08:00
Michael Vogt
2c86e90d05 tools: make check-snapshots pylint clean 2024-02-20 14:52:23 -08:00
Michael Vogt
5c47be179c tox: add all non shell file in tools/ to lintables
Right now the tools directory is not checked by pylint because
it will not auto-detect what files are python files and instead
just skip the dir if it does not have a __init__.py.

This commit uses `tox-backticks` to run a custom find to ensure
the python files are explicitely added. I'm not sure we can
use tox-backticks or we need it packages for fedora/rhel?

If we cannot use it we need to look into either a custom tox
plugin to support more rich globbing or just move out
`tools/set-env-variables.sh` as it's the only non-python code
in the repo and it will trip up pylint (syntax error).
2024-02-20 14:52:23 -08:00
Tomáš Hozza
be1ba5be08 Stages/grub2: extend default config options
Extend the stage to allow explicitly configuring more grub2 default
config options. Preserve the defaults for options which were previously
hard-coded.

Extend the stage unit test to verify setting of the new grub2 default
config options.

Related to https://issues.redhat.com/browse/RHEL-19583

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
84fc4c9903 Extend unit test for org.osbuild.grub2 stage
Test the content of the /etc/default/grub config file based on the
provided stage options.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
7895424b78 Stages/grub2.legacy: extend default config options
Extend the stage to allow explicitly configuring more grub2 default
config options. Preserve the defaults for options which were previously
hard-coded.

Extend the stage unit test to verify setting of the new grub2 default
config options.

Related to https://issues.redhat.com/browse/RHEL-19583

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Tomáš Hozza
21ebed9305 Add unit test for org.osbuild.grub2.legacy
For now, test the content of /etc/default/grub configuration file.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-02-20 19:28:43 +01:00
Brian C. Lane
b131d3cf57 osbuild-depsolve-dnf5: Fix url substitutions
Substitutions should be set on Base, not per-repo. Discovered this
in lorax's dnf5 code so I am updating it here as well.
2024-02-20 09:42:01 +01:00
Brian C. Lane
4f83cdc434 osbuild-depsolve-dnf5: module_hotfixes wasn't really set
Typo in the previous change, wasn't setting `repo.module_hotfixes`
2024-02-20 09:32:43 +01:00
Michael Vogt
43c83c01e6 stages(org.osbuild.systemd.unit.create): add small unit test
Small unit test for the new `org.systemd.unit.create` stage. It
will do basic schema validation checks and ensures that a simple
service definition is correctly translated to a systemd unit.
2024-02-19 15:12:55 +01:00
Evgeny Kolesnikov
46e1bc1e2b stages/oscap.remediation: Mount host's /proc and /dev earlier
We need /dev/urandom for the first pass as well.
2024-02-17 02:10:58 +01:00