Commit graph

2039 commits

Author SHA1 Message Date
Xiaofeng Wang
20af9a7258 test: Remove user SSH key work around
It's been fixed already by commit 1b0e9e3
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
b843c77c8c rhel84: add a first boot stage for user SSH key
User home directories don't survive the rpm-ostree stage.  They are
converted to systemd-tmpfiles via rpm-ostree post-process, but the
contents are left behind, so any keys we add to the authorized_keys file
will be gone.

This stage sets up a first-boot service that writes the user's public
key to the file in the home directory during the first system boot.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
1aa0dc28a9 rhel84: fix ostree URL in kickstart
In the Anaconda pipeline, the kickstart stage should fetch the commit
we're embedding.  It was mistakenly trying to fetch from the URL used to
build the image instead.
2021-03-17 18:12:17 +00:00
Xiaofeng Wang
4844f4bc7a test: Fix ssh public key issue
The public key should be osbuild-composer CI's key, not my local
test one
2021-03-17 18:12:17 +00:00
Tom Gundersen
955585072d ostree-ng.sh: set VERSION-ID and ID variables
We only support one combination for now, but let's stay compatible with the old tests.

This fixes the places where these variables are still used.
2021-03-17 18:12:17 +00:00
Xiaofeng Wang
5445acb0cc test: Update ostree-ng to support container and installer tests
The ostree-ng will only be run on RHEL 8.4 because
rhel-edge-container and rhel-edge-installer image type are
supported by RHEL 8.4 only
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
f8b3b3f7e2 rhel84,osbuild2: add system ID to ISO
New stage option added in osbuild
https://github.com/osbuild/osbuild/pull/611

System ID is used by osinfo to identify the RHEL boot ISOs, where the
system ID is "LINUX".
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
8c92553623 docs/news: update news item to mention both image types 2021-03-17 18:12:17 +00:00
Achilleas Koutsou
ae4a1384e3 Schutzfile: pin osbuild for rhel-8.4
The new rhel-edge-installer requires unreleased fixes:
https://github.com/osbuild/osbuild/pull/610
https://github.com/osbuild/osbuild/pull/611
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
bacba210b0 rhel84: new image type: rhel-edge-installer
New image type that generates a Boot ISO.  The ISO contains a RHEL Edge
commit and an installer.  On Boot, it sets up a new RHEL Edge system
with the commit.

The RHEL Edge commit (ostree commit) is downloaded during build from a
URL that should be supplied with the compose request.  The commit's hash
and URL need to be added to the Sources list in the Manifest.

Unlike other types, the new image type defines its own "build" package
set that is added to the distro and arch build package lists.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
2edb057f3b distro: add URL to OSTreeImageOptions
We need to add the URL to the manifest as an ostree source repo so that
osbuild can pull the commit to embed it in the boot ISO for the new
rhel-edge-installer image type.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
33cebcc8fc osbuild2: port tar assembler to new stage 2021-03-17 18:12:17 +00:00
Achilleas Koutsou
bec194dfff osbuild2: add support for new osbuild stages
- org.osbuild.anaconda
    Configures Anaconda.  For now, only enabling kickstart modules is
    supported.

- org.osbuild.buildstamp
    Creates a buildstamp file, which is required by Anaconda.

- org.osbuild.kickstart
    Creates a kickstart file.

- org.osbuild.lorax-script
    Uses lorax template helpers to execute a template.

- org.osbuild.bootiso
    Prepares a bootable file system tree suitable for writing on an ISO
    file system

- org.osbuild.discinfo
    Creates a .discinfo file, used by the Anaconda installer.

- org.osbuild.xorrisofs
    Uses the `xorrisofs` command line utility to an ISO.

- org.osbuild.implantisomd5
    Uses the `implantisomd5` command to implant MD5 checksums into an
    ISO.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
011559f785 osbuild2: add SavedEntry to Grub2StageOptions
Added in osbuild1 already.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
f107241ee2 obsuild2: support additional layers in oci-archive
The org.osbuild.oci-archive stage now supports an arbitrary number of
layers on top of the Base layer.  The keys for these layers follow the
pattern "layer.N" (N = 1, 2, 3, ...).

We use a custom marshaller and unmarshaller for the
OCIArchiveStageInputs to handle this.  The unmarshaller also validates
the layer keys to match the pattern in the schema.
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
dc5e46139a osbuild2: new dracut stage to re-create initrd 2021-03-17 18:12:17 +00:00
Achilleas Koutsou
3618611d6f Schutzfile: pin osbuild for rhel-8.4
We need to test the PR before a new osbuild is released.  Pinning to
current `main`.

In particular, we need to test against
https://github.com/osbuild/osbuild/pull/600
2021-03-17 18:12:17 +00:00
Xiaofeng Wang
e4419ed752 test: Update ostree-ng.sh to work with rhel-edge-container test
rhel-edge-container is only supported by RHEL 8.4, so the test is
for RHEL 8.4 only
2021-03-17 18:12:17 +00:00
Achilleas Koutsou
2e58dfa61b distro/rhel84: reuse edge package lists for new types
The payloads for these image types should be identical, so no need to
redefine them.
2021-03-17 18:12:17 +00: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
164faa7503 osbuild{1,2}: new stages in unmarshal method
Recently added stages org.osbuild.sysconfig and
org.osbuild.kernel-cmdline were missing from the Manifest unmarshal
method causing it to fail when trying to unmarshal manifests that
contained them.
2021-03-17 18:12:17 +00:00
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