Commit graph

858 commits

Author SHA1 Message Date
Ondřej Budai
3f15b97af0 rhel84: fix kernel cmdline for s390x
RootFsUUID should be the UUID of a root filesystem, not of a root partition.

🤦 sorry!

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-01-14 20:29:52 +01:00
Jacob Kozol
45138801f9 distro/rhel84: fix s390x kernel options
Our s390x images now use the kernel commandline options set in the image
type's declaration.
2021-01-14 12:59:31 +01:00
Jacob Kozol
9d0d5967d6 distro/rhel84: use New York as default timezone
RHEl 8.4 guest images need to have the default timezone of EST/EDT
unless the user specifies one in their blueprint. New York is a major
location for this timezone.
2021-01-13 17:49:51 +01:00
Lars Karlitski
cb894ccf68 jobqueue: remove testjobqueue
testjobqueue did not implement the JobQueue interface correctly (noted
in its package comment), making it impossible to write tests for
JobQueue itself.

Replace its use everywhere with fsjobqueue operating on a temporary
directory.
2021-01-12 12:19:25 +01:00
Lars Karlitski
90e15da032 kojiapi/test: use the worker of the fixture
No need to create a second one.
2021-01-12 12:19:25 +01:00
Jacob Kozol
da6f5ba701 kojiapi,cloudapi: exclude packages when depsolving
When rpmmd's Depsolve function is called we need to pass in the image
type's excluded packages. These excluded packages are retrieved when we
get the packages we include from each image type.
2021-01-06 21:34:37 +01:00
Ondřej Budai
1b05192298 upload/azure: use the new azure/azblob API on Fedora 33+ & RHEL
Fedora 33 and rawhide got an updated version of the azblob library. Sadly, it
introduced a non-compatible API change. This commit does the same thing as
a67baf5a did for kolo/xmlrpc:

We now have two wrappers around the affected part of the API. Fedora 32 uses
the wrapper around the old API, whereas Fedora 33 and 34 (and RHEL with its
vendored deps) use the wrapper around the new API. The switch is implemented
using go build flags and spec file magic.

See a67baf5a for more thoughts.

Also, there's v0.11.1-0.20201209121048-6df5d9af221d in go.mod, why?

The maintainers of azblob probably tagged a wrong commit with v0.12.0 which
breaks go. The long v0.11.1-.* version is basically the proper v0.12.0 commit.
See https://github.com/Azure/azure-storage-blob-go/issues/236 for more
information.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-01-06 16:31:28 +01:00
Ondřej Budai
1dd4eb7e38 composer: seed the random number generator
I thought rand in Go is auto-seeded but I was wrong, see [1].
This commit adds seed initialization.

[1]: https://golang.org/pkg/math/rand/#Seed

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 21:26:40 +01:00
Ondřej Budai
973639d372 distro/rhel84: use a random uuid for XFS partition
Imagine this situation: You have a RHEL system booted from an image produced
by osbuild-composer. On this system, you want to use osbuild-composer to
create another image of RHEL.

However, there's currently something funny with partitions:

All RHEL images built by osbuild-composer contain a root xfs partition. The
interesting bit is that they all share the same xfs partition UUID. This might
sound like a good thing for reproducibility but it has a quirk.

The issue appears when osbuild runs the qemu assembler: it needs to mount all
partitions of the future image to copy the OS tree into it.

Imagine that osbuild-composer is running on a system booted from an imaged
produced by osbuild-composer. This means that its root xfs partition has this
uuid:

efe8afea-c0a8-45dc-8e6e-499279f6fa5d

When osbuild-composer builds an image on this system, it runs osbuild that
runs the qemu assembler at some point. As I said previously, it will mount
all partitions of the future image. That means that it will also try to
mount the root xfs partition with this uuid:

efe8afea-c0a8-45dc-8e6e-499279f6fa5d

Do you remember this one? Yeah, it's the same one as before. However, the xfs
kernel driver doesn't like that. It contains a global table[1] of all xfs
partitions that forbids to mount 2 xfs partitions with the same uuid.

I mean... uuids are meant to be unique, right?

This commit changes the way we build RHEL 8.4 images: Each one now has a
unique uuid. It's now literally a unique universally unique identifier. haha

[1]: a349e4c659/fs/xfs/xfs_mount.c (L51)
2020-12-15 16:43:39 +01:00
Ondřej Budai
ae0d1b8663 distro/rhel84: remove hardcoded root partition UUIDs
Let's use the root partition UUID from the partition table instead of
hardcoding the value.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 16:43:39 +01:00
Ondřej Budai
d52c1ea1f8 distro/rhel84: generate fstab stage from partition table
Now that we have an abstract partition table definition, we can use it to
generate org.osbuild.fstab stage options.

This is extremely nice because it removes magic contains.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 16:43:39 +01:00
Ondřej Budai
76926ecd35 distro/rhel84: encode the partition table using abstract data-types
Using osbuild.QEMUAssemblerOptions to encode a partition table was weird.
This commit introduces a disk package that contains data types for defining
partition tables. Also, there's a handy function to convert the abstact
partition table to osbuild.QEMUAssemblerOptions.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 16:43:39 +01:00
Ondřej Budai
a9c367ab4a distro/rhel84: factor partition table definition out of assembler
Previously, the partition table definition was defined inside an assembler.
This has an issue though: The partitions and filesystems are needed at several
other places, e.g. grub2 stage and fstab stage. As the partition table was
basically hardcoded, this didn't matter - we could just use constants
in these stages. Not ideal but it worked.

This commit changes the behaviour: A partition table is firstly created and
then it's passed to the assembler function where complete assembler options
are created out of it.

To make this change as small as possible, osbuild.QEMUAssemblerOptions type
is used to encode the partition table for now.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 16:43:39 +01:00
Ondřej Budai
e725ca0dd5 distro/test: improve manifest diffing
require.JSONEqf cannot handle diffs of such a big entity as a manifest is.
It just prints an empty string.

This commit unmarshalls the manifests instead and then uses the cmp library
to make a very nice and readable diff.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-15 16:43:39 +01:00
Jacob Kozol
51c08105fe distro/rhel84: update kernel options
The kernel options are updated to remove the read only option "ro" from
the qcow2 and amazon image types. Also, the qcow2's kernel options are
updated to only set console=ttyS0 once. It was declared twice which is
redundant so now it is set for both tty0 and ttyS0.
2020-12-11 18:53:30 +01:00
Jacob Kozol
a827e594bf distro/rhel84: remove rng-tools
rng-tools is no longer included as a package in the RHEL 8.4 image. This
package is both removed from being an included package and also
specifically declared as excluded. The test manifests are updated.
2020-12-08 14:04:40 +01:00
Christian Kellner
f0896be0c0 distro/rhel84: use the org.osbuild.rhel84 runner
The RHEL 8.4 specific runner was introduced in osbuild 22, released
on the 8th of October 2020. It should by now be in relevant Fedora
releases and RHEL 8.4.
Adapt the corresponding test cases.
2020-12-04 19:28:44 +01:00
Ondřej Budai
3d465a4778 api/koji: invert the compose status condition
This is just easier to grasp.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-02 10:27:31 +01:00
Ondřej Budai
00cd4cb346 api/koji: return pending status until all jobs are finished
Previously, the compose status returned failure as soon as possible.
koji-osbuild considers the job as done when its status == failure and proceeds
with uploading the logs to koji and marking the job as failed. However, not
all osbuild-composer jobs might be done at this point so the logs might be
incomplete making the debugging hard.

This commit changes the behaviour: Now, the compose status is pending until
ALL jobs belonging to it are finished.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-02 10:27:31 +01:00
Ondřej Budai
e10a7f1ccc {koji,worker}/server: log errors returned from handlers
Previously, we had no clue what errors were catched by the default echo's
error handler. Thus, in the case of an error, we were basically blind. Let's
log all errors so we can investigate them later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-02 08:52:27 +01:00
Ondřej Budai
915c9d6c50 distro/rhel84: change the default size of qcow2 to 10 GiB
The default size of RHEL 8 qcow2 images is 10 GiB, let's align our default.

Related: rhbz#1846087
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 14:33:23 +00:00
Ondřej Budai
f1b7476da5 test: add arch to the generate test artifact names
To prevent conflicts sooner rather than later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
18258238d9 test: extract GenerateCIArtifactName to test helpers
A bit of deduplication can never hurt.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
9f80c2ac8e test/image: print saner error messages
%#v was my bad understanding of Go's error formatting. Let's use the standard
%v that gives saner and human-readable error messages.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
7256a92d15 test/image: use t4g.micro instance type for aarch64
The instance type is arch-dependant, therefore it's needed to pick the right
one for a given arch.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Ondřej Budai
4548923a09 upload/aws: fix architecture for aarch64 images
Previously, composer wrongly set x86_64 architecture even for aarch64 images.
This commit fixes it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-12-01 08:27:44 +01:00
Christian Kellner
9b2d565545 distro/rhel84: no hybrid boot on aarch64
Hybrid boot, i.e. MBR+UEFI, is only supported on x86_64, but not
on aarch64, which only supports UEFI. Therefore, disable legacy,
i.e. MBR, boot for aarch64 and remove the corresponding BIOS boot
partition.
Since hybrid boot is always used on x86_64, the "uefi" parameter
is removed completely, together with the "legacy only" option on
x86_64. Thus we are left with a simple one to one mapping of
architecture to qemu assembler stage options in `qemuAssembler`.
2020-11-27 00:43:14 +00:00
Sanne Raymaekers
22c9f6af61 cloudapi: Share an ec2 snapshot/ami with an account 2020-11-26 13:08:18 +00:00
Chloe Kaubisch
6388aaff4c cloudapi: add support for mirrorlist and metalink repos
Previously, baseurl was required in openapi.yaml. In order to add support
for metalink and mirrorlist repos as well, make all optional, since openapi
does not support mutually exclusive parameters. Instead, enforce this logic
in server.go, and if no repo has been specified, return a 400 bad request error.
2020-11-26 14:07:59 +01:00
Ondřej Budai
04c239246a internal/test: remove redundant API interface
test.API is actually just http.Handler, let's use this interface directly
instead of defining our own one.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-25 22:20:42 +00:00
Lars Karlitski
dfe748265d distro/rhel84: don't install uefi packages on all arches
These packages are architecture-specific. Including them in the generic
package list broke image builds for everything but x86_64.

The corresponding architecture-dependant packages were already included
in `arch.bootloaderPackages` (some via dependencies).

Fixes #1103
2020-11-25 12:25:27 +01:00
Ondřej Budai
978e309153 worker/server: move it to the style of koji server
The previous code was smelling a bit (e.g. Server.server field) so I decided
to rewrite it in the style of the much nicer koji server.

Not a functional change.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-19 17:39:24 +00:00
Jacob Kozol
0dd17ae3f7 distro: add rhel 84 support
cockpit-composer can now build rhel 8.4 images. Our distro name for
rhel 8.4 is rhel-84 unlike prior rhel releases which fall
under the umbrella name rhel-8. rhel 8.4 still uses the same
repos as the rest of the rhel 8 releases but points to a different
nightly repo for testing purposes. Test cases are added. The changes
between rhel 8.3 and 8.4 are as follows:

There is now a hybrid boot partition scheme for x86_64. x86_64 images
now use uefi boot and have 3 gpt partitions: a small unformated
partition for mbr compatibility, an efi boot partition of type vfat, and
a root partition of type xfs. The packages grub2-efi-x64 and shim-x64
are added as bootloader packages for all x86_64 images.

For qcow2 images ro is added as a kernel option and the following
packages are added (+) or removed (-):
+ dosfstools
+ efi-filesystem
+ efivar
+ efivar-libs
+ grub2-efi-x64
+ shim-x64
- rhn-client-tools
- rhnlib
- rhnsd
- rhn-setup
2020-11-19 10:36:49 +01:00
Tom Gundersen
bf86e8ad79 workerapi: serialize koji errors as strings
Serializing an interface does not work, let us simply use the string
representation and treat the empty string as no error. This is
compatible with the current API in the success case, and fixes the
error case, which is currently broken.

Also extend the test matrix for the kojiapi to ensure that all the
different kinds of errors can be serialized correctly and leads to
the correct status being returned.

Fixes #1079 and #1080.
2020-11-13 09:39:55 +01:00
Ondřej Budai
a6df2877a3 fsjobqueue: accept jobs of any type
Soon, we want to begin tagging the jobs with the name of its submitter.
The simplest way to add a tag to a job is to put it into its type string.
However, as we don't know (and don't want to know) the submitters' names when
osbuild-composer is initialized, we need to be able to push arbitrary job
types into the jobqueue.

This commit therefore lifts the restriction that a jobqueue accepts only
a predefined set of job types. Now, jobqueue clients can push jobs of
arbitrary names.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-12 15:30:30 +00:00
Ondřej Budai
e007f9964e fsjobqueue: extract channelSize constant 2020-11-12 15:30:30 +00:00
Tom Gundersen
f9af1e3e13 kojiapi/logs: adjust for multi-build composes
Return the full array of image build logs, as well as logs for the
init and import tasks.
2020-11-11 18:16:42 +01:00
Tom Gundersen
a99127aed9 kojiapi: add basic test
This test schedules a compose, pops the jobs off the queue, marks each
as done and verifies that the compose is correctly marked as successful.
2020-11-11 18:16:42 +01:00
Tom Gundersen
4a484c8192 worker/server: extend the route tests a bit
Test the update and upload routes too, for completeness.
2020-11-11 18:16:42 +01:00
Tom Gundersen
5dac422b9c cmd/composer: drop koji configuration
Now that all interaciton with the koji API happens in the workers
we can drop koji configuration from composer itself. This means
that composer no longer needs to be provisioned with kerberos
credentials, and does not need to know about which koji servers
the workers support.
2020-11-11 18:16:42 +01:00
Tom Gundersen
654daf96c1 kojiapi: return BuildID from status route
This is no longer returned when creating a compose, as it is obtained
asynchronously.

The TaskID is still returned, and is always set to 0. This is not right,
and should either be fixed or dropped. The caller should know the TaskID
(if they have one), so this is redundant and currently unused.
2020-11-11 18:16:42 +01:00
Tom Gundersen
c777a18df0 jobqueue: expose dependencies when querying status
The status of a job may depend on the status of its dependenices,
as we do not repeat for instance the failed state in each dependent
job.

Return also the list of dependencies so these can be queried too.
2020-11-11 18:16:42 +01:00
Tom Gundersen
9adae8a3a7 kojiapi: support multi-build composes
This removes the restriction of only having a single build per compose
and uses the new job types to schedule the broken-appart build.

A small change in behavior is introduced: the koji build ID is not
known when the call to `compose` returns, so it is always set to
`0`. In the future we should remove this from the API, and instead
rely on the status call to return this information, when it is
known.

The status route will be updated in follow-up commits to reflect the
changes introduced here.
2020-11-11 18:16:42 +01:00
Tom Gundersen
98fd290a08 worker: make Enqueue() specific for each job type
Most of the worker API is now untyped, but keep Enqueu() typed to
ensure the job objects match the names in the queue. This means we
must add a version of Enqueue() for each job type we support.
2020-11-11 18:16:42 +01:00
Tom Gundersen
79f87ea347 worker/RequestJob: treat 'osbuild-koji' jobs like 'osbuild' ones
We must special-case the treatment of architecture, to select the
correct remote worker for any job that requires a specific
architecture. For now this means any jobs that run osbuild.
2020-11-11 18:16:42 +01:00
Tom Gundersen
0e382e9cf4 worker: implement koji job types
The three new job types osbuild-koji, koji-init, and koji-finalize
allows the different tasks to be split appart and in particular for
there to be several builds on different architectures as part of a
given compose.
2020-11-11 18:16:42 +01:00
Tom Gundersen
a2895376ae worker: introduce dynamicArgs
In addition to the arguments passed when scheduling a job, a job now
also takes the results of its dependencies as additional arguments. We
call these dynamic arguments for the lack of a better term.

The immediate use-case for this is to allow koji jobs to be split up
as follows:
 - koji-init: Creates a koji build, and returns us a token.
 - osbuild-koji: one job per architecture, depending on koji-init
   having succeeded. Builds the image, and uploads it to koji,
   returning metadata about the image produced.
 - koji-finalize: uses the token from koji-init and the metadata
   from osbuild-koji to import the build into koji if it succeeded
   or mark it as failed if it failed.
2020-11-11 18:16:42 +01:00
Tom Gundersen
11d0da0b5c jobqueue/JobStatus: return result as json.RawMessage
Similarly to the recent changes to Dequeue(), let the caller unmarshal the
return JSON. This allows us to pass the result on without being able
to unmarshal it.

In follow-up patches, we will pass results of jobs to dependent jobs,
but the worker API does not know about the different job types, nor how
to unmarshal them.
2020-11-11 18:16:42 +01:00
Tom Gundersen
e277501ca3 jobqueue: return dependencies on dequeue
Once a job has been enqueued, there is no way to query its dependencies.

This makes dequeue more symmetric to enqueue by returning the
dependencies that were passed to enqueue, allowing the caller to
query the dependencies and their results.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-11-11 18:16:42 +01:00
Tom Gundersen
e72b14bdd1 jobqueue: do not sort dependencies
While dependencies are purely internal, sorting and pruning them is a
reasonable optimization. However, we wish to expose them in follow-up
commits and then we want them to remain unchanged from the input.

Nothing in the internal logic seems to rely on the fact the dependencies
were sorted.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-11-11 18:16:42 +01:00