Commit graph

4512 commits

Author SHA1 Message Date
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
Christian Kellner
7f3f016ed1 distro: add containers arg to ImageType.Manifest
This is the first step to support embedding container images. Here
we add the `containers []container.Spec` argument to supply images
with resolved container specifications. For now all distros will
return an error in case a container is actually supplied since none
of them currently support embedding containers. NB: also no apis or
tools will actually resolve containers.
2022-07-21 13:32:07 +02:00
Christian Kellner
f8804358a4 osbuild: add new org.osbuild.skopeo stage
Add bindings for the `org.osbuild.skopeo` that can be used to copy
container images, accessed via the `org.osbuild.containers` input,
into images.
The constructor is designed with ease of use in mind and takes
the needed container inputs and the storage path option, i.e.
where to store the container in the images.
2022-07-21 13:32:07 +02:00
Christian Kellner
718b0c0c32 osbuild: add support for org.osbuild.container inputs
Add bindings for `org.osbuild.conainer` inputs which can be used to
supply containers to stages. Currently only fetching containers via
sources is supported.
2022-07-21 13:32:07 +02:00
Christian Kellner
513ae6d3d0 osbuild: add support for the org.osbuild.skopeo source
Add bindings for the `org.osbuild.skopeo` source that can be used
to fetch container images from container registires.
2022-07-21 13:32:07 +02:00
Christian Kellner
b4f890a909 container: add tests for resolver
Add checks for the new `container.Resolver`, including the failure
case.
2022-07-21 13:32:07 +02:00
Christian Kellner
76d80295fa container: add new resolver helper
Add a new class `container.Resolver` which can be used to resolve
multiple container images to their respective ids in parallel.
It should make it easy for all existing tools and api endpoints
to adpot container resultion.
2022-07-21 13:32:07 +02:00
Christian Kellner
dcbdcf4419 container: simple client resolver tests
Add some basic checks for the new `client.Resolve` method.
Specifically that pinning down the ids is working as expected.
2022-07-21 13:32:07 +02:00
Christian Kellner
60135dd5df container: add mock container registry for testing
Create a small only mock container registry to test `Client`.
Currently the registry is read-only and thus cannot be used
for upload tests but it can and will be used for container
resolution checks.
2022-07-21 13:32:07 +02:00
Christian Kellner
60607af26c container: ability to resolve containers to specs
Add a new `Resolve` method to `Client` that will resolve its `Target`
to the corresponding manifest digest id and its corresponding iamge
identifier. The former can be used in the URL to fetch a specific
image from the registry via `<name>@<digest>` and the latter uniquely
identifies a container image via the hash of its configuration object.
This should stay the same across pulls and is also the id returned via
`podman pull` and `podman images`.
Since (most) container images are OS and architecture specific a tag
often points to a manifest list that contains all available options.
Therefore the resolve operation needs to choose the correct arch for
image. A new pair of getters `Set{Architecture,Variant}Choice` lets
the user control which architecture/variant is selected during the
resolution process.
2022-07-21 13:32:07 +02:00
Christian Kellner
bd42243882 container: set default auth file path to sane location
Ensure that the `Client.AuthFilePath` points to a sane location,
which here means that the location is either accessible by the
current user or does not exist. This is because any other error
opening the auth file with lead to a overall failure when trying
to access container registries, even if the target resources is
public.
The reason we have to set it ourselves is that by default the
containers library looks in a sub-path of `XDG_RUNTIME_DIR` and if
that variable is not set it falls-back to `/run/containers/<uid>`.
Since `XDG_RUNTIME_DIR` is indeed not set for the composer process
started via systemd, it will fall-back, but it does not have access
to `/run/containers` and finding the authorization info for any
request will fail with "permission denied".
Add a setter so that we can set the `Client.AuthFilePath` to a
different location than the default one.
2022-07-21 13:32:07 +02:00
Christian Kellner
e53b9c8bb2 container/client: rework credentials storage
Instead of keeping an extra field in `Client`, we just use the
existing `sysCtx.DockerAuthConfig` structure. When the context
is later copied during the upload operation the credentials
will be copied as well. It also saves us from syncing the
credentials if we directly use said `sysCtx` for operations.
2022-07-21 13:32:07 +02:00
Christian Kellner
865a899f70 container/client: rework tls settings
Instead of having an extra field, `TlsVerify`, on the `Client` and
then later setting the corresponding `SystemContext` options, use
the existing `SystemContext` field of `Client`. The corresponding
field is a tri-state: unset, true, false, which is represented as
a pointer to boolean in the `Client`'s new getter and setter. This
also inverts the boolean logic from verify TLS to skip TLS which
aligns very well with the corresponding fields in the upload target
struct.
In addition we properly capitalize some existing variables.
2022-07-21 13:32:07 +02:00
Christian Kellner
4b67e12958 ci: install gpgme-devel for db test
This prepares the usage of the `internal/container` from composer
directly, as opposed to the existing use in the worker. Said pkg
uses the `containers/image/v5`, which uses `proglottis/gpgme` and
the latter needs the gpgme C library. We therefore install it and
its dependencies.
2022-07-21 13:32:07 +02:00
Christian Kellner
4c55063a55 Dockerfile-ubi: install gpgme devel package in builder
The go package `proglottis/gpgme` a dependency of `containers/image/v5`
package uses `libgpgme`. In the near future `internal/container`, which
depends on `containers/image/v5`, will be used directly in composer and
thus we need to install the `gpgme` devel package and its build deps.
2022-07-21 13:32:07 +02:00
Christian Kellner
f76b1545ca test/diff-manifests.sh: install build dependencies via spec file
This test is compiling `gen-manifests` via `go run` and thus needs
to pick up build requirements for the source. Instead of manually
installing the go toolchain use the `dnf build-dep` command on the
spec file so we pick up current and future build dependencies.
2022-07-21 13:32:07 +02:00
Jakub Rusz
f93b38c1a8 CI: fix ci_details artifact placement
The output of the ci_details.sh needs to be placed in the /tmp/artifacts
in order to be uploaded with the rest of the artifacts.
2022-07-21 13:17:45 +02:00
Jakub Rusz
151a9f5c86 tests/filesystems: Fix error checking
Checking the results of each scenario separately and making it more
clear what has actually failed.
2022-07-21 13:17:45 +02:00
Alexander Todorov
6e6f595c1a ci: Disable some Fedora-36 OStree testing due to #2702 2022-07-21 12:19:38 +03:00
Alexander Todorov
0cbac05d42 tests: Temporarily disable cloud-image-val util CLOUDX-54 is resolved 2022-07-21 12:19:38 +03:00
Alexander Todorov
9960021a56 Update version of cloud-image-val b/c of failure on Fedora-36
the test scenario which failed appears to be a noop on Fedora-36
and has been tagged appropriately in cloud-image-val.
2022-07-21 12:19:38 +03:00
Alexander Todorov
63a4ae7626 Update fedora-36 manifests 2022-07-21 12:19:38 +03:00
Alexander Todorov
9cf8054d21 Add fedora-36.json repo definitions 2022-07-21 12:19:38 +03:00
Alexander Todorov
d36e005b37 Update tests with config for Fedora 36 2022-07-21 12:19:38 +03:00
Alexander Todorov
4dab7b74cf COMPOSER-1623: Enable Fedora 36 testing 2022-07-21 12:19:38 +03:00
Ondřej Budai
0adbce3606 test/koji: remove the old code for testing koji API
Koji API is no more, let's drop the test and rename koji-compose-v2.py to
koji-compose.py.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-07-19 16:00:52 +02:00
Ondřej Budai
e779562f3c worker: remove osbuild-koji job
Koji API removed by the previous commit was the last user of osbuild-koji job.
Let's remove it since nothing uses it. This also removes all of the
compatibility code in Cloud API, see concerns below:

Compatibility concerns:
- the internal deployment was moved to a completely different composer
  instance, thus there are no old jobs
- Fedora deployment is still unused in prod, thus we don't care about keeping
  backward compatibility of the old jobs

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-07-19 16:00:52 +02:00
Ondřej Budai
74eb3860df internal: remove kojiapi
We no longer use it, let's remove it. If you are wondering what to use instead,
use Cloud API. It supports everything that Koji API supported and more.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-07-19 16:00:52 +02:00
Ondřej Budai
058edd3d76 cloudapi: remove a confusing test
This test tested two things:

1) Invalid route - this is already covered by TestUnknownRoute
2) Invalid UUID in the compose status route - this is now covered by
   TestComposeStatusInvalidUUID

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-07-19 16:00:52 +02:00
Ondřej Budai
3e25f5ef76 remove all traces of fedora 34
Fedora 34 is EOL, let's remove all traces of it, including:

- distro definition
- repositories (and test one)
- test manifests
- special package set rules
- hacks from the spec file

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-07-18 20:38:33 +02:00
Chloe Kaubisch
86971ca312 templates: update dashboards to include tenant
Add a tenant variable to the composer dashboard, with the option
to select multiple tenants. Add tenant filter to queries accordingly.

link to dashboard: https://grafana.stage.devshift.net/d/image-builder-worker-with-tenant/image-builder-worker?orgId=1
2022-07-18 18:55:13 +02:00