Commit graph

3946 commits

Author SHA1 Message Date
Ondřej Budai
082da070d1 test: generate manifests for rhel-87 and rhel-91
These are without image-info as discussed in the PR.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 18:13:28 +02:00
Ondřej Budai
c811860771 test-case-generators: add rhel-87 and rhel-91
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 18:13:28 +02:00
Ondřej Budai
df011dbb06 tests: add rhel-87 repositories overrides
This is a bare minimum for our downstream testsuite to pass (otherwise
it will fail on non-existing 8.7 CDN repositories).

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 18:13:28 +02:00
Ondřej Budai
8575620591 distro: add an alias for rhel-91
We would benefit from having support for 9.1 downstream so let's add it in
the form of an alias. This is a bare minimum for having a proper 9.1 support.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 18:13:28 +02:00
Christian Kellner
f212e6690d image-info: dynamically detect the rpm database
Check for the rpm database in $tree/usr/share/rpm and explicitly
also in $tree/var/lib/rpm and if the respective location exists
pass it as argument to rpm. This should fix the situation where
the default database on the host is in a different location than
in the tree. Fedora < 36 and RHEL have the location in /var but
Fedora starting 36 and rpm-ostree have it in /usr.
2022-05-03 12:22:43 +02:00
Ondřej Budai
6fce34a5ea worker: add proxy support to composer and oauth calls
In the internal deployment, we want to talk with composer over a http/https
proxy. This proxy adds new composer.proxy field to the worker config that
causes the worker to connect to composer and the oauth server using
a specified proxy.

NB: The proxy is not supported when connection to composer via unix sockets.

For testing this, I added a small HTTP proxy implementation, pls don't
use this in production, it's just good enough for tests.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
9ee3997428 worker: use custom requester also for oauth refresh
Just so we can share e.g. proxy server or other http transport settings.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
71a4ceecaa worker/client: factor out common testing code
Just so we don't need to care about all the server-side setup in individual
test cases and we can just reuse the setup.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
b4d6ec5a75 worker/client: simplify the oauth test
Firstly, let's use t.TempDir(), it's less code.

Secondly, let's remove all the code that touches distributions, we can just
use random values, both worker server and client actually do't inspect
any values so they can be completely random.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
ed8bcd2f49 worker: move client test to its own file
This test actually verifies that the client code for OAuth works. As this was
the only code that tests client in the file, I think it deserves its own one.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
6e9901fe6b worker: exit(2) when address is missing from argv
Address is always required so not passing one is a clear error, let's return
exit code 2 which go itself returns when bad arguments are passed in.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
Ondřej Budai
6e92263c23 worker: rename config field in Go to reflect its toml name
For the sake of consistency, not a functional change.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-05-03 06:19:31 +01:00
dependabot[bot]
5028b19a71 build(deps): bump github.com/aws/aws-sdk-go from 1.43.42 to 1.44.4
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.43.42 to 1.44.4.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.43.42...v1.44.4)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 10:01:01 +02:00
Christian Kellner
98b491fcac distro/rhel85: automatically convert to LVM on fs customizations
Whenever we create a new mountpoint due to a user customization,
ensure the layout uses LVM, i.e. convert plain layouts to it, if
needed. This does not apply to rpm-ostree based systems.
Add "lvm2" to the build pipeline and thus generate new manifests
and image infos.
Adjust the existing tests that assumed we can not create more
than 4 partitions on mbr layouts, since that is now not true
anymore.
This is a port from rhel86, commit 63aa155

The change in osPipeline() is required now to fix the Prefix for the
bootloader specification when LVM is used. The unspecified Prefix, which
was previously used for all cases, defaults to "/boot". When the layout
is converted to LVM, a boot partition is created and the BLS Prefix
should be set to "".

In the case where we don't have a partition table, the BLS stage is not
needed, but it was done unconditionally before, so keep the default
image definitions unchanged.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-04-30 12:37:50 +01:00
Christian Kellner
bd6b8e7128 distro/rhel85: reformat distro build package list
One package on each line, makes future changes easier to follow.
No actual change of packages in this commit.
2022-04-30 12:37:50 +01:00
Tomas Hozza
8ee90334ba generate-all-test-cases: add manifests command
Add `manifests` command for generating image test cases without
`image-info` report, so only manifests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-04-29 12:13:00 +02:00
Tomas Hozza
01864e4db7 Don't support gce-rhui image type on CentOS Stream 8
The RHUI variant of the GCE image is intended only for RHEL.
2022-04-29 09:24:40 +02:00
Achilleas Koutsou
d357f92f91 test: add fs customization to qcow2 test case
Added a filesystem customization to the qcow2 test case to test that the
filesystem is converted to an LVM layout.
Set overrides for distros that don't support fs customizations.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
ceb64b43fe test: disable full image building in generation.sh
The purpose of the test is to check that the dnf-json socket can be
started automatically when running the test case generator while the
service or socket isn't enabled/started.

dnf-json will still be used to depsolve the packages and create the
manifest even if the image is not built.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
8be2c5c89a disk: test minimum directory size calculations
/ and /usr have minimum sizes defined (1 GiB and 2 GiB respectively).
When /usr is not defined, the minimum size of /usr gets added to the
minimum size for /.
This new test runs through a few scenarios and checks whether the sizes
fit.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
b8cd4bb839 disk: add an empty blueprint to the tests
Adjusted tests accordingly
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
ae9960b8db disk: test that all mountpoints are the minimum 1 GiB
This tests that the clampFSSize() function ensures all user-defined
mountpoints are at least 1 GiB.
Added a blueprint with < 1 GiB minsizes to test this.
Testing all blueprints in TestCreatePartitionTable() now.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
61be84d634 disk: define blueprint map for test
Convenient for iterating and to define more cases.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
9920d798f5 disk: remove special case for /usr in clampFSSize
The `/usr` case is now handled by the `EnsureDirectorySizes()` function.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
275e60f199 disk: add default minimum directory sizes
Currently, we only specify a minimum size for
- `/` (1 GiB), and
- `/usr` (2 GiB).

This ensures that
- a separate `/usr` partition is at least 2 GiB,
- `/` is always at least 1 GiB,
- if `/usr` it not a separate partition, `/` is at least 3 GiB.

We could (or should), in the future, make it possible for image types to
override this mapping as part of their default config, for example, if
an image type by default requires a larger `/usr`.
2022-04-29 08:55:36 +02:00
Achilleas Koutsou
efa10e56e1 disk: use constants for size units in tests
Makes the test values more readable (without needing comments).
Some values in the default partition table were fixed, e.g., cases where
we had `Size: 1024000, // 500 MB`.
2022-04-29 08:55:36 +02:00
Christian Kellner
b365b18390 disk: fix ensureLVM for partition tables without /boot
When the partition table did not have a boot partition, we created it
but then _unconditionally_ returned, which meant that we did not create
the LVM skeleton and wrap the root partition. Properly handle this case
and also re-initialize the `rootPath` in this case since we change the
underlying `Partition[]` array in `PartitionTable` object. Add an extra
blueprint with only one customization which exposes this bug.

Co-Authored-By: Achilleas Koutsou <achilleas@koutsou.net>
2022-04-29 08:55:36 +02:00
Sanne Raymaekers
e3f812f6fd Schutzfile: Pin osbuild version to use minimal required caps 2022-04-28 16:38:42 +02:00
Tomas Hozza
81fc032a45 RHEL-90: don't pass blueprint package set separately to pipelines
Blueprint package set is now depsolved together with the OS package set
in a chain. The result is stored in the package specs sets under the OS
package set name.

In reality, the code was able to handle a `nil` package specs to be
passed to pipelines, however some parts were looking for the kernel
version in the blueprint package specs, which would be a bug.

Regenerated affected image test cases.
2022-04-28 14:42:49 +02:00
Tomas Hozza
e6a20699f9 RHEL-90beta: don't pass blueprint package set separately to pipelines
Blueprint package set is now depsolved together with the OS package set
in a chain. The result is stored in the package specs sets under the OS
package set name.

In reality, the code was able to handle a `nil` package specs to be
passed to pipelines, however some parts were looking for the kernel
version in the blueprint package specs, which would be a bug.

Regenerated affected image test cases.
2022-04-28 14:42:49 +02:00
Tomas Hozza
c26a1839d1 RHEL-86: don't pass blueprint package set separately to pipelines
Blueprint package set is now depsolved together with the OS package set
in a chain. The result is stored in the package specs sets under the OS
package set name.

In reality, the code was able to handle a `nil` package specs to be
passed to pipelines, however some parts were looking for the kernel
version in the blueprint package specs, which would be a bug.

Regenerated affected image test cases.
2022-04-28 14:42:49 +02:00
Tomas Hozza
4c707663f2 RHEL-85: don't pass blueprint package set separately to pipelines
Blueprint package set is now depsolved together with the OS package set
in a chain. The result is stored in the package specs sets under the OS
package set name.

In reality, the code was able to handle a `nil` package specs to be
passed to pipelines, however some parts were looking for the kernel
version in the blueprint package specs, which would be a bug.

Regenerated affected image test cases.
2022-04-28 14:42:49 +02:00
Tomas Hozza
800ac5fe0b Weldr: use rpmmd.DepsolvePackageSets() in compose handler
Use `rpmmd.DepsolvePackageSets()` in Weldr API compose request handler,
instead of `rpmmd.Depsolve()`.

Extract common code from `API.allRepositories()` and
`API.allRepositoriesByImageType()` to a new method
`API.payloadRepositories()`.

Modify `API.allRepositoriesByImageType()` to return payload repositories
(repositories defined by user) as a separate slice to enable the use of
`rpmmd.DepsolvePackageSets()`, which requires the package-set-specific
repositories to be passed separately.

Keep using `rpmmd.Depsolve()` in Weldr where appropriate. The
implementation depsolves various simple package sets for multiple API
request handlers and it does not make sense to complicate the code by
moving to `rpmmd.DepsolvePackageSets()`.
2022-04-28 14:42:49 +02:00
Tomas Hozza
21c6c452ef TestDistro: return dummy values from PackageSets related methods
Return dummy values from the following methods:
 - PackageSets
 - PayloadPackageSets
 - PackageSetsChains

Use package set names commonly used by recent distro definitions.
Package sets are based on values used by rpmmd mock implementation.

Adjust two Weldr API unit test check for the dummy values. Without
this fix, these unit tests would start failing after the move to
`rpmmd.DepsolvePackageSets()` in Weldr API compose handler.
2022-04-28 14:42:49 +02:00
Tomas Hozza
42b3512b12 Delete TestImageType methods not required by ImageType interface 2022-04-28 14:42:49 +02:00
Tomas Hozza
b92196a056 kojiapi: use DepsolvePackageSets instead of Depsolve 2022-04-28 14:42:49 +02:00
Tomas Hozza
694230b453 TestDistro_Manifest: use DepsolvePackageSets instead of Depsolve 2022-04-28 14:42:49 +02:00
Tomas Hozza
e819e08098 worker: extend the depsolve job to use DepsolvePackageSets()
Extend the `DepsolveJob` worker job argument to contain package sets
chains and use `DepsolvePackageSets()` for depsolving.
2022-04-28 14:42:49 +02:00
Tomas Hozza
ac8b0b211c osbuild-store-dump: use DepsolvePackageSets instead of Depsolve 2022-04-28 14:42:49 +02:00
Tomas Hozza
906e88ea8c osbuild-pipeline: use DepsolvePackageSets instead of Depsolve 2022-04-28 14:42:49 +02:00
Tomas Hozza
ef4db9edda rpmmd: introduce DepsolvePackageSets() to the RPMMD interface
Add a convenience method `DepsolvePackageSets()` to the `RPMMD`
interface. The method is expected to depsolve all provided package sets
in a chain or separately, based on the provided arguments, and return
depsolved PackageSpecs sets.

The intention is to have a single implementation of how are package sets
depsolved and then use it from all places in composer (API and tools
implementations).

Adjust necessary mock implementations and add a unit test testing the
new interface method implementation.
2022-04-28 14:42:49 +02:00
Tomas Hozza
fee529cd0a distro: introduce PackageSetsChains() method to ImageType
Introduce a new method `PackageSetsChains()` to the `ImageType`
interface, which returns a named lists of package sets, which should be
depolved together in a chain.

Extend all distro implementations with the new method.

Add a unit test ensuring that if an image type defines some package set
name chains, that all of the listed package set names are present in the
package set map returned by the image type.

The method is currently not used anywhere. This is a preparation for
switching from current way of depsolving to the chain depsolving.
2022-04-28 14:42:49 +02:00
Tomas Hozza
04d45a0fce rpmmd: switch Depsolve() internal implementation to chainDepsolve()
Replace the `rpmmdImpl.Depsolve()` internal implementation by a call to
`rpmmdImpl.chainDepsolve()`.
2022-04-28 14:42:49 +02:00
Tomas Hozza
d48da99a12 rpmmd/dnf-json: support chain dependency solving
Add a new `rpmmdImpl` method `chainDepsolve`, which is able to
depsolve multiple chained package sets as separate DNF transactions
layered on top of each other.

This new method allows to depsolve the `blueprint` package set on top of
the base image package set (usually called `packages`).

Introduce a helper function `chainPackageSets` for constructing
arguments to the `chainDepsolve` method based on the provided arguments:
 - slice of package set names to chain as transactions
 - map of package sets
 - slice of system repositories used by all package sets
 - map of package-set-specific repositories

Extend `dnf-json` with a new command `chain-depsolve` allowing to
depsolve multiple transaction in a row, layered on top of each other.

Add unit tests where appropriate.
2022-04-28 14:42:49 +02:00
Achilleas Koutsou
0f0b2072d5 test: update test manifests
Update GPG keys in all RHEL 8.x test manifests.
2022-04-28 09:50:27 +02:00
Achilleas Koutsou
81c62204b9 repositories: update gpg key for all RHEL 8.x repos
Follow-up to 60db6ad06f

The SHA-1 key is no longer supported in RHEL 9.0.  This isn't a problem
for RHEL 8.x in general, but it prevents cross building RHEL 8.x images
on RHEL 9.0, since the host (RHEL 9.0) rpm and openssl cannot import the
older keys and we fail to bootstrap the build root for the new image if
the source repositories use SHA-1 keys.

Related rhbz#2058497 (Comment 18).

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2022-04-28 09:50:27 +02:00
Achilleas Koutsou
389b7c1848 Unify formatting for all repository json files
- 2 space indent
- lists on multiple lines
- newlines at EOF

This was accomplished by simply running each file through `jq` with no
arguments.
It is also equivalent to Python's `json.dump(..., indent=2)` plus the
added newline.
2022-04-28 09:50:27 +02:00
Achilleas Koutsou
55a2e8ddac disk: add function for resizing Entities based on dirs
New function that ensures that a partition can hold the total sum of all
the required sizes of specific directories on the partition.  The
function sums the required directory sizes grouped by their mountpoint
and then resizes the entity path of that Mountable.
2022-04-27 13:49:19 +02:00
Achilleas Koutsou
ce5a28c113 disk: add function for finding entity path for a dir
New function that returns the Entity path for the Mountpoint that
contains a given directory path.
2022-04-27 13:49:19 +02:00
Achilleas Koutsou
75a0a74064 disk: add docstring for resizeEntityBranch()
resizeEntityBranch() is a private function, but it's not immediately
clear how it works so a docstring is useful for internal development.
2022-04-27 13:49:19 +02:00