Commit graph

437 commits

Author SHA1 Message Date
Christian Kellner
7059995268 osbuild-pipeline: support for ostree arguments
Add support for an "ostree" object that can contain the usual
"ref", "parent" and "url" option for ostree based artifacts.
2021-08-27 12:56:54 +02:00
Jakub Rusz
37b14facd3 tests: update base tests for weldr-client
weldr-client returns different json structures than the original
composer-cli does. It is being replaced in RHEL-9 and these changes make
it possible to run the tests with both old composer-cli and
weldr-client.
2021-08-25 19:16:04 +02:00
Jakub Rusz
a3ac31a483 ci/tests: scheduled cloud-cleaner for Azure
This introduces a script to run cloud-cleaner with a schedule. It's
currently working with Azure only and therefore needed a change to
cloud-cleaner code as well. Using azure-cli it gets a list of resources
from $AZURE_RESOURCE_GROUP and then sorts out only resources that
are older than $HOURS_BACK and are not storage accounts.
Then it processes the list further leaving only list with unique
TEST_ID to supply to the cloud-cleaner.
2021-08-19 09:04:28 +02:00
Ondřej Budai
1516c1987e test/image: fix pipeline exports for v2 manifests
Previously, we just assumed that all test manifests are of version 1, or we
should export the pipeline named assembler. However, this is no longer true
in RHEL 8.5 and 9 - they are only manifest v2 and they don't have a pipeline
named assembler.

This commit introduces a new way to guess the export name - if the manifest
is of version 1, we just export the assembler. In the case v2 manifest, the
last pipeline is exported.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-08-17 15:53:08 +02:00
Martin Sehnoutka
1ada606ed8 internal/rhsm: introduce package that handles subscriptions
The problem: osbuild-composer used to have a rather uncomplete logic for
selecting client certificates and keys while fetching data from
repositories that use the "subscription model". In this scenario, every
repo requires the user to use a client-side TLS certificate. The problem
is that every repo can use its own CA and require a different pair of
a certificate and a key. This case wasn't handled at all in composer.

Furthermore, osbuild-composer can use remote workers which complicates
things even more.

Assumptions: The problem outlined above is hard to solve in the general
case, but Red Hat Subscription Manager places certain limitations on how
subscriptions might be used. For example, a subscription must be tight to
a host system, so there is no way to use such a repository in osbuild-composer
without it being available on the host system as well.

Also, if a user wishes to use a certain repository in osbuild-composer it
must be available on both hosts: the composer and the worker. It will come
with different pair of a client certificate and a key but otherwise, its
configuration remains the same.

The solution: Expect all the subscriptions to be registered in the
/etc/yum.repos.d/redhat.repo file. Read the mapping of URLs to certificates
and keys from there and use it. Don't change the manifest format and let
osbuild guess the appropriate subscription to use.
2021-08-09 12:40:23 +02:00
Tomas Hozza
4e92b65721 composer: don't expose ec2 and ec2-ha RHEL images via WeldrAPI
The `ec2` and `ec2-ha` images include RHUI client packages, which are
not publicly available. For this reason, building of such images in the
on-premise use case via WeldrAPI would always fail, unless the system
would be inside the Red Hat internal network or VPN.

Mark the `ec2` and `ec2-ha` image types for `rhel-*` distribution as
denied in WeldrAPI by default.

Extend and modify affected unit tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-08-05 09:34:07 +02:00
Tomas Hozza
b150d57c18 Weldr API: make Image Type denylist distribution-specific
Change the Image Type denylist in Weldr API from being applied to all
distributions to being distribution-specific. A special name `*`
can be used in the configuration to match any distribution
or any image type.

Modify NEWS entry and unit tests to reflect this change.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-08-02 18:51:03 +02:00
Tomas Hozza
076bbc5456 Weldr API: introduce Image Type denylist for filtering exposed images
Extend Weldr API to accept a list of denied image types, which should
not be exposed via API for any supported distribution. This
functionality will be needed to not expose image types which can't be
successfully built outside of Red Hat VPN. Example of such images are
the official RHEL EC2 images, which include RHUI client packages not
available publicly.

Image Types are filters when listing available compose types and
creating a new compose using Weldr API.

Extend osbuild-composer configuration to allow specifying the list of
denied Image Types for Weldr API.

Add unit tests for implemented changes.

Add NEWS entry describing the newly introduced functionality.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-08-02 18:51:03 +02:00
Lars Karlitski
9c2c92f729 jobqueue: Introduce jobqueue backed by a postgres database
Co-authored-by: sanne <sanne.raymaekers@gmail.com>
2021-07-28 21:52:31 +01:00
Thomas Lavocat
5e127de303 Worker: report stages status after RunOSBuild
To help along with debugging, this commit makes the worker able to print
the status of the different stages with a oneliner for each successfull
stages and a detailed message for failed ones.

Sample output:
Jul 23[..]: Build stages results:
Jul 23[..]: org.osbuild.rpm  success
Jul 23[..]: org.osbuild.selinux  success
Jul 23[..]: Stages results:
Jul 23[..]: org.osbuild.rpm  success
Jul 23[..]: org.osbuild.fix-bls  success
Jul 23[..]: org.osbuild.fstab  success
Jul 23[..]: org.osbuild.grub2  success
Jul 23[..]: org.osbuild.locale  success
Jul 23[..]: org.osbuild.timezone  success
Jul 23[..]: org.osbuild.users failure:
Jul 23[..]:  [/usr/lib/tmpfiles.d/journal-nocow.conf:26] Failed to resolve specifier: uninitialized /etc detected, skipping
Jul 23[..]: All rules containing unresolvable specifiers will be skipped.
Jul 23[..]: Failed to create file /sys/fs/selinux/checkreqprot: Read-only file system
Jul 23[..]: useradd: group 'toto' does not exist

Fixes #1584
2021-07-27 18:13:10 +02:00
Chloe Kaubisch
4c800f29a7 worker: add metrics
use prometheus to gather metrics
2021-07-23 21:54:28 +02:00
sanne
7555ed7556 worker: Merge configs 2021-07-16 12:14:46 +02:00
Tomas Hozza
3a0540dff0 test/api.sh: randomize used GCP zone from the region
The `api.sh` test currently always defaults to "<REGION>-a" zone when
creating instance using the built image. The resources in a zone may get
exhausted and the solution is to use a different zone. Currently even a
CI job retry won't help with mitigation of such error during a CI run.

Modify `api.sh` to pick random GCP zone for a given region when creating
a compute instance. Use only GCP zones which are "UP".

The `cloud-cleaner` relied on the behavior of `api.sh` to always choose
the "<REGION>-a" zone. Guessing the chosen zone in `cloud-cleaner` is
not viable, but thankfully the instance name is by default unique for
the whole GCP project. Modify `cloud-cleaner` to iterate over all
available zones in the used region and try to delete the specific
instance in each of them.

Make `ComputeZonesInRegion` method from the `internal/cloud/gcp` package
exported and use it in `cloud-cleaner` for getting the list of available
zones in a region.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-07-16 10:14:30 +02:00
Brian C. Lane
9818b4b6b1 osbuild-composer: Move InitWeldr code into weldr.New
This will make it easier to support new features related to building for
other distribution releases.
2021-07-12 08:58:42 +02:00
Ondřej Budai
5ae6203d65 distro: drop Fedora 32
It's EOL.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-07-05 11:16:08 +02:00
Achilleas Koutsou
6b3920783f rpmmd: move RPM metadata tooling to internal pkg
Move the OSBuildStagesToRPMs function, associated test, and RPM type
from the worker into the rpmmd subpackge. We will use this function in
the cloud API to compile the NEVRAs for the new metadata endpoint.
2021-06-29 09:33:05 +01:00
Ondřej Budai
579a5df698 upload/aws: add support for session tokens
If a user uses a temporary access key for login, a session token is also
needed.

This commit adds support for it to the internal aws library and also
to the osbuild-upload-aws helper. Note that this doesn't affect the main
osbuild-composer executable nor the worker. Everything here should work
as before and session tokens are not supported. Something for a follow up
if anyone needs it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-06-28 13:14:19 +03:00
sanne
acf88309c2 worker: Trim offline token 2021-06-23 10:33:22 +02:00
sanne
9161553170 worker: Tidy up help message 2021-06-23 10:33:22 +02:00
Tomas Hozza
e6c3d78ec4 image tests: ignore 'selinux/context-mismatch' in image-info report on RHEL-8
Add a new CLI option to `osbuild-image-tests` called
`-skip-selinux-ctx-check` to workaround the limitation of `setfiles` on
RHEL-8 [1]. If the option is passed to the binary, then the
'selinux/context-mismatch' part is removed from the "expected" and
"actual" image-info report, before these two reports are compared.

Modify `image_tests.sh` to run `osbuild-image-tests` with
`-skip-selinux-ctx-check` when run on RHEL-8.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1973754

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-06-22 13:25:59 +03:00
Achilleas Koutsou
1a3447ed38 kojiapi: include image type exports in Koji job args
Koji image request handling now reads the exports defined by each image
type. All APIs now support reading the exports defined by each image
type. The worker still falls back to "assembler" in case the call comes
from an older version of composer.
2021-06-18 14:02:09 +01:00
Achilleas Koutsou
5556137daf Append filename to S3 object upload 2021-06-18 14:02:09 +01:00
Achilleas Koutsou
e5b28c0bb3 New upload target: AWS S3
Uploads an artifact to an S£ bucket and returns a presigned URL to allow
the user to download the file.

Although it uses a lot of common code with the AWS AMI upload target,
it's treated as a completely separate target.
2021-06-18 14:02:09 +01:00
Achilleas Koutsou
14aea30bcd osbuild-worker: add export path to all upload calls
Exports are defined in all cases now.
2021-06-18 14:02:09 +01:00
Ondřej Budai
0a304f659d worker/client: pass arch explicitly
The API client guessed the arch, let's pass it explicitly so a caller
can specify it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-06-17 10:08:35 +02:00
sanne
0ea31c39d5 worker: Add identity filter and client oauth support 2021-06-17 10:08:35 +02:00
sanne
19db3ff1d4 cloudapi: Add x-rh-identity header filter 2021-06-05 14:47:38 +01:00
Tomas Hozza
aa6665ad01 Use RepoRegistry in composer and Weldr API
Modify composer to use RepoRegistry, instead of loading the host
repositories, when initializing WeldrAPI.

Modify WeldrAPI to use RepoRegistry, instead of a map of repository
definitions. Make sure that the RepoRegistry method specific to image
type is used in Welder where appropriate. Specifically when depsolving a
Blueprint, which is used to build a specific image type. Update Weldr
API unit tests to reflect the change.

Add a new method to RepoRegistry, allowing to get list of repositories,
which should be used for building an image for a given architecture,
without specifying the exact image type. Add relevant unit tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-05-14 15:43:00 +02:00
Tomas Hozza
fba9fe1072 Make the Distroregistry FromHost() return distro with correct name
Composer does not have 1:1 mapping of what can be the Host Distro name
and the names of supported distributions held in the Distroregistry.

The fact that the host distro `Name()` method as passed to the Weldr API
does not return the same name as what is used as distro name for
repository definitions. This makes it hard to use `distro.Distro` and
`distro.Arch` directly and rely on the values returned by them as their
name.

Add `New*HostDistro()` to all distro definitions, accepting the name
that should be returned by the distro's `Name()` method. This is useful
mainly if the host distro is Beta or Stream variant of the distro.

Change the distroregistry.Registry to contain host distro as a separate
value set when creating it using `New()` function. This value is
returned by `Registry.FromHost()` method. Determining the host distro is
handled by the `NewDefault()` function. Move the distro name mangling to
distroregistry package. Add relevant unit tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-05-14 15:43:00 +02:00
Achilleas Koutsou
34b5c5b3f1 weldr: use rhel-8 repos for all RHEL 8.x distros 2021-05-11 12:10:09 +02:00
Tomas Hozza
c91f3b11f6 Rename all occurrences of "Compute Node" to "Compute Engine"
This is an error, there is no such thing as "Compute Node" in GCP.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-04-01 20:12:39 +02:00
Tomas Hozza
e799f752be GCP: clean up resources after canceled image import
Add method to fetch Cloudbuild job log.

Add method to parse Cloudbuild job log for created resources. Parsing is
specific to the Image import Cloudbuild job and its logs format. Add
unit tests for the parsing function.

Add method to clean up all resources (instances, disks, storage objects)
after a Cloudbuild job.

Modify the worker osbuild job implementation and also the GCP upload CLI
tool to use the new cleanup method CloudbuildBuildCleanup().

Keep the StorageImageImportCleanup() method, because it is still used by
the cloud-cleaner tool. There is no way for the cloud-cleaner to figure
out the Cloudbuild job ID to be able to call CloudbuildBuildCleanup()
instead.

Add methods to delete Compute instance and disk.

Add method to get Compute instance information. This is useful for
checking if the instance has been already deleted, or whether it still
exists.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-04-01 20:12:39 +02:00
Tomas Hozza
6d51d285cf GCP: accept context from the caller in all methods
Modify all relevant methods in the internal GCP library to accept
context from the caller.

Modify all places which call the internal GCP library methods to pass
the context.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-04-01 20:12:39 +02:00
Brian C. Lane
ca9bb52f7e osbuild-store-dump: Use bp1 with iot image type
Previously it was not using the correct blueprint with the iot image
type. Switch to using bp1 which is the correct blueprint.
2021-03-30 00:19:30 +01:00
Brian C. Lane
ad3e43dc90 osbuild-store-dump: Add Packages support
The compose now saves the list of packages used to create the manifest.
2021-03-30 00:19:30 +01:00
Ondřej Budai
334f421927 test/cli: add a sanity check for Weldr logs
To prevent the issue fixed by the previous commit.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-19 18:50:31 +01:00
Martin Sehnoutka
9ba6dcec4e osbuild-worker: log unknown upload type
Make the target error a bit more useful by sending the name of unknown
upload target.
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
dfa227e82f osbuild-worker: s|errored|failed| because error is a noun
Fix grammar issue.
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
34d165be6c osbuild-worker: unify logging statements
The code previously used both fmt.Printf and log.Printf. Simplify this
by using log.Printf everywhere.
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
a3d80cc924 osbuild-worker: simplify jobimpl osbuild code
The previous version constructed multiple temporary variables and then
create job result from them. This was needed because we had multiple
upload targets but now that we have only one, this is only fragile
version of what can be done in a simplified way.

This PR removes the temporary variables and assigns errors and success
states right after the upload or build has finished.
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
3f9f8c7487 osbuild-worker: drop support for multiple upload targets
Multiple upload targets are not supported by osbuild-composer any more.
Dropping support for this in worker therefore doesn't change anything
from the user's perspective, but it allows us to simplify the code a
bit.

Replace calls to "continue" with "return nil" because the job finished
correctly even though it failed to perform the task. But the failure was
reported to osbuild-composer for further processing so there is no need
to duplicate and report the same error in worker process
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
086a9270b4 osbuild-worker: drop support for local and koji target
Drop support for LocalTarget, this has not been used in a long time,
and we don't really need to stay compatible across many releases
(just as long as we don't get problems with having to deploy in
lock-step), at least not yet.

Also drop support for KojiTarget, this has been replaced by the
osbuild-koji job type.
2021-03-19 15:59:57 +01:00
Martin Sehnoutka
87942865ba osbuild-worker: refactor reporting the job status to deref
The previous implementation exited before reporting back to the worker
API in few branches. This left the compose status in RUNNING state even
though the worker did not work of the job any more. Refactoring the
API call into the `deref` part makes sure it gets called every time.

This commit only moves bits of the code around so that the status gets
back to osbuild-composer, but it still doesn't contain any useful
information in case osbuild fails etc. This will be introduced in
subsequent commits.
2021-03-19 15:59:57 +01:00
Achilleas Koutsou
7b02d43139 osbuild-image-tests: call osbuild with export option
Call osbuild with the export option.  For now the only valid export
value is "assembler".

Run all exported images through testImage.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
12d4f82428 osbuild-worker: handle 0 and > 1 exports in job
If exports is undefined in request, add the default "assembler" for the
old image types.

If more than 1 export is requested, fail with an error.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
bc8ac681b6 osbuild-pipeline: add ostree.ref image option
Use default ostree ref for each image type when generating pipelines.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
e5abd5e5a6 cli-tests: print stderr when cli test fails
When shelling out for a CLI test the error returned from the Start()
command prints the exit code which is not very informative.  Capturing
and printing stderr is a lot more useful.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
2cce81093f osbuld-worker: call osbuild with --export flag
osbuild now supports using the `--export` flag (can be invoked multiple
times) to request the exporting of one or more artefacts.  Omitting it
causes the build job to export nothing.

The Koji API doesn't support the new image types (yet) so it simply uses
the "assembler" name, which is the final stage of the old (v1)
Manifests.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
8090621300 osbuild: rename package to osbuild1
Preparing for version 2 of the manifest schema, which will be
implemented in a separate package (osbuild2) alongside the original.
2021-03-17 18:12:17 +00:00
Tomas Hozza
fb089cf00d GCP: Report the right error when image import fails
Fix a bug in the worker job implementation and GCP CLI upload tool,
which causes the code to report wrong error instance in case the image
import failed for some reason.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-16 15:26:17 +01:00