Commit graph

4492 commits

Author SHA1 Message Date
Christian Kellner
8a06b9ddf3 osbuild: add bindings for org.osbuild.containers.storage.conf stage
Add support for the `containers.storage.conf` stage with helper
constructors that should make it easy to use.
Add a small test for it.
2022-07-26 17:07:31 +02:00
Achilleas Koutsou
f3c166c3fd CI: fix artifact collection for diff-manifests 2022-07-25 21:23:02 +02:00
Achilleas Koutsou
46b127c898 diff-manifests: never use main explicitly
The base branch name is read from the pull request metadata.  Let's use
it everywhere and never assume `main`.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
b5c47dbe8a test/diff-manifests: warn if generation fails on merge-base
If the manifest generation fails on the merge-base with main (the target
branch of the PR), add a note to the review comment.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
404d1130bd test/diff-manifests: add link to job artifacts in review comment 2022-07-25 21:23:02 +02:00
Achilleas Koutsou
4c7fc8fd4d test/diff-manifests: fail test if manifest generation fails on PR
Fail the test if manifest generation fails on the PR HEAD, but don't
fail if the generation on main fails.
This can happen if something breaks in main (the generator, a
repository, an image definition, etc) and the PR is meant to fix it.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
7f563a6db1 test/diff-manifests: minor change in error handling 2022-07-25 21:23:02 +02:00
Achilleas Koutsou
68227ed18b test/diff-manifests: print gen-manifests output
Don't silence the output.  It should be much less noisy now that the
progress isn't printed on a timer but only when something changes.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
2afc8fd1dd gen-manifests: minor output changes
Don't print "Worker started" message.
Print "done" after submitting all jobs to the queue.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
b20605d9f1 gen-manifests: append message to failed jobs on finish
When the 'Finished' message is printed, append [failed] to the message
if the job encountered an error.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
20b6d3866a gen-manifests: support arch, distro, image type selection
Multiple values can be specified by separating with commas.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
a018c69f90 gen-manifests: simplify flag definitions
Remove the reliance on flag variable pointers and read the argument
values directly into the target variables.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
d61b553045 gen-manifests: don't print progress when nothing changed
Update the progress line only when another line was received, which in
this case means a job has started or finished.
No need to keep reprinting the progress.
2022-07-25 21:23:02 +02:00
Achilleas Koutsou
6e4a55cf9e gen-manifests: print errors on stderr 2022-07-25 21:23:02 +02:00
Christian Kellner
78a96a5414 worker: support for configuring the containers auth file
Add a new configuration section for containers and an option
to configure the authfile in it.
2022-07-25 21:21:44 +02:00
Christian Kellner
ec4598f81f weldr: use worker job to resolve container
The main reason is that there should be only one place where the
container resolution is happening, which is the worker, so that
we only have one central place to configure aspects of it, like
container credentials.
2022-07-25 21:21:44 +02:00
Christian Kellner
50e630a76f worker: add new container resolve job type
This is a new job that can be used to resolve containers. It uses
the existing `container.Resolver` class to do the actual work.
2022-07-25 21:21:44 +02:00
Christian Kellner
c2f3f76d96 container: ability to set AuthFilePath for Resolver
Add a new field `AuthFilePath` and if it is not the empty string,
it will be forwaded that information to `Client`.
2022-07-25 21:21:44 +02:00
Christian Kellner
2c0594629f osbuild: add extraEnv argument to RunOSBuild
This adds the ability to supply extra environment variables to
the osbuild process.
2022-07-25 21:21:44 +02:00
Tomas Hozza
31072c1189 Cloud API: extend a code comment with more information 2022-07-24 08:40:58 +02:00
Tomas Hozza
0614913010 worker/koji-finalize: fix error message 2022-07-24 08:40:58 +02:00
Tom Gundersen
0f5846326c image: introduce image kinds for Fedora
Implement all of Fedora in terms of this new abstraction. What used to be the
manifest functions (and before that the pipeline functions) are now the image
functions, whose purpose is to instantiate the right image kind structs from the
image type definitions we currently have in the distro definition.
2022-07-22 16:04:07 +02:00
Tom Gundersen
5a15608c89 image: add image kind abstraction
This abstracts away the manifest instantiation. The idea is that we define one
of these image kind types to represent a group of image types that are
sufficiently similar. Each image kind will have a struct with with all the
properties that can be customised for the image and a function to turn that into
an actual manifest. This is similar to how distro/fedora/manifest.go and
cmd/osbuild-playground works today, and aspires to move these closer together
and to eventually make the distro definitions simpler.

For now cmd/osbuild-playground is moved over to using the new abstraction.
2022-07-22 16:04:07 +02:00
Tom Gundersen
ce40e1d810 artifact: this represents the artifacts a manifest exports
For now this encapsulates osbuild export and filename in that
exported tree. In the future we could add MIME type.

For now this is a concrete type, but should probably be an
interface, so the consumer of artefacts know they are the right
type. Enforcing we only push AMIs to EC2, etc.

Similarly to how checkpoints work, each pipeline can be marked for
export, and the manifest can return all the names of the exported
pipelines, to be passed to osbuild. Additionally, the Export
function returns an artefact object, which can be used to know how
to access the exports once osbuild is done. For now, this is unused.
2022-07-22 16:04:07 +02:00
Tom Gundersen
9b77e67576 manifest: add Checkpoint()/GetCheckpoints()
If Checkpoint() is called on a pipeline, it is marked for
checkpointing. Calling GetCheckpoints() returns the names of all
its pipelines that are marked for checkpointing as a slice of
strings. This can be passed to osbuild by the caller, in which case
the trees produced by each of these pipelines will be checkpointed
to speed up future builds.

Before this can be used in production we need a mechanism for
automatically cleaning up the cache.
2022-07-22 16:04:07 +02:00
Tom Gundersen
a8f48822e8 platform: include image format
The format of the image is (arguable) a property of the hardware
platform, keep that in the platform abstraction.
2022-07-22 16:04:07 +02:00
Tom Gundersen
5c5c63afd1 manifest/os: split out OSCustomizations
This is meant to encapsulate the tweaks we do to the OS tree
orthogonally to anything else. For now it still contains some
configuration that only sometimes applies, but this should
continue being reworked until all the fields in this struct
always apply to any artefact that is using it.

At the same time, stop instantiating with default values, as the
empty values should work. This is not a functional change as the
caller always sets these now.
2022-07-22 16:04:07 +02:00
Tom Gundersen
0bebc107d2 manifest/os: don't depsolve empty workload
Workloads could contain no packages, in which case, skip depsolving.
2022-07-22 16:04:07 +02:00
Tom Gundersen
a92b672bc7 manifest/anaconda: pull in biosdevname if enabled
Rather than listing this in the package sets, pull it in implicitly
by the pipline that requires it.
2022-07-22 16:04:07 +02:00
Tomas Hozza
5f3f477d47 CI: test cloud upload for Koji composes
Test the functionality only on RHEL-8.6, since this is the version that
Brew workers use. Test only RHUI images, because these will be the ones
to be used with this functionality.
2022-07-22 11:39:49 +01:00
Tomas Hozza
2ff34767cc worker/osbuild: workaround cloud upload for compressed images
The AWS and Azure RHUI images are produced as compressed archives, which
can be uploaded to Koji, but they can't be uploaded to the cloud
provider in this format. To support cloud upload for these types of
images, we need to decompress them before the upload.

Add a workaround for AWS and AzureImage targets to check if the image
has `.xz` suffix and if yes, decompress it before uploading to cloud.

This workaround is needed until image definitions will support and use
multiple exports per image to allow using different export per upload
target.
2022-07-22 11:39:49 +01:00
Tomas Hozza
abc3d31222 test/repos: add AWS and Azure RHUI repos for 86/87/90/91
This is needed in order to be able to test Koji composes with cloud
upload and RHUI images.
2022-07-22 11:39:49 +01:00
Tomas Hozza
85f9f07a1f Cloud API: support cloud upload for Koji composes
Add support to handle upload options in image requests for Koji
composes. The image is always uploaded to Koji, but now it can be
uploaded to the cloud environment in addition to Koji as part of the
build.

The image name used for Koji image can't be used as is for uploading to
the cloud, because each cloud provider has its own requirements for the
valid characters. For now, let the Cloud API implementation generate a
random image name. The name is always returned in the compose status's
upload status, so it should be possible to attach it to the Koji build
to allow users to find the image.
2022-07-22 11:39:49 +01:00
Tomas Hozza
77a1672b79 worker/koji-finalize: handle multiple upload targets
Enhance the `koji-finalize` job implementation to be able to cope with
multiple upload targets being specified for an `OSBuildJob`.

Implement a convenience method `OSBuildJobResult.TargetResultsByName()`
for filtering the target results attached to the job result by their
name. Cover the method with an unit test. And lastly use this method in
the `koji-finalize` job to find the appropriate Koji upload target
results.

This is a preparation for enabling cloud uploads for Koji composes.
2022-07-22 11:39:49 +01:00
Tomas Hozza
58696e849f worker/koji-finalize: always report status back to composer and Koji
Enhance the `koji-finalize` job implementation to use deferred function
to ensure that the job status is always reported back to the composer.
In addition, if the `JobError` is set, also fail the Koji job.

Previously, composer and Koji were not updated in some corner cases when
the job would fail.
2022-07-22 11:39:49 +01:00
Tomas Hozza
1fec2c476d Cloud API: add support for gce-rhui image type
Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-07-22 11:39:49 +01:00
Tomas Hozza
88403dec75 koji.sh: support testing of upload to the cloud
Extend the `koji.sh` test case to allow also testing the upload to
cloud, in addition to the testing that it supports currently (building
of multiple images in one Koji compose request).

The script now reuses some common functions used by the `api.sh` test
case. Once the Koji compose succeeds, the script verifies that the image
is present in the appropriate cloud environment using a CLI tool. No
additional testing of the image is done, it is not booted.
2022-07-22 11:39:49 +01:00
Tomas Hozza
067e58857a koji-compose.py: support Koji composes with upload to cloud
Extend the `tools/koji-compose.py.sh` script to allow also testing the
upload to cloud, in addition to the testing that it supports currently.

If only the `DISTRO` and `ARCH` arguments are passed to the script, it
submits a new Koji compose with two image requests, as it always did.

If a `CLOUD_TARGET` and `IMAGE_TYPE` arguments are provided in addition
to `DISTRO` and `ARCH`, then the script submits a new Koji compose with
a single image request, which has the upload options set to make the
image be uploaded to cloud.

Supported cloud targets are:
 - `aws`
 - `azure`
 - `gcp`

The image types are those that are accepted by the Cloud API. The script
does not check at all if the provided combination of the cloud target
and image type is valid and submits anything that it gets to composer.
2022-07-22 11:39:49 +01:00
Tomas Hozza
250810614e koji-compose.py: use provided arch instead of hard-coding it 2022-07-22 11:39:49 +01:00
Tomas Hozza
9c13f267dc koji-compose.py: print only compose ID to STDOUT
Modify the `tools/koji-compose.py` script to print all log messages to
STDERR and to print only the Koji compose ID to STDOUT. This way, the
caller of the script can easily get the ID of the compose created by the
script and use it later.
2022-07-22 11:39:49 +01:00
Christian Kellner
de72b36ddd ci: test container embedding on CentOS stream 8
Now that we have enabled container embedding on RHEL 8, let's
also test it there.
We also pin it for Fedora and RHEL/CS 9 to be able to use the
new `org.osbuild.containers.storage.conf` stage.
2022-07-21 13:32:07 +02:00
Christian Kellner
d842bdba21 distro/rhel8: support for embedding container
Support for adding containers in non-ostree images. The reason we
don't support OSTree artefacts just yet is that the default storage
location for container is `/var/lib/containers/storage`. But for
OSTree images all content in `/var` is discarded, since that is
deployment specific data. We therefore need to store the containers
somewhere else, e.g. `/usr/share/containers/storage`, but then also
need to configure the system to find containers in that location.
osbuild only recently gained the corresponding stage to do so and
thus this will be done in a follow up.
2022-07-21 13:32:07 +02:00
Christian Kellner
6ee4da1bd5 ci: add container embedding test case
Add a new test case that embeds an existing container store in our
gitlab ci registry into a qcow2 image. It uses `image-info` to
verify that the container, with the expected id, is indeed embedded
in the resulting image.
2022-07-21 13:32:07 +02:00
Christian Kellner
fdb530e29d image-info: add ability to read container images
Add support for reporting the install container images in an image.
NB: this does not use `podman` but reads the overlay storage
directly and therefore does currently not take additional image
locations or different storage drivers into account. For now this
is not a problem since we don't support any of that.
2022-07-21 13:32:07 +02:00
Christian Kellner
0d4fac101c weldr: support container embedding
Add support for resolving containers via `container.Resolvers`.
NB: this happens synchronously in the compose handler, very much
like dep-solving.
2022-07-21 13:32:07 +02:00
Christian Kellner
5f8358ee46 cmd/gen-manifests: support container embedding
Add support for resolving container via `container.Resolver`.
2022-07-21 13:32:07 +02:00
Christian Kellner
a24cc16bb0 cmd/osbuild-pipeline: resolve blueprint container
Add support for resolving containers via `container.Resolver`.
2022-07-21 13:32:07 +02:00
Christian Kellner
2007d67fd2 distro/rhel90: support for embedding container
Support for adding containers in non-ostree images. The reason we
don't support OSTree artefacts just yet is that the default storage
location for container is `/var/lib/containers/storage`. But for
OSTree images all content in `/var` is discarded, since that is
deployment specific data. We therefore need to store the containers
somewhere else, e.g. `/usr/share/containers/storage`, but then also
need to configure the system to find containers in that location.
osbuild only recently gained the corresponding stage to do so and
thus this will be done in a follow up.
2022-07-21 13:32:07 +02:00
Christian Kellner
fbd6d804f0 blueprint: add support for containers
Add a new `containers` section that can be used to request the
embedding of containers into images. The only requirement is
the source property to specify where to fetch the container from.
This suppports specifying the digest of the container or the tag.
In case none is given it defaults to the `latest` tag. The `Name`
field can be used to optionally specify a name to use inside the
image.
NB: currently no tools or apis support container resolution yet.
This follows in the next commits.
2022-07-21 13:32:07 +02:00
Christian Kellner
49b37d672b osbuild: support generating container sources
Modify the existing `GenSources` helper to also support generating
`org.osbuild.skopeo` source for fetching container images.
2022-07-21 13:32:07 +02:00