Commit graph

5362 commits

Author SHA1 Message Date
Tomáš Hozza
1ea58566ff tools/tc-generators/format-req-map: drop all rhel-edge-* requests
Drop unused `rhel-edge-*` requests, which are not used any more. They
have been replaced by `edge-*` requests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
aa9373cb18 Test: use dir and file customizations in qcow2 image manifests
Add the new directories and files customization to the customized qcow2
image manifests used for testing.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
e9af3bda64 Cloud API: expose directory and file customizations
Expose the Directory and File customizations in the Cloud API. Also
validate the provided customizations while processing the compose
request by trying to convert them to internal representations
`fsnode.File` and `fsnode.Directory`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
15f1962c34 Cloud API: add error for failed customization validation
Add new error `ErrorInvalidCustomization` used in situations when the
user-provided customization values don't pass validation. This will be
used by the Directory  / File customization.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
ffd0bdb7ad distro: add dir / files customizations policy check
Add a default policy for custom directories and files to constrain what
users can do. The intention is to ensure that directories and files can
be created only in `/etc` and also that none of the important
configuration files can be overwritten by this customization.

Add the policy validation to all distro implementation.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
3ee973c8ee blueprint: add functions checking dir / file customizations policy
Add helper functions for checking directory and file blueprint
customizations against the policy of allowed paths.

These functions are not yet used in the distro definitions.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b98f5dad70 distro: set dir / file BP customizations in OS customizations
Hook up the custom BP directories and files implementation with OS
pipeline implementation. The user-provided values are now set in the OS
customizations structure and will be used by the OS pipeline generator
when adding stages to the pipeline.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
4e2b369acf SPEC: depend on osbuid v78
The version 78 is needed in order to use the `chown` stage.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0e2f221514 distro: validate directory / file BP customizations
Validate the user-provided directory and file BP customizations in
`checkOptions()`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
a6dd4943c5 blueprint: add function for validating dir and file customizations
Add a helper function for validating the user-provided directory and
file customizations. This is necessary to fail early on invalid input,
instead of when building the image.

The function ensures that:
- No file path is a prefix of another file or directory path
- There are no duplicate file or directory paths in the
  customizations

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
053c1b090f blueprint: add functions converting dir and file customizations
Add helper functions for converting slices of directory and file
customizations structures from the `blueprint` package to a slice of
structures from the `fsnode` package, which are used in image type
definitions.

These will be used to convert BP customizations to the os pipeline
customization then used by the pipeline generator.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
c1991b3d51 blueprint: add representation of Directories and Files customization
Extend the Blueprint customizations with the representation for custom
Directories and Files specified by the user.

Implement custom Unmarshalers for TOML and JSON. These ensure that all
user-provided values are validated before use and also handle the fact
that user and group ownership for directories and files can be
specifies as a string or as an integer.

Implement helper functions for converting the Blueprint-specific types
for these customizations to their internal representation from `fsnode`
package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
26e6983320 disk: move remaining mountpoint policy code to different packages
Move the `CheckMountpoints()` implementation to `blueprint` package,
since it does not operate on any data structures from the `disk`.

Move the default mountpoint allow list policy definition to the
`pathpolicy` package.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
eb0531b89b blueprint: move FilesystemCustomization code to separate file
Move the `FilesystemCustomization` structure and its custom
unmarshallers to a dedicated file. This makes `customizations.go` easier
to read.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
3075d3a2ad disk: separate PathPolicies implementation to its own package
The `PathPolicies` implements a generic concept that can be fit on more
use cases than just mountpoints. Another one would be a policy for
creating custom files and directories in the image. Having the
implementation in the `disk` package and using data structures from the
`disk` and `blueprint` packages makes it impossible to use it for any
additional BP customization due to a circular dependencies that always
occurs.

Split out the implementation into a separate package `pathpolicy` as the
first step.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b3f695db72 manifest/os: support directories and files customization
Extend the `OSCustomizations` with a list of custom files and
directories, that should be created in the image. If any `Files` or
`Directories` are specified in the `OSCustomizations`, the appropriate
osbuild stages will be added to the `os` pipeline. In addition to that,
any custom files data will be returned by the `getInline()` method of
the `os` pipeline.

This customization can't be yet used by users, because the translation
from BP customization to the `OSCustomizations` is missing.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
acfceb74b2 osbuild: add variadic version of Pipeline.AddStage() method
This will allow to conveniently add multiple stages to the pipeline at
once, which is useful if a generator function wrapping some
functionality generates more than one `Stage`.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b36c03f20c manifest/os: move the systemd services stage more to the end
Move the handling of the list of enabled and disabled systemd services
more to the end of the `os` pipeline, just before the SELinux stage.
This has no functional effect on produced images, but it will make it
nicer once the handling of the custom files and directories will be
added to the pipeline. Specifically it should be added right before the
services stage to allow enabling custom service files, but after all
other configurations that are applied to the image.

Regenerate all manifests.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
fd79934843 osbuild: add helper functions generating stages from fsnode types
Implement helper functions for generating osbuild stages for a slices of
`fsnode` types, such as Files and Directories. The generated stages will
ensure that the provided FS nodes will be created in the FS tree and
will have their respective properties set (such as ownership, mode,
etc).

These functions are not yet used by any pipeline code, but the idea is
that they will be used in pipeline generator functions to create custom
directories and files based on the pipeline-specific customizations.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0bd0ce9fc1 osbuild: add support for org.osbuild.chown stage
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
2e54557cd4 osbuild/copy: support files input
Add support for files input in the copy stage. This will enable copying
inline sources as a custom files in the image filesystem tree.

Add a simple unit test covering the use of this stage input.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
b007b0ea12 internal/fsnode: add API for custom directories and files
Add an internal API for working with custom FS nodes such as Files and
Directories. This implementation is agnostic to external API, such as
Weldr API, Cloud API or osbuild stages. The purpose of it is to be the
common translation layer between all of these "external" APIs and
osbuild.

In this stage, the representation for Files and Directories is added.

The functionality is not yet used by any existing code.

Note about user/group type being `interface{}`:
I considered using the internal `users` representation for users and
groups, but it contains additional information, which are not relevant
for FS node user / group ownership representation. Therefore I didn't
use it. I also considered using separate variables for user / group
name (string) and uid / gid (int64). However, the implementation would
need to ensure that only one of these typed values is set for user /
group or ensure that it refers to the same group / user. My estimate
was that the code ensuring that only one of these typed values is set
would be probably as complex as the current implementation that checks
the types stored in `interface{}` typed variable. And ensuring that
the set user / group name and uid / gid is referring to the same user
/ group is nearly impossible to get right without actually building
the image.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
0e4dabd265 blueprint: delete HasIgnition() function
Unify how are allowed options checked in distro implementation in
relation to Ignition customization. Specifically, delete `HasIgnition()`
function and replace its use by `GetIgnition()` call and checking if it is
`nil`. This approach is consistent with how this is checked for other
customizations.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
317565f2c4 blueprint: delete unused HasFDO() function
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Tomáš Hozza
772a131d35 osbuild/copy: add TODO comment related to GenCopyFSTreeOptions()
The `GenCopyFSTreeOptions()` function has unused argument
`inputPipeline`. After discussing this with @achilleas-k, we determined
that it would be for the best to refactor this function and split out
the part that generates Mounts and Devices and instead return the actual
Stage from it. The reason for splitting out Mounts and Devices is that
these are then reused also by other stages when constructing pipelines
inside composer.

This would be a bigger change, so just adding the comment to the code to
capture this future work.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-02-22 12:17:36 +01:00
Mario Cattamo
b68cf83a8e Update boot location for Fedora 37 edge-commit 2023-02-21 09:46:27 +01:00
Jakub Rusz
004c4e8acc Gitlab CI: Run libvirt.sh tests on GCP
We can now use GCP runners in our CI. Let's test them out by running all
of libvirt tests for starters.
2023-02-20 14:24:09 +01:00
Sanne Raymaekers
96b42b5791 internal/worker: add String to clienterrors.Error struct
This should make the logging better when errors have another error
struct.

Fixes #3272
2023-02-16 00:55:34 +01:00
Juan Abia
5a62453190 Remove cloud cleaner
cloud cleaner is now being executed in it's own repo.
2023-02-15 17:23:35 +01:00
Juan Abia
197cd47e0b test/cases: move CIV options into a variable
In order to provide different options when running CIV from it's own CI,
move them to the variable CIV_OPTIONS
2023-02-15 17:23:35 +01:00
Thomas Lavocat
be48279af8 schutzfile: update OSBuild's ref
Image-info needs to have support for mounting the devices with their
respective mount options. Otherwise it will fail schema validation.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
aba981c508 tools/image-info: bad syntax on rhel8 python
We can't use:

with (a() as b, c() as d):
    pass

On older versions of python.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
15d80a0cd1 tools/image-info: cosmetics, autopep8 2023-02-14 14:37:10 +01:00
Thomas Lavocat
36d890d452 toos/image-info: use SECTOR-SIZE
Instead of numerical value
2023-02-14 14:37:10 +01:00
Thomas Lavocat
0324e02659 tools/image-info: support iso
Add the support for ISOs. Mounting then as a loopack device and then
accessing the content as a tarball
2023-02-14 14:37:10 +01:00
Thomas Lavocat
d0be1ec5a4 tools/image-info: validate with osbuild's schemas
Before we were invoking osbuild's stages/devices/mounter directly
without taking the time to validate that the options sent were actually
valid and supported.
This commit adds the support of the validation schema into image-info so
that we're sure we don't mess with the internals when we call them.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
ffd45d635a tools/image-info: mount with the mount options
Before the new version of image-info was ignoring the mount options for
the devices leading to errors in the resulting json.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
62e6bed23d tools/image-info: clean placeholder try block
Was only there to ease diffing previous commit.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
31e3729236 tools/image-info: use osbuild's internal to mount
On the newest versions of rhel 92, 88, a change in behavior makes the
previous version of image-info failing to mount loopback devices. We've
tracked down this error to be a race condition on udev, yet without
understanding what changed for now.

Osbuild had for some time already a cleaner way to mount partitions.
osbuild has some machinery to opt out of block device handling in udev
48a4419705/devices/org.osbuild.loopback (L69)
Using this fixes the issue at hand.

This changes the way we need to mount all the partitions, including the
LVM ones. This new mechanism might also pave the way to include lusks fs.
2023-02-14 14:37:10 +01:00
Thomas Lavocat
aaddca445d tools/image-info: fix mypy errors 2023-02-14 14:37:10 +01:00
Antonio Murdaca
71ca1d0e9a regenerate manifests
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-14 12:07:23 +01:00
Antonio Murdaca
6afab3dff2 rhel9: fix conditionals for sysroot.readonly enablement
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-14 12:07:23 +01:00
Antonio Murdaca
1b9e008c29 rhel8: remove sysroot.readonly functionality
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-14 12:07:23 +01:00
Brian C. Lane
6846f59ff4 manifest: Add tests for subscriptions
There are 3 different ways for subscriptions to be setup, test the
pipeline to make sure it includes the correct commands, and check the
package set chain to make sure it includes the packages needed to
support the selected subscription mode.
2023-02-09 09:41:15 +01:00
Brian C. Lane
6944d15293 cloudapi: Add a test for the subscription rhc flag
This makes sure that the new flag is accepted by the API endpoint.
2023-02-09 09:41:15 +01:00
Brian C. Lane
b0e388d115 cloudapi: Add subscription option for rhc
When rhc is selected it will install the required packages, register
using rhc and always enable insights.

When rhc is not selected it will use subscription manager for
registration, and optionally enable insights. Also installing required
packages.
2023-02-09 09:41:15 +01:00
Jakub Rusz
3cdfa9d7f0 internal/prometheus: add more buckets for job durations
We were hitting the limit on stage, let's increase it.
2023-02-08 12:33:10 +01:00
Diaa Sami
20c6fad7c2 osbuild-worker/koji: Add logging for koji requests/responses 2023-02-08 11:40:34 +01:00
schutzbot
4e574b6e99 Post release version bump
[skip ci]
2023-02-08 08:25:30 +00:00
Antonio Murdaca
b8ddbd3031 internal/distro/rhel9: enable ignition on 9+
Signed-off-by: Antonio Murdaca <antoniomurdaca@gmail.com>
2023-02-07 13:30:22 +01:00