Commit graph

1918 commits

Author SHA1 Message Date
Achilleas Koutsou
ce963004e0 docs/news: describe osbuild v2 and new image-type 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
f317b0a3d9 test/data: test cases for rhel-edge-container 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
28aaa129ff generate-test-cases: export flag for osbuild call
osbuild requires the export flag otherwise it wont produce an artifact.
For the older manifest format (v1), the export value is always
"assembler".  For v2 manifests, it is the name of the last pipeline.

If an unknown version number is read the script now fails.  This should
help catch manifest changes that may affect test case generation in the
future.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
0f5936e9fe osbuild1/source: minor typo fix 2021-03-17 18:12:17 +00:00
Achilleas Koutsou
007d52f171 osbuild1/result: read v2 output and convert to v1
Log output from osbuild has a very different format when using the
new schema.  The osbuild1.Result object now supports unmarshalling the
new format and adapting it to the old format.

The most important field to set is the Success field to signal whether
the build succeeded.

Secondarily, it also copies over the output from each stage in order to
provide build job log output through the weldr API.
Since the new format contains multiple pipelines with multiple stages
each, the stages are flattened to fit the old format.  A unique name for
each stage is created by prepending the name of the pipeline to its
index in the pipeline and its type.
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
541cbab0f6 distro/rhel84: new imageType implementation
imageTypeS2 implements the distro.ImageType interface buts generates a
Manifest matching the new osbuild v2 schema.

Two new image types are added to the rhel84 distro (x84_64 and aarch64)
for generating OCI containers contain an Edge (ostree) commit and, when
run, start a web serer to serve the commit.

The image type uses the new PackageSets map to define packages (and
excludes) for the image.  The old methods (Packages() and
BuildPackages()) are implemented for compatibility with the old
workflow.
The image also defines an extra package set for the container that will
serve the package: "httpd" (and its dependencies).

The distro.ImageType interface has a new method: Exports()
It should return a list of names or IDs of artefacts that should be
exported from osbuild when the job is complete.
For the old image types, this is simply set to "assembler".
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
756d5b063f osbuild2: new schema types: stages, inputs, sources
Adding new types and adapting copies of all the old types to match the
new Manifest schema:

New types:
- Stages
    - org.osbuild.ostree.init
    - org.osbuild.ostree.pull
    - org.osbuild.ostree.preptree (replaces org.osbuild.rpm-ostree)
    - org.osbuild.curl
- Converted from assemblers
    The concept of a Build and Assembler stage in gone now. Instead they
    are regular Stages like any other.
    - org.osbuild.oci-archive
    - org.osbuild.ostree.commit
- Sources
    - org.osbuild.curl
    - org.osbuild.ostree
- Inputs
    - org.osbuild.files
    - org.osbuild.ostree

Types with changes:
- Stages
    - org.osbuild.rpm:
        - New input structure for defining packages
        - New options

Basically copies:
- The rest simply rename the `Name` field to `Type`

Decoding types with interface fields:
Types that contain interfaces with multiple implementations implement
their own UnmarshalJSON method.  In these cases, we use a JSON decoder
with the `DisallowUnknownFields` option to catch errors during the
deserialization while trying to determine which implementation matches
the data.

Copied tests for copied types are adapted accordingly.
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
Ondřej Budai
18af1f5b78 github: run workflows on PR head commit
By default, the checkout action checkouts the merge commit. This is different
from what Schutzbot currently does - it runs the test on the PR HEAD commit.
Let's change the GitHub workflows behaviour to the same one as Schutzi
uses.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-17 00:15:13 +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
Ondřej Budai
a6bc07fac0 schutzbot: run the CS8 integration test on AWS
I think there's currently no reason to run it on PSI.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-16 12:07:55 +01:00
Aleksandar Todorov
2bcd040b4a schutzbot: Fix wrong COMPOSE_ID URL 2021-03-16 09:10:38 +01:00
Ondřej Budai
d6afdda82f schutzbot: evaluate the when block before an agent is started
By default, a when block is evaluated after an agent is started. I discovered
this randomly: I opened a pipeline and saw that it was stuck on "Prepare EL8
internal 🤔" stage even though the pipeline should have even run it.

This commit fixes it by adding "beforeAgent true" to all when blocks. It
changes the behaviour to more sane "if when is true, allocate an agent".

See https://www.jenkins.io/doc/book/pipeline/syntax/#evaluating-when-before-entering-agent-in-a-stage

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-15 17:58:51 +00:00
Tomas Hozza
e04b75f3df cloud-cleaner: clean up GCP Storage objects based on metadata
Add StorageListObjectsByMetadata() to internal GCP library. The method
allows one to search specific Storage bucket for objects based on
provided metadata.

Extend cloud-cleaner to search for any Storage objects related to the
image import, using custom metadata set on the object. Delete all found
objects.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-15 16:48:40 +00:00
Tomas Hozza
e698080bc7 GCP: Set image name as custom metadata on uploaded image object
Extend StorageObjectUpload() to allow setting custom metadata on the
uploaded object.

Modify worker's osbuild job implementation and GCP CLI upload tool to
set the chosen image name as a custom metadata on the uploaded object.
This will make it possible to connect Storage objects to specific
images.

Add News entry about image name being added as metadata to uploaded GCP
Storage object as part of worker job.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-15 16:48:40 +00:00
Tomas Hozza
aa1d038b59 cloud-cleaner: clean up image and vm after GCP integration test
Extend internal GCP library to allow deleting Compute Node image and
instance. In addition provide function to load service account
credentials file content from the environment.

Change names used for GCP image and instance in `api.sh` integration
test to make them predictable. This is important, so that cloud-cleaner
can identify potentially left over resources and clean them up. Use the
same approach for generating predictable, but run-specific, test ID as
in GenerateCIArtifactName() from internal/test/helpers.go. Use SHA224
to generate a hash from the string, because it can contain characters
not allowed by GCP for resource name (specifically "_" e.g. in "x86_64").
SHA-224 was picked because it generates short enough output and it is
future proof for use in RHEL (unlike MD5 or SHA-1).

Refactor cloud-cleaner to clean up GCP resources and also to run cleanup
for each cloud in a separate goroutine.

Modify run_cloud_cleaner.sh to be able to run in environment in which
AZURE_CREDS is not defined.

Always run cloud-cleaner after integration tests for rhel8, rhel84 and
cs8, which test GCP.

Define DISTRO_CODE for each integration testing stage in Jenkinsfile.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-15 16:48:40 +00:00
Tomas Hozza
f9fe699564 GCP: split internal library based on functionality
Split the GCP library into multiple files:
- compute.go - code interacting mainly with the Compute Node resources
- storage.go - code interacting mainly with the Cloud Storage resources
- gcp.go - common code (e.g. authentication with GCP)

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-15 16:48:40 +00:00
Tomas Hozza
075373a51e internal: Move GCP library to internal/cloud
The internal GCP library was originally placed into `internal/upload`
directory, since its purpose was mainly to upload and import built
images to GCP.

Functionality for other cloud-provider-specific libraries is broader,
however scattered around the `internal/` directory based on purpose (e.g. in
`internal/boot` and `internal/upload`). Since all parts of provider-specific
library usually share some common pieces (e.g. authentication), it makes
sense to consolidate them into a single package (e.g. in
`internal/cloud/<provider>`).

Create `internal/cloud` directory, where all cloud-provider-specific
internal libraries should be consolidated. Start with GCP.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-15 16:48:40 +00:00
Tom Gundersen
b0805377ea image-tests: checkpoint build root
Most images share a build root, checkpoint the build root to speed up tests
at the potential cost of some disk space (in the cases the build roots are not the same).
2021-03-15 16:40:48 +00:00
Tom Gundersen
ddc4013dbf generate-all-test-cases: don't wipe store
Afetr a run, a store contains downloaded rpm's and whatever pipelines
were checkpointed. We want to reuse these for subsequent runs, so
don't delet the store.
This risks minimally increasing the disk space usage, but should speed things up significantly.
2021-03-15 16:40:48 +00:00
Tom Gundersen
aeddf7e501 generate-test-cases: checkpoint build root
Most of the images for a given distro share a build-root, checpoint it to avoid having to recreate it.
2021-03-15 16:40:48 +00:00
Aleksandar Todorov
d7e21e2299 tests: Update documentation 2021-03-15 14:20:25 +02:00
Aleksandar Todorov
0716c32e97 tests: Refresh COMPOSE_ID file if COMPOSE_URL was defined from ENV 2021-03-15 14:20:25 +02:00
Ondřej Budai
60e12212c5 test cases: regenerate qcow2 for rhel-84 and centos-8
So they contain the net-tools change.
2021-03-14 15:03:58 +00:00
Tom Gundersen
fd7431276b news: add entry about net-tools in rhel84 qcow2 2021-03-14 15:03:58 +00:00
Tom Gundersen
b159a281b9 distro/rhel84/qcow2: add net-tools
cloud-init not longer depends on net-tools, so we need to add in the dependency explicitly.

We aimed for the qcow2 to be equivalent to the RHEL8.4 qcow2 produced by imagefactory. However, we missed this unintended change from RHEL8.3.
2021-03-14 15:03:58 +00:00
Aleksandar Todorov
661b2a0be0 Schutzbot: Allow overriding internal RHEL URL
by defining the COMPOSE_URL environment variable! This will allow
testing more flavors of internal releases.

The rest is renaming files and variables to reflect the fact that
we're running tests against internal trees, not only nightlies.
2021-03-12 20:38:06 +02:00
Aleksandar Todorov
fc2d2894d4 tests: add manifest file for CentOS 8 aarch64 AMI 2021-03-12 11:59:21 +00:00
Aleksandar Todorov
6c546fa257 Schutzbot: Start building & testing on aarch64 for RHEL/CentOS
For now we're testing only on released streams in AWS because
we don't have aarch64 support in PSI.
2021-03-12 11:59:21 +00:00
Tomas Hozza
7e6adec695 worker: refactor handling of GCP credentials
Make the handling of GCP credentials more consistent with what is being
done e.g. for Azure. Make the GCP section in worker's configuration a
pointer so that it does not show up in the printed worker's
configuration during start up if it was not specified in the actual
configuration file.

Load the GCP credentials file, if provided, during the worker start up to
prevent failure later on while processing a job with GCP upload target.
Pass the loaded GCP credentials as []byte to the OSBuildJobImpl.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-12 12:17:02 +01:00
Tomas Hozza
87d82e529d Makefile: build osbuild-upload-gcp as part of build target
Build `cmd/osbuild-upload-gcp` as part of the `build` make target,
similar to other cloud providers.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-12 12:17:02 +01:00
Tomas Hozza
53cde684d3 GCP: simplify calls to Compute Node API
Reduce the code related to Compute Node v1 API calls in a similar way as
it is done in the API usage examples.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-12 12:17:02 +01:00
Tomas Hozza
bbae190e99 worker: share GCP image only if the accounts list is not empty
Modify worker's job implementation to try to share GCP image only if the
provided list of accounts is not empty.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-12 12:17:02 +01:00
Tomas Hozza
7de2011beb GCP: refactor logging and storage cleanup
Originally, the internal GCP library in `internal/upload/gcp` was
logging various information and errors. Refactor the code to move all
logging to callers of the library. As a result, some methods now return
additional information to preserve the same amount of information being
logged for GCP.

Refactor methods to have only single purpose and not do any extra work,
such as storage cleanup. Methods which create new resources now don't do
any cleanup at all. The caller is responsible to check for any errors
and perform any cleanup necessary. Necessary methods to perform cleanup
are provided.

Modify worker's job implementation and GCP CLI tool to explicitly do all
necessary cleanup, including in case of errors.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-03-12 12:17:02 +01:00
Ondřej Budai
d7b0323a2d distroregistry/test: add test for GetDistro
Adding the sweet coverage.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
9bc35d5e98 distroregistry/test: make the List test generic
So we don't need to update the list when we changed the supported distros.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
e4295dc49c distroregistry/test: do not depend on the order in the List test
order of distributions doesn't matter.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
1b63a69245 distro/test: use the new default distroregistry
This way, we don't need to add here a new distro when it's added.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
a7dee8b604 distro/*: remove redundant manifest tests
The same test is run in distro/distro_test.go. The redundancy was probably
caused by a bitrot in several commits.

I decided to remove the test from distro implementations to reduce the amount
of duplicated code.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
3c715c7cf8 distroregistry: add a default distroregistry
This commit adds NewDefault() method to distroregistry that returns a slice
with all distributions supported by osbuild-composer. This way, there's only
one place where a distribution needs to be defined while its support
is being added to composer.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Ondřej Budai
dd4db353e2 distro: move Registry to its own distroregistry package
My goal is to add a method to distroregistry to return Registry with
all supported distributions. This way, all supported distributions
would be defined only on one place.

To achieve this, the Registry must live outside the distro package
because the distro implementation depends on it and this would create
a circular dependency unsupported by Go.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-03-12 08:29:30 +01:00
Aleksandar Todorov
b5a1d89e45 tests: Save osbuild-composer.repo file under artifacts
makes it easier to grab if we need it for manual testing or
in case one needs to download the RPMs from Schutzbot
2021-03-11 11:01:20 +02:00
Tom Gundersen
9e2e009ac8 distro: introduce PackageSets
This replaces Packages() and BuildPackages() by returning a map of
package sets, the semantics of which is up to the distro to define.

They are meant to be depsolved and the result returned back as a
map to Manifest(), with the same keys.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-03-10 11:52:05 +00:00
Tom Gundersen
4805eeedf8 test/data/manifests: drop .rpmmd.checksums
These are no longer used.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-03-10 11:52:05 +00:00
Christian Kellner
ee08790504 test: regenerate -cusomize manifests
Use `generate-test-cases` to generate the qcow2 image types with
customization for fedora 32, 33 and CentOS 8 and RHEL 8 and 8.4.
The previous commit changed the customization blueprint but the
changes to the resulting manifest and test data was done by hand.
2021-03-09 21:45:27 +00:00
Christian Kellner
8da813ecd2 rhel84: use en_US.UTF-8 as default for LANG
Use en_US.UTF-8 as default for LANG, which is what previously was
used and is also needed to properly work on non-us/latin setups[1].

In the customization tests, use a different value than the default
one to check that the customization does in fact work.

[1] http://git.app.eng.bos.redhat.com/git/spin-kickstarts.git/tree/rhel8/rhel-8.2-kvm-x86_64.ks#n4

Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-03-09 21:45:27 +00:00