Commit graph

4395 commits

Author SHA1 Message Date
Tomas Hozza
c4ba6d8b11 OSBuildJob: support more than one export and drop assembler fallback
Drop the fallback to the `assembler` export if no is specified in the
job and return Job Error in this case.

Remove the constraint to support only a single osbuild export. The job
is now able to use multiple osbuild exports and each target may use a
different one.
2022-07-01 18:55:01 +01:00
Tomas Hozza
776a54135f worker: move osbuild exports from OSBuildJob to target
The osbuild export is specific to the upload target and different
targets may require using a different export. While osbuild-composer
still does not support multiple exports for osbuild jobs, this prepares
the ground for such support in the future.

The backward compatibility with older implementations of the composer
and workers is kept on the JSON (Un)mashaling level, where the JSON
message is always a super-set of the old and new way of providing the
exports to osbuild job.
2022-07-01 18:55:01 +01:00
Tomas Hozza
4e26ba82d0 worker: drop ImageName from the OSBuildJob struct
The `ImageName` in `OSBuildJob` is not used any more by any API
implementation 	or any worker job implementation. Drop it from the
structure.
2022-07-01 18:55:01 +01:00
Tomas Hozza
6a12ce1998 worker: drop implicit upload to server based on OSBuildJob.ImageName
Weldr API already does not rely on this code and nothing else uses it.
Since the code has been used only on-premise, where we expect the
composer and workers to be always of the same version, there is no need
to keep backward compatibility in the worker.
2022-07-01 18:55:01 +01:00
Tomas Hozza
165a05ab43 weldr: use "Worker Server" target instead of setting ImageName
Stop relying on the server interpreting the set `ImageName` in the
`OSBuildJob` as a signal to upload the image back to the worker server
and add an explicit "Worker Server" upload target to the job.
2022-07-01 18:55:01 +01:00
Tomas Hozza
a12827865d target: add explicit target for uploading back to worker server
The uploading of artifacts back to the worker server for the on-premise
(Weldr) use case was signaled to the worker by setting the `ImageName`
in the `OSBuildJob` definition. The code also relies on the osbuild
exports being specified in the `OSBuildJob`, instead of in the target
(this is not implemented yet).

Prepare the ground for moving osbuild export definition from
`OSBuildJob` to `Target` by introducing an explicit `Worker Server"
upload target. This target will signal to the worker that it should
upload the image back to the worker server. The new target is not yet
used by any API implementation.

Extend the worker osbuild job implementation to handle the new upload
target.
2022-07-01 18:55:01 +01:00
Tomas Hozza
a61b8af261 cloudapi: fix issue in koji api test forgotten in #2758
The `TestKojiJobTypeValidation` unit test used the `OSBuildJob` and
Koji Target fields in the wrong way, however without any impact on the
testing itself. The reason is that no actual images were built as part
of the test nor the created jobs were ever picked up by a worker.

This change was forgotten in PR#2758.

[1] https://github.com/osbuild/osbuild-composer/pull/2758
2022-07-01 18:55:01 +01:00
Tomas Hozza
6f464949f5 target: move Filename from target options to Target
The filename of the image as produced by osbuild for a given export is
currently set in each target options type in the `Filename` struct
member. However, the value is not really specific to any target type,
but to the specific export used for the target. For this reason move the
value form target type options to the `Target` struct inside a new
struct `OsbuildArtifact` under the name`ExportFilename`.

The backward compatibility with older implementations of the composer
and workers is kept on the JSON (Un)mashaling level, where the JSON
object is always a super-set of the old and new way of providing the
export filename in the Target.
2022-07-01 18:55:01 +01:00
Tomas Hozza
eda691971c weldr/upload: stop setting Filename in gcpUploadSettings
The `Filename` previously set in the `gcpUploadSettings` does not
provide any value. It is the filename of the image as produced by
osbuild for a given export. It may not correspond with the object name
when the image is uploaded to GCP storage and may not even correspond
with the image name after it is imported to GCE. Stop setting the value
and remove the variable from data structures.

This change should not have any impact on backward compatibility,
because the field will be ignored when (Un)Marshalling.
2022-07-01 18:55:01 +01:00
Tomas Hozza
8c8468cd33 worker/osbuild: use more self-explanatory variable names
Some variable names used in the `OsBuildJob` `Run()` method were not
very self-explanatory, which made the code harder to understand and
navigate. These were `args`, `options`, `t`. Rename them to be more
self-explanatory of their purpose.
2022-07-01 18:55:01 +01:00
Tomas Hozza
7bfd3aec71 target/oci: OCITargetOptions.FileName -> OCITargetOptions.Filename
The `Filename` is defined in each and every target options. Modify its
name in the OCI target to be consistent with all other targets.
2022-07-01 18:55:01 +01:00
Tomas Hozza
40abb32dec target: deprecate local target and don't use it anywhere
Completely remove the use of `local` target from all code, which is not
required to keep backward compatibility. The target has not been used in
composer for some time already, but some unit tests still used its data
structures. Mark the target as deprecated and adjust all unit tests that
depended on it.

The backward compatibility is kept mostly to enable long running
osbuild-composer instances, which were upgraded to still read old jobs
from the store.

While a target with the same intention will be reintroduced, the current
`local` target data structures contain many fields which would not be
relevant for the new target.

In addition, while the "local" target will be ever used only by Weldr
API, the name would be a bit misleading. Although the worker usually
runs on the same system when using Weldr API, there is no hard
requirement enforcing this setup. In reality, the worker will be
uploading the image back to the worker server, so there is room for a
better name.
2022-07-01 18:55:01 +01:00
Tomas Hozza
a7b97697de store: delete unused GetLocalTargetOptions() method 2022-07-01 18:55:01 +01:00
Tomas Hozza
95e2e75851 worker/osbuild: stop handling VMDK stream-optimized conversion
A backward compatibility code handling the conversion of VMDK image to
stream-optimized sub-format has been kept in the implementation since
PR#2529 [1] merged on May 4th 2022. Since this change, no API
implementation is submitting jobs, which would hit this conversion code,
because VMDK images are already being produced in the desired
sub-format.

On-premise deployments are expected to use the same composer and worker
versions. There are no composer / worker instances in production, which
are not running the modified code.

Delete the backward compatibility code.

[1] https://github.com/osbuild/osbuild-composer/pull/2529
2022-07-01 18:55:01 +01:00
Tomas Hozza
fc6bd60b94 worker/osbuild: handle multiple upload targets
Modify the `OsBuildJob` implementation to handle multiple upload targets
in a cycle. However, there is still no API implementation, which would be
adding `OsBuildJobs` with multiple targets to the job queue.

The limitations are that only a single osbuild export is supported, and
the same artifact will be used for each target.

At the end of the job, errors from all targets are gathered. In case
there are none, the job succeeds. In case at least one target failed,
the job fails as well. In such a case, a slice of errors from all failed
targets is added to the job error as details.
2022-07-01 18:55:01 +01:00
Tomas Hozza
6dcadc9d20 worker/osbuild: move target errors to detail of job error
Add a new worker client error type `ErrorTargetError` representing that
at least one of job targets failed. The actual target errors are added
to the job detail.

Add a new `OSBuildJobResult.TargetErrors()` method for gathering a slice
of target errors contained within an `OSBuildJobResult` instance. Cover
the method with unit test.
2022-07-01 18:55:01 +01:00
Tomas Hozza
20cb2e1b2c worker/osbuild: set error in target result
Ensure that a target result with a proper error is added to the Job
result, in case the there was any error encountered. This error is not
used at all for now. Keep setting the `JobError` to the same error set
in the target result for now.

This is a step towards job results containing multiple target results
with each or them having potentially an error set as well.
2022-07-01 18:55:01 +01:00
Tomas Hozza
ff669b8f2c worker/osbuild: do not set job results in uploadToS3()
Do not pass the `worker.OSBuildJobResult` to `uploadToS3()`, but instead
return target errors from the function. This will make the error
handling of all upload targets consistent and easier to modify to
support multiple targets.
2022-07-01 18:55:01 +01:00
Tomas Hozza
93fd5e3821 target: ensure that each used target has NewXXXTargetResult defined
Ensure that `UnmarshalTargetResultOptions()` is called only when there
are any options to unmarshal in the JSON object.

Since results of some Targets don't have any options defined, mark
`TargetResult.Options` as optional in the JSON tag.
2022-07-01 18:55:01 +01:00
Tomas Hozza
6f13db5b92 target: extend TargetResult with TargetError
This will enable reporting of target-specific errors from jobs, once
they'll support multiple targets.

Target errors are currently reported via `JobResult.JobError`.
2022-07-01 18:55:01 +01:00
Tomas Hozza
59ded68457 worker: delete TargetErrors from OSBuildJobResult
The `TargetErrors` is not used any more since PR#2192 [1] and there is
no need to keep the backward compatibility any more, because there are
no composer / worker instances in production, which are not running the
modified code.

In addition, delete unit tests covering this legacy error handling.

[1] https://github.com/osbuild/osbuild-composer/pull/2192
2022-07-01 18:55:01 +01:00
Tomas Hozza
c63bfe6d83 target: use constants for target names, instead of string literals 2022-07-01 18:55:01 +01:00
Juan Abia
f6fa5ccca1 remove cloud cleaner
scheduled cloud cleaner now uses a new method to remove azure resources.
So cloud cleaner code is not used
2022-07-01 17:47:44 +02:00
Jakub Rusz
6d15c03d2f tools/generic_s3: remove unused condition
This is a copypaste from other tests. Test can be ran on nightlies and
is passing.
2022-07-01 13:00:52 +03:00
Jakub Rusz
3547764687 CI: Don't run ContainerUpload job on scheduled pipelines 2022-07-01 13:00:52 +03:00
Jakub Rusz
8d6b998b0a tests/libvirt: boot with uefi on rhel and centos
Updating condition to run on all rhel and centos runners. Before this
eufi was not tested on all supported runners.
2022-07-01 13:00:52 +03:00
Achilleas Koutsou
444b8e33c9 distro: don't enable fdo-client service on RHEL 8.5
RHEL 8.5 doesn't have FDO and it's not installed, but we were enabling
the service for it in edge.
2022-06-30 18:34:45 +02:00
Christian Kellner
54ae069b94 distro: remove rhel 9 beta
This was a stop-gap until the actual rhel 9 distro was created. It
is in a sad state, quite broken and shout not be used by anybody.
Put it out of its misery.
2022-06-30 14:15:33 +02:00
Juan Abia
8f9bb1bc01 tag azure resources with gitlab-ci-test
cloud cleaner removes old enough resources with 'gitlab-ci-test' tag.
2022-06-30 13:46:15 +02:00
Ygal Blum
08811dd632 Composer API - add support for services enable/disable
Add service sections to the customization unittests
2022-06-30 13:32:12 +02:00
Achilleas Koutsou
fc1d754999 distro: remove rhel85
Remove RHEL 8.5 distro source files.
RHEL 8.5 is now defined in the rhel86 package.
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
436d8f9b43 distro/rhel86: add RHEL 8.5 variant
Define the distribution strings for RHEL 8.5 in distro/rhel86 and add
constructors.  Remove the old 8.5 from the distro registry and use the
new constructors.

Composer can now build RHEL 8.5 image-installer on aarch64, which wasn't
supported before.

RHEL 8.5 manifests have changed to minimise the differences from 8.6.
Some changes are fixes made in 8.6 but never backported to 8.5 because
of our (older) policy of not changing definitions after the release of a
distro.
Other changes are non-functional (e.g., stage or package order).

See the list below for the source of each change.

Manifest changes:
- Stage order changed for org.osbuild.systemd-logind and
  org.osbuild.rhsm.
- org.osbuild.grub2 options: config.default = "saved"
  Reverted 111cd8871f
- Partition sizes: RHEL 8.5 had extra arbitrarily sized padding for the
  header.  Now all partitions are sized to fit headers exactly.
  Original change at b7abef54e8.
- SELinux set to permissive in Anaconda.  This was changed in RHEL 8.6
  and 9.0 but never backported to 8.5.
  See a7fbe916b7.
- Installer isolevel set to 3.  Like above, this was changed in
  8.6 and 9.0.
  Original change at d8d161480e.
- Specify a remote for edge deployments.
  Original change at b18b4e80a0.
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
56e6208fcf distro/rhel86: imagetypes and packages per RHEL version
Added utility function for comparing RHEL version strings.

Conditions added:
- greenboot subpackages were changed between RHEL 8.5 and RHEL 8.6.
- fido client packages aren't available in RHEL prior to 8.6.
- the ec2 SAP image type is not supported in RHEL prior to 8.6.
- the edge-simplified-installer and edge-raw-image image types are not
  supported in RHEL prior to 8.6.
    - They were previously supported in 8.5 without FDO support, but now
      it's dropped from 8.5 completely.
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
e2e77a1190 distro/rhel86: reformat package sets
- One package per line for easier reading and diffing.
- Sorted alphabetically.  Exceptions made for sub-grouping.
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
0a82fe4561 distro/rhel86: reorganise addImageTypes() call
One image type per line.
Sorted alphabetically.
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
062e38da69 osbuild-package-sets: check for required cl args
Print usage when one or more required arguments are omitted.
Fix the error message for incorrect distro: print distroName, not distro
(nil).
2022-06-30 11:14:21 +02:00
Achilleas Koutsou
5e14c34462 gen-manifests: add descriptions for command line flags 2022-06-30 11:14:21 +02:00
Achilleas Koutsou
8adb502aa0 gen-manifests: add flag for setting cache location 2022-06-30 11:14:21 +02:00
Achilleas Koutsou
5ac0ef2f77 test: update RHEL 8.5 manifests
Package changes from RHUI repository updates.
2022-06-30 11:14:21 +02:00
Ondřej Budai
3fcb737243 worker/koji-finalize: fix result options casting
It's actually a pointer, this caused a panic before, let's fix it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-06-29 16:44:10 +02:00
Ondřej Budai
0693274ffe worker/server: set a job error when heartbeat gets missing
Previously, we just used an empty struct when heartbeat failed. This is fine
for the osbuild job because it's treated as a failed one when
result.OSBuildResult == false which is the default value.

koji-finalize works differently though: It's in a failed state if there's
an job error of kojiError != "". So when failed heartbeat set the struct to
be empty, this was treated as success because there's no error.

Let's fix this by introducing a new error for the situation where we don't get
a heartbeat in time for a specific job.
2022-06-29 16:44:10 +02:00
Jakub Rusz
358e58f3d3 image-tests: skip azure-rhui test on rhel-86 2022-06-29 15:21:59 +02:00
schutzbot
d1b6a6455c Post release version bump
[skip ci]
2022-06-29 08:30:35 +00:00
Achilleas Koutsou
321295e34d test/diff-manifests: don't fail on diffs
The script isn't supposed to fail when the manifests differ.
Initialise err to 0 and assign it the exit code of the diff call if it
returns with an error.
2022-06-29 10:02:46 +02:00
Christian Kellner
dbd2ed6cc8 ci: add new container uploading test
Add a new integration test that will create a fedora container and
upload it to the gitlab container registry.
2022-06-29 10:02:46 +02:00
Christian Kellner
c5a5da5f56 distro/fedora: add container image type
Add a container image type that is based on the existing fedora
container image. There is a delta in terms of the configuration
because osbuild does not yet provide all the neccessary means,
but the package set is already very close.
2022-06-29 10:02:46 +02:00
Christian Kellner
59edcc4a46 distro/fedora: only pass kernelName to NewOSPipeline for bootable images
If the image is not bootable it means that we do not need the kernel
version and thus we should not pass it along to `NewOSPipeline`,
because we might not even have a kernel in the package set.
2022-06-29 10:02:46 +02:00
Christian Kellner
49559d53d7 pipeline/os: only infer kernel version if name is not empty
Do not try to infer the kernel verison if `kernelName` is the
empty string.
2022-06-29 10:02:46 +02:00
Christian Kellner
776dfd2da6 distro: option to exclude docs during installation
We don't ship documentation in container images, add an option to
ImageConfig to disable the installation of docs during installation.
2022-06-29 10:02:46 +02:00
Christian Kellner
f37a791bd2 distro: new image config to disable selinux
We don't need to label container artifacts, so include an option
in the image config to disable it.
NB: This is a boolean that with the default false in order to
not have to change every existing image configuration.
2022-06-29 10:02:46 +02:00