Commit graph

1431 commits

Author SHA1 Message Date
Tomas Hozza
8420f34b7a RHEL-9.0: install and enable TuneD by default on all EC2 images
Add TuneD package to the base package set for all EC2 image types,
including the `ami` image type. In addition to installing the package,
also enable the service by default. TuneD will by default auto-detect
the environment in which the image is running and set the most
appropriate TuneD profile, with exception of the `ec2-sap` image, which
explicitly sets a specific TuneD profile.

This change affects the `ami`, `ec2`, and `ec2-ha` image types on all
supported architectures.

Regenerate affected image test cases.

Related to RHELPLAN-102615
Fix #1972

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-24 08:51:52 +01:00
Martin Sehnoutka
04f69db2c0 osbuild2: selinux stage - introduce force_autorelabel option
This was added in osbuild: https://github.com/osbuild/osbuild/pull/875

Introduce the same option in composer and make it optional by specifying
it as a pointer to bool value. It would work the same even if it was
there every time, but as it should be an edge case, don't use it
everywhere. Also osbuild doesn't require it to be present, so it seems
like the right thing to do.
2021-11-22 15:28:19 +01:00
Antonio Murdaca
ea5f153f3c internal: drop not needed kargs
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-11-20 14:31:44 +01:00
Antonio Murdaca
fed8edc51b internal/rhel86: prune default dracut modules
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-11-20 14:31:44 +01:00
Gianluca Zuccarelli
91f2457363 metrics: add prometheus namespaces
Make use of the prometheus namespace and subsystem
to give the metrics a consistent namespaces in openshift.
2021-11-19 22:48:25 +01:00
sanne
c8f198166d cloudapi/v2: Add support for edge-container 2021-11-19 21:45:19 +01:00
Tomas Hozza
57d60df24a RHEL-9.0: remove compat-sap-c++-9 from EC2-SAP image package set
The `compat-sap-c++-9` package no longer exists on RHEL-9. It has been
removed from the RHEL-9.0 Beta EC2-SAP image's package set, but then got
readded as part of adding the RHEL-9.0 distro and merging package sets
code with RHEL-8.6.

This issue have been found by the test case which tests manifests from
mage test cases, including the package set depsolving.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-19 19:50:25 +01:00
Tomas Hozza
8eb71484d9 RHEL-8.6: fix package set of the image-installer image type
The commit adding distro-specific package set to RHEL-8.6 [1] introduced
a bug in the `image-installer` image type due to a typo. The
`insights-client` package have been removed from the
`bareMetalPackageSet` and moved to `distroSpecificPackageSet`. However
the `distroBuildPackageSet` got appended to `bareMetalPackageSet`,
instead of `distroSpecificPackageSet`, which caused `insights-client` to
be removed from the image's package set.

This issue have been found by the test case which tests manifests from
image test cases, including the package set depsolving.

[1] ed0cb5ea24#

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-19 19:50:25 +01:00
Tomas Hozza
c5a4946135 Test all manifests with depsolved package sets
Generated image test case manifests for all supported distros, arches and
image-types are being tested as part of distro unit tests. However due
to time constrains, the unit test does not depsolve the image's default
package sets and thus does not check if they changed in the internal
osbuild-composer's representation, compared to the generated image test
case.

Extend the `TestDistro_Manifest()` function used by the unit test to
allow depsolving image's package sets.

Introduce a new test case binary `osbuild-composer-manifest-tests`
allowing to check the manifests generated by composer for all supported
combinations of images against generated manifests, including depsolving
image's default package sets.

Introduce a new CI test case `manifest_tests.sh` executing the
`osbuild-composer-manifest-tests` binary and testing all existing image
test cases. Run it in CI on RHEL-9 runner.

Modify SPEC file to ship the newly added test case.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-19 19:50:25 +01:00
Achilleas Koutsou
0712ed9700 cloudapi: add pipeline names to osbuild job 2021-11-19 19:37:08 +01:00
Martin Sehnoutka
f4412ff07f osbuild2: update rhsm stage
The stage now allows for customizations specific to YUM or DNF. So far
it is just an alias to the same definition, meaning that composer can
use exactly the same structures for both.

Ref: https://github.com/osbuild/osbuild/pull/876
2021-11-19 10:43:58 +01:00
Antonio Murdaca
5005ff6184 internal: mandate installation device for the simplified installer
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-11-18 18:10:09 +01:00
Antonio Murdaca
26b96483a3 edge-simplified-installer: use coreos-installer-dracut
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-11-18 18:07:52 +01:00
sanne
0a49dbe560 cloudapi/v2: Hard timeout for manifest job 2021-11-18 10:26:17 +01:00
sanne
028eca1b26 cloudapi/v2: Use manifest-id-only job
job dependencies:
depsolve -> manifest -> osbuild

This allows the compose handler to return the osbuild job id
immediately.
2021-11-18 10:26:17 +01:00
sanne
e5aba6bce9 cloudapi/v1: Adapt metadata handler to osbuild2 results 2021-11-17 18:59:13 +01:00
Achilleas Koutsou
e32f1cd697 osbuild: test Write() on nil Result receivers
Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-17 15:21:40 +01:00
Achilleas Koutsou
7f8a1b314a osbuild: check if result objects are nil in Write()
Before dereferencing the method receiver in Write(), check if the object
is nil and return early.

Fixes #2002

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-17 15:21:40 +01:00
Achilleas Koutsou
42d7979d65 api/v1: check for nil data before reading
After parsing the osbuild output, immediately check if any data was
set before dereferencing pointers.
2021-11-17 12:49:10 +01:00
Achilleas Koutsou
8dbf3e48c0 distro/rhel90*: minor code cleanup
Removing extraneous error checks (unreachable code).
2021-11-17 12:49:10 +01:00
Tomas Hozza
029c005473 osbuild2/modprobe: extend and rework stage options validation
Rework the stage options data validation to be done in constructor
methods, instead of when being marshalled to JSON.

Add validation of values passed to constructor methods for modprobe
command structures.

Add validation of the configuration filename based on stage schema.

Related to issue #1785.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-16 21:49:38 +01:00
Tomas Hozza
801c9fadab osbuild2: support 'install' command in the modprobe stage
Add support for the 'install' modprobe command in the modprobe osbuild
stage implementation.

Extend unit tests to verify marshalling the stage options into JSON.

Related to https://github.com/osbuild/osbuild/pull/867.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-11-16 21:49:38 +01:00
Sanne Raymaekers
2d1b7baa27 Revert "cloudapi/v2: Use manifest-id-only job"
This reverts commit 992e442ba7.
2021-11-16 20:23:36 +01:00
sanne
992e442ba7 cloudapi/v2: Use manifest-id-only job
job dependencies:
depsolve -> manifest -> osbuild

This allows the compose handler to return the osbuild job id
immediately.
2021-11-16 18:53:12 +00:00
Diaa Sami
df73b835c3 jobqueue: improve logging
Add job ID where it's missing
2021-11-16 19:16:34 +01:00
Diaa Sami
9c6438c8f4 jobqueue: include dependent job IDs when logging 2021-11-16 19:16:34 +01:00
sanne
b075cac9e3 worker: Correct servers in openapi spec
Similar to other services on api.openshift.com, the full url should be
shown.
2021-11-16 10:30:58 +00:00
Achilleas Koutsou
778b2de3c0 worker: test mixed new and old jobs in jobqueue
Two new tests, one for OSBuild and one for Koji jobs. Both follow the
same flow:
- Enqueue a job that doesn't specify PipelineNames (oldJob)
- Enqueue a job that does specify PipelineNames (newJob)
- Read the job data for the oldJob and check that the default
  PipelineNames were added
- Read the job data for the newJob and check that it's unchanged
- Finish oldJob and add results without specifying PipelineNames
- Finish newJob and add results with PipelineNames
- Read the oldJob result and check that the default PipelineNames were
  added
- Read the newJob result and check that it's unchanged

This is meant to test several scenarios that can occur when upgrading
the service:
1. The existing jobqueue has old jobs in it that were queued before the
   PipelineNames were part of the data structure. The worker should be
   able to read these and add the fallback data.
2. New jobs are added while old jobs still exist in the queue and the
   worker can read both types.
3. The existing jobqueue has old finished jobs in it that were finished
   and had results written before the PipelineNames were part of the
   result data structure. The worker should be able to read these and
   add the fallback data.
4. New jobs are finished and results are written while old jobs still
   exist in the queue and the worker can read both result types.
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
51870676cc worker/json: add fallback pipeline names when reading data
When worker reading data into the job and result types, check if the
PipelineNames are populated and, if not, add the fallback values from
distro.

This makes it simpler to work with job queues that contain old data
before the introduction of the PipelineNames. In any situation where the
job or result data are read, the reader can assume that the
PipelineNames are non-nil and that if they belong to an old job, they
have the fallback names.

This assumption goes hand-in-hand with the change in v2 format for
osbuild results, since old jobs that don't have PipelineNames set *must*
contain results in the old format for the names to be valid.
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
38b8bfbd66 rpmmd: test rpm list deduplication 2021-11-16 09:49:37 +01:00
Achilleas Koutsou
9aef7bfc47 osbuild-worker: attach pipeline names to jobs
Pipeline names are added to each job before adding to the queue. When a
job is finished, the names are copied to the Result object as well. This
is done for both OSBuild and Koji jobs.

The pipeline names in the result are primarily used to separate package
lists into build and payload/image packages in two cases:
1. Koji builds: for reporting the build root and image package lists to
   Koji (in Koji finalize).
2. Cloud API (v1 and v2): for reporting the payload packages in the
   metadata request.

The pipeline names are also used to print the system log output in the
order in which pipelines are executed. This still isn't used when
printing the OSBuild Result (osbuild2.Result.Write()) and we still rely
on sorting by pipeline name
(see https://github.com/osbuild/osbuild-composer/pull/1330).
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
143eb5cb91 worker: add PipelineNames to Job descriptions
The names of the pipelines that make up a Manifest for a job are
attached to the job data that is stored in the queue. The pipelines are
separated into Build and Payload.

This information is useful for identifying the build pipeline results
and metadata and for the order of the pipelines as they appeared in the
manifest.
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
a0479a1bcf osbuild2: test result Write() function
Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
65f1a24ecd osbuild2: remove Prints in lvm.create stage test
Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
682fc245e5 kojiapi: use osbuild2.Result in test
Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
dc0e3dea92 osbuild: test result conversions
Moved and adapted tests from osbuild1 to osbuild2.
Moved test data from osbuild1 to osbuild2.
Added conversion tests for v1 to v2.
Added full v2 result raw data from successful build.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
b7bab25e73 osbuild2: check v1 data before converting
Don't convert stage results if there are none.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
6731984326 distro: ImageType build and payload pipeline names
Each image type now implements BuildPipelines(), which returns a list of
pipeline names that set up the build environment, and
PayloadPipelines(), which returns a list of pipeline names that create
the OS image (all non-build pipeline names).

Older distros that produce v1 manifests should call the distro Fallback
functions to return the common defaults.

A Fallback function for the Exports() method is also added and called by
older distros.

All image types that produce v2 manifests (distros after RHEL 8.4)
should include the information in the image type definition and should
not rely on fallbacks for default values.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
fbdc19f6d8 rpmmd: deduplicate RPM list based on NEVRA
Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
e73d35d7c1 osbulid2: unmarshal PipelineMetadata into ptr receiver 2021-11-16 09:49:37 +01:00
Achilleas Koutsou
a9ea5e12a8 osbuild2: omitempty Error field in v2 Result 2021-11-16 09:49:37 +01:00
Achilleas Koutsou
5f8bd4fd6e osbuild2: small code reorganisation
Move main type to the top of the file
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
10eb0d65a1 osbuild2: convert from osbuild1 results
Convert osbuild1.Result{} to osbuild2.Result{}.
For the Metadata objects, it assumes they are directly convertible: the
stage metadata structs have the same members.

The old conversion code from v2 to v1 is removed and the equivalent
conversion logic is moved to osbuild2:
- version detection based on stub
- custom unmarshaller that calls conversion function if v1 result is
  detected

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
9eff6f1e95 osbuild2: v2 Result writer
Implementing writer for osbuild2 Result type.
Since Go maps don't have stable ordering, sorting by the pipeline name
provides stable output.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
2004c71f89 cloudapi: use osbuild v2 result struct to extract metadata
Reading stage metadata using osbuild's v2 result format.
For RPM stages we only want the core (OS) RPMs (not the build root
RPMs). Skip the build pipeline by name, but this should be handled
better since names are arbitrary.

Using type switch to convert metadata types instead of relying on the
type string of the stage result.

The rpmmd helper function isn't used anymore since that requires two
conversion passes (osbuild.StageMetadata -> rpmmd.RPM ->
cloudapi.PackageMetadata).

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
Achilleas Koutsou
9dff17e172 rpmmd: convert from v2 result metadata
Function renamed to better fit the argument element type
(StageMetadata).
Argument is a map to fit the pipeline metadata in the result object.
Signature function is made public to be reused in the cloud API
conversion.

Metadata test raw value updated to v2 result format.

Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
2021-11-16 09:49:37 +01:00
sanne
6757916c54 worker: Introduce manifest-id-only job
A job intended to run in composer itself, after which a dependant
osbuild job can parse the manifest from it's dynamic arguments.
2021-11-15 16:04:12 +01:00
Ondřej Budai
d3a3dbafed jobqueue: add DequeueByID
We will soon need to dequeue a job using its ID. This commit adds ability
to do that to the Jobqueue interface. As always, the fsjobqueue implementation
is slightly naive but it should fine for the usecases that it's designed for.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-11-14 10:17:03 +01:00
Ondřej Budai
2ecc48727f fsjobqueue: factor out finished deps check
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-11-14 10:17:03 +01:00
Ondřej Budai
5f4db72777 fsjobqueue: do not delete empty channels
Previously, we deleted empty channels when a job was dequeued. This is
completely wrong because there still might be some clients waiting for
a job. This commit removes the cleanup and adds a regression test.

Note that this has the potential to leak memory if we ever use a lot of
job types. Currently, we have just handful of them, so this is fine.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-11-14 10:17:03 +01:00