Commit graph

1506 commits

Author SHA1 Message Date
Tom Gundersen
b32ab36e1d worker/server: typesafe Job and JobStatus
Replace Job() and JobStatus() with typesafe versions, and introduce JobType()
for the rare instances where we don't know the type up front.

Additionally, catch a few more error cases:
 - if OSBuildResult is nil, then we failed to invoke osbuild
 - make sure the same JobResult handling is done for osbuild-koji, as for osbuild
2022-02-01 20:28:40 +00:00
Tom Gundersen
9fba2dcc5d cloudapi/v2: introduce multi build composes
This only extends the API, the backend can still only deal with composes of a single build.

I aimed to keep the API practically backwards compatible, i.e., no current consumer of it should notice the change. I hope I didn't mess that up.

fixup: image statuses
2022-02-01 20:28:40 +00:00
Tom Gundersen
c1dc9d7284 cloudapi/v2: introduce compose status
In addition to individual image status, have an
overall status that captures success or failure
of the compose as a whole.

This is not as fine grained, and only distinguishes
between "pending", "failure" and "success".

This captures other jobs than the image builds, which
is relevant for the koji composes, which consists also
of koji-init and koji-finalize, in addition to the build
jobs.
2022-02-01 20:28:40 +00:00
Tom Gundersen
c892ccfde0 cloudapi/v2: make upload request optional
For now upload requests are required if and only if we are not
using koji. When using the koji integration the produced artifacts
are uploaded to koji only. In the future we may want to support
also uploading to the cloud providers.
2022-02-01 20:28:40 +00:00
Tom Gundersen
92c7fc2534 cloupapi/v2: add koji support
Extend the compose endpoints to have minimal koji support.

This is intended to replace the current koji API so that it
can be consumed through api.openshift.com.
2022-02-01 20:28:40 +00:00
Achilleas Koutsou
2965833001 distro/rhel90: drop IA32 from bootiso.mono 2022-02-01 19:27:47 +01:00
Antonio Murdaca
f697414c03 distro/rhel90: drop IA32 from grub2iso
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2022-02-01 19:27:47 +01:00
Antonio Murdaca
db2be5d7c9 distro/rhel90: drop unavailable ia32 packages
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2022-02-01 19:27:47 +01:00
Tom Gundersen
0b24099751 jwt: support multiple key providers
We may need to use several SSO providers, so extend our
configuration to allow that.

Based on PoC from Sanne:

```
package main

import (
	"net/http"
	"log"

	"github.com/openshift-online/ocm-sdk-go/authentication"
	"github.com/openshift-online/ocm-sdk-go/logging"
)

type H struct{}

func (h *H) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	log.Println("HURRAY")
}

func main() {

	logBuilder := logging.NewGoLoggerBuilder()
	logger, err := logBuilder.Build()
	if err != nil {
		panic(err)
	}

	aH, err := authentication.NewHandler().
		KeysURL("https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs").
		KeysURL("https://identity.api.openshift.com/auth/realms/rhoas/protocol/openid-connect/certs").
			Logger(logger).Next(&H{}).Build()
	if err != nil {
		panic(err)
	}

	log.Fatal(http.ListenAndServe(":8080", aH))

}
```
2022-01-31 20:40:22 +00:00
Christian Kellner
669d3e0734 distro/rhel86: fix ec2 boot partition for arm64
It should be `1048576` (exactly 512 MiB), like it is for all other
distributions. It somehow got mingled in when the distribution was
forked off from 8.5/9.0 beta (1048676 to 1048576 strongly suggests
a sed command was involved, so we blame that).
2022-01-31 11:46:09 +01:00
Christian Kellner
5e2617ed49 kojiapi: successful osbuild jobs must have output
When we compute the overall status of a koji compose, the individual
build jobs are checked. Currently, a job is considered a failure, if
a build job has output (`OSBuildOutput`) and the output's `Success`
field is `false`. But `OSBuildOutput` will be `nil` when osbuild
crashed or refused the manifest input. Therefore the job status is
a failure if `OSBuildOutput` is `nil`, since if osbuild was run,
and the run was successful we must have a non-`OSBuildOutput` field.
2022-01-28 20:37:23 +00:00
Achilleas Koutsou
022a52d56b distro/rhel90: special case root user for ssh keys
Add a special cases for the root user to the work-around for ssh keys in
OSTree commits.

See 93e54cd872 for the original,
equivalent change in RHEL 8.6.
2022-01-28 15:16:56 +01:00
Roy Golan
bee932e222 Add support for OCI upload provider
Signed-off-by: Roy Golan <rgolan@redhat.com>
2022-01-28 15:16:47 +01:00
Christian Kellner
c5feb93279 distro/rhel90: no uuids in dos partition table
The unification of the partition table also introduced uuids and
types in uuid form for partition tables in dos layout, sill used
on PPC64LE and s390x. The org.osbuild.sfdisk stage did work with
that but produced a `/boot` partition with the wrong type, which
grub2 refused to read from and thus prevented boot. Fix this by
removing uuids from the dos partition tables.

Reported-by: Jakub Rusz <jrusz@redhat.com>
2022-01-28 12:16:39 +01:00
Gianluca Zuccarelli
88b5529cc4 osbuild-worker: test error backwards compatability
Since the workers will use structured error messages
going forward, it is necessary to maintain backwards
compatability for there errors in composer. Tests have
been added to the various apis to ensure that each api
checks for both kinds of errors, old and new.
2022-01-27 16:45:14 +01:00
Gianluca Zuccarelli
cc981b887a osbuild-worker: implement structured errors
Implement the structured errors as defined by the worker client.
Every error for each of the job types now returns a structured
error with a reason and a specific error code.  This will make
it possible to differentiate between 4xx errors and 5xx errors.

This commit refactors the way errors are implemented in the workers,
but maintains backwards compatability in composer by checking for
both kinds of errors.
2022-01-27 16:45:14 +01:00
Gianluca Zuccarelli
daf24f8db3 worker: define worker errors
Define worker errors to give more structured
error messages. The error api is:
id: VALIDATION_ERROR_NUMBER, reason: STRING, details: { issues: [{...}, {...}] }

The api was agreed upon with osbuild so that,
in future, osbuild errors will share the same
structure
2022-01-27 16:45:14 +01:00
sanne
a83cf95d5b go.mod: Update oapi-codegen and kin-openapi 2022-01-12 11:35:06 +01:00
Tomas Hozza
ec6099f7f6 RHEL-86: port over the RHEL-90 pipeline refactoring
Port all of the pipeline refactoring done to RHEL-90 to RHEL-86. Both
distros now use the same approach.

Regenerate all RHEL-8.6 and CentOS 8 image test cases.

[1] https://git.centos.org/centos/kickstarts/tree/master

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
960aad0b0a RHEL-86: apply subscriptions and RHSM configuration only on RHEL
RHSM configuration is now applied conditionally only on RHEL. The same
applies to the customization to subscribe the system on first boot.

The reason is that the CentOS `@core` package group does not contain
`subscription-manager`. Thus it is not installed on CentOS Stream by
default and also CentOS 8 image definitions don't apply any changes
to the RHSM configuration [1].

In addition, make sure to not install any subscription-manager
packages on CentOS Stream images.

Regenerate all CentOS 8 image test cases.

[1] https://git.centos.org/centos/kickstarts/tree/master

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
e6c55efe08 RHEL-90: replace ostreeTreePipeline by osPipeline
Enhance the `osPipeline` to add necessary stages to the returned
pipeline, in case the image is RPM OSTree based. As a result, delete the
`ostreeTreePipeline` and replace its uses by `osPipeline`.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
90e00c48fa RHEL-90: make the osPipeline self-contained
Make the `osPipeline` self-contained in the sense, that no stages are
added to the returned pipeline outside of the function and the returned
pipeline is usable as returned.

Modify the `osPipeline` to add Kernel Cmdline, FSTab and bootloader
config stages to the pipeline if a valid partition table was passed to
the function. As the last one, the SELinux stage is appended to the
returned pipeline.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
36e81bfdac RHEL-90: replace rhelEc2SapPipelines by rhelEc2Pipelines`
Move the EC2 SAP image specific configuration from `ec2SapPipelines`
to the EC2 SAP default image configurations data structure. As a
result, remove the `ec2SapPipelines` and `rhelEc2SapPipelines` entirely
and use `rhelEc2Pipelines` for all RHEL EC2 images.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
43ea54f8de RHEL-90: replace ec2X86_64BaseTreePipeline by osPipeline
Move the x86_64 specific configuration from `ec2X86_64BaseTreePipeline`
to x86_64-specific image configurations for EC2 / AMI images. As a
result, remove the `ec2X86_64BaseTreePipeline` entirely and replace it
with `osPipeline`.

Regenerate image test cases. While there are changed in the manifests,
the actual image configuration didn't change at all and thus the
`image-info` report was not changed.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
776de86e6d RHEL-90: replace ec2BaseTreePipeline by osPipeline
Move all hard-coded image configuration from the `ec2BaseTreePipeline`
function to the `ImageConfig` structure and update the respective EC2
images default configuration structure.

Update `osPipeline` and `ostreeTreePipeline` to handle all of the new
configuration values from `ImageConfig`.

Completely remove the `ec2BaseTreePipeline` and replace it with
`osPipeline`.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
755154179d RHEL-90: do not install subscription-manager on non-RHEL
Do not install any subscription-manager packages on non-RHEL distro
variant of RHEL-90 (meaning CentOS Stream). Subscription-manager is not
needed on CentOS Stream and it does not add value to install it by
default. It is also not included on images produced by CentOS Stream.

Relevant links:
- https://gitlab.com/redhat/centos-stream/release-engineering/comps/-/merge_requests/151
- https://bugzilla.redhat.com/show_bug.cgi?id=1962385
- https://gitlab.com/redhat/centos-stream/release-engineering/kickstarts/-/blob/main/CentOS-Stream-9-kvm.ks#L115

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
8130c892f0 RHEL-90: move RHSM configuration to ImageConfig structure
Move the RHSM configuration settings to `ImageConfig` structure and use
when handling subscriptions in `osPipeline`, `ec2BaseTreePipeline` and
`ostreeTreePipeline` functions.

Regenerate image test cases. While there are changed in the manifests,
the actual image configuration didn't change at all and thus the
`image-info` report was not changed.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Tomas Hozza
b200fa8fcd RHEL-90: introduce default image config data structure
Introduce a new data structure `ImageConfig` holding the default OS
configuration applied when building an image. The structure can be used
to hold the default image configuration on the distribution level with
possible overrides defined on the image-type level.

As a starting point, move hard-coded default values and configuration
common for `osPipeline`, `ec2BaseTreePipeline` and `ostreeTreePipeline`
to the distribution and image-type default image configuration. This is
preparing the ground for merging all of these three pipeline functions
into `osPipeline`, which will produce the appropriate OS pipeline based
on the image-type configuration and the fact if it is rpmOstree or not.

Regenerate affected EC2 and AMI manifests. There is however no change in
the resulting image configuration and image-info report.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-01-11 17:08:19 +01:00
Ondřej Budai
d967790ea5 api/cloud: drop v1 API
It's deprecated and not used anywhere, let's just drop it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-01-04 16:38:50 +01:00
Ondřej Budai
e668ed0ac5 weldr: return an error if host distro wasn't found in distro registry
Prevents a nil panic, see rhbz#2035956

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-01-03 18:05:15 +01:00
Tomas Hozza
885fe3d2b4 osbuild2: fix typo in tar stage option value
Related to https://github.com/osbuild/osbuild/pull/940

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-22 10:41:22 +01:00
Tomas Hozza
35ef067396 osbuild2: support 'format' and 'root-node' Tar stage options
Bring the Tar stage implementation on par with the current osbuild
schema. Specifically add the 'format' and 'root-node' options to the
stage options structure.

Add stage options validation along with appropriate unit tests.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-21 20:40:12 +01:00
Ondřej Budai
ab3990b90a dbjobqueue: fix FinishJob not returning an error if already finished
Reported by covscan

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-12-18 00:14:07 +00:00
sanne
2543459a7f osbuild2: Expand dnf_config stage 2021-12-17 20:07:56 +01:00
sanne
8406ada6f5 worker: Treat a non echo.HTTPError like a regular error 2021-12-17 13:13:05 +01:00
Tomas Hozza
30f64d190d osbuild2: ensure that empty sysconfig options members are omitted
The `Kernel` and `Network` members of the sysconfig stage options
structure were previously not declared as pointers. As a result, they
always appeared in the resulting JSON object, even though they were
empty. Use pointers to ensure that the members are omitted from the
resulting JSON object, if they were not defined.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-16 20:47:28 +01:00
Tomas Hozza
96000173db osbuild2: do not use reflect in pam.limits.conf stage
Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-16 20:01:42 +01:00
Tomas Hozza
09cd5b3576 osbuild2: support org.osbuild.dnf-automatic.config stage
Add support for the new `org.osbuild.dnf-automatic.config` stage for
configuring DNF Automatic.

Add appropriate new unit tests for the stage implementation and modify
necessary existing unit tests.

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

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-16 20:01:42 +01:00
Tomas Hozza
97ef7fbf28 osbuild2: support org.osbuild.yum.repos stage
Add support for the new `org.osbuild.yum.repos` stage for creating DNF /
YUM repository configuration files.

Add appropriate new unit tests for the stage implementation and modify
necessary existing unit tests.

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

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-16 20:01:42 +01:00
Tomas Hozza
37a39743bc osbuild2: support PermitRootLogin in sshd.config stage
Add support for the `PermitRootLogin` option in the `sshd.config` stage.
Valid values can be of type `bool` or `string`. Due to this reason, a
custom interface type is defined and a custom `UnmarshalJSON()` method is
defined for the `SshdConfigConfig` structure.

Modify unit tests to test the newly added option and test
(un)marhsalling of valid values of both types.

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

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-16 20:01:42 +01:00
Diaa Sami
487e2d0669 internal/cloud: use logrus for logging
and log upload & sharing failures
2021-12-16 11:58:41 +00:00
Diaa Sami
510d2ccac0 worker/server: pass more error details to handler 2021-12-16 11:58:41 +00:00
Diaa Sami
c1aeeeaf0e internal/worker: log internal details when available 2021-12-16 11:58:41 +00:00
Gianluca Zuccarelli
e165db63ea metrics: add additional buckets
The change between the 32s bucket and the 64s bucket is too drastic
for measuring the duration of depsolve jobs. At present, 90% of the
depsolve jobs have a duration inbetween 32s and 64s, making the 32s
bucket too sensitive and the 64s bucket not sensitive enough.
2021-12-15 19:53:11 +00:00
Djebran Lezzoum
c93ea748a2 distro/depsolve/cloudapi: Add 3rd-party repository support.
Allow 3rd-party repositories to be supported and custom packages installed.
Fixes #COMPOSER-1273
2021-12-15 20:12:49 +01:00
Thomas Lavocat
ca126e9747 dnf-json: Change dnf-json to be a daemon
The service is started via systemd activation sockets.
The service serves http POST requests, the same json as before is
expected as the body of the request, and the same json as before is sent
as the response of the request.
2021-12-15 09:41:32 +01:00
Tomas Hozza
66cd704198 RHEL-9.0: use the default partitioning scheme for all EC2 images
This change is part of unifying the default partitioning scheme used by
all RHEL-9.0 images [1].

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

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-13 12:33:16 +01:00
Tomas Hozza
661cd2772d RHEL-9.0: add / fix BIOS boot partition size comment
Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-13 12:33:16 +01:00
Tomas Hozza
52115716d7 RHEL-9.0: increase the size of /boot/efi partition to 200 MB
Increase the size of /boot/efi partition in the default partition table
used for x86_64 and aarch64 architectures. The size is the same as what
is being used by RHEL EC2 aarch64 image as well as what ie being
suggested by RHEL-8 documentation [1]. There is currently no
documentation equivalent for RHEL-9 yet.

This change is part of unifying the default partitioning scheme used by
all RHEL-9.0 images.

[1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/performing_an_advanced_rhel_installation/partitioning-reference_installing-rhel-as-an-experienced-user
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2022805

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-13 12:33:16 +01:00
Tomas Hozza
4366acc8f4 RHEL-9.0: add separate /boot partition to default partition table
Add a separate /boot partition to the default partition table used on
RHEL-9.0. The size is set to 500 MB, which is the value used by RHEL EC2
images. This change is needed to unify the default partitioning scheme
used by all RHEL-9.0 images [1].

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

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-12-13 12:33:16 +01:00