Commit graph

912 commits

Author SHA1 Message Date
Tomas Hozza
080b64c12c cloudapi: Don't return upload type in UploadStatus for now
Upload target type is currently not returned form the worker, but
hardcoded in the cloudapi code to always return "aws". This make testing
of the cloudapi for other cloud providers quite complicated.

Since extending the target status information returned from the
worker is currently in progress, work around the situation for now
by returning an empty string as the upload type.

This will allows other types of upload targets to be tested as part of
cloudapi test case.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-25 18:44:21 +00:00
Tomas Hozza
94d399f010 cloudapi: Add support for GCP as upload target
Add support for GCP as an upload target to the internal API.

Extend the cloudapi to allow GCP as an upload target in the compose
request. Regenerate the cloudapi go code. Added GCP-specific upload
result component in the API definition, similar to AWS. It is not yet
used, but it will be once returning a target-specific result from
worker is supported.

Add support for GCP upload target to the worker job implementation.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-25 18:44:21 +00:00
Tomas Hozza
ff95059748 internal/upload: Add support for upload to GCP and CLI tool using it
Add new internal upload target for Google Cloud Platform and
osbuild-upload-gcp CLI tool which uses the API.

Supported features are:
- Authenticate with GCP using explicitly provided JSON credentials
  file or let the authentication be handled automatically by the
  Google cloud client library. The later is useful e.g. when the worker
  is running in GCP VM instance, which has associated permissions with
  it.
- Upload an existing image file into existing Storage bucket.
- Verify MD5 checksum of the uploaded image file against the local
  file's checksum.
- Import the uploaded image file into Compute Node as an Image.
- Delete the uploaded image file after a successful image import.
- Delete all cache files from storage created as part of the image
  import build job.
- Share the imported image with a list of specified accounts.

GCP-specific image type is not yet added, since GCP supports importing
VMDK and VHD images, which the osbuild-composer already supports.

Update go.mod, vendor/ content and SPEC file with new dependencies.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-25 18:44:21 +00:00
Ondřej Budai
449242ebda test/openstack: increase timeout for the instance to become ACTIVE
The openstack boot test often ruins our days with:

Waiting for instance 63ac19be-2e19-44e2-8bef-9770d68a190c to become Active
failed: A timeout occurred

I decided to investigate. It turns out the first boot of an image can take
up to 18 minutes. The subsequent ones are usually much faster (but don't rely
on this fact, I saw 15 minutes there).

This commit bumps the timeout to 30 minutes. This should be plenty of time
for the instance to spin up and get into the ACTIVE state.

Honestly, I'm not very happy with the solution but it should help with the
failing Schutzbot. As a follow up, I will reach to the PSI OpenStack team
and ask them if we could somehow speed up the process (maybe by using another
flavor, ci.m1.medium.ephemeral just might be slow for some reason, I don't
know).

Anyway, this should help us in the short term because I strongly believe that
a slow test is still better than a failing one.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-25 17:27:01 +00:00
Tom Gundersen
0efc345b2d rhel84/grub2: set saved_entry
Explicitly set the kernel to boot into.

Also change the blueprint/kernenl handling:

Rather than only falling back to the default kernel name for
getting the package list, let GetKernel() always return the
correct result so we can rely on this being consistent.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-02-20 20:01:15 +01:00
Tom Gundersen
687ac7f615 weldr/compose/ostree: introduce URL parameter
For now this is simply used to resolve the parent commit, in case
one is not provided. In the future it will be used by new image
types to actually pull content from.

This extends the weldr API, so that future work does not have to
modify that.

The logic we now implement for the ostree commit image types is:
If the URL is provided, but the parent commit is not. The parent
commit is taken to be the current HEAD of the ostree repo at the
given url, with the given (or default) ref.

This only provides a small optional convenience, but we will
soon introduce image types where the URL of the repository is
required.

This commit still needs testing.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-02-20 14:53:49 +01:00
Tom Gundersen
6cb47862df distro: expose default OSTreeRef()
Rather than setting this automagically, expose it to the caller. For
now the only caller we have simply passes it back in, so this is a
noop.

In follow-up commits this will be used to resolve the parent commit.

This is tested by verifying that the generated manifests do not
change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-02-20 14:53:49 +01:00
Antonio Murdaca
21319520e5 internal/distro/rhel8: un-exclude subman from edge
We aim at shrinking our deps eventually but we need subman for the time
being. This patch basically un-exclude subman which was introduced by
https://github.com/osbuild/osbuild-composer/pull/893

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2021-02-18 13:08:32 +01:00
Jozef Mikovic
0597ac48a7 upload/vmware: document uploadImage function 2021-02-16 19:06:01 +00:00
Jozef Mikovic
08cfc08805 weldr: add vmware upload target to api
Extend Weldr API to allow user to specify option to upload built image to VMWare,
makes use of previously define upload target.
2021-02-16 19:06:01 +00:00
Jozef Mikovic
1a81489ef1 osbuild-worker: add target for upload to vmware
New upload target for VMWare, similar to the ones for AWS and Azure,
allowing users to set credentials for their vSphere instance.
Commit also includes function that performs the actual upload.
2021-02-16 19:06:01 +00:00
Achilleas Koutsou
1ef1bab5a8 distro/*: test kernels in image types
Test that all defined image types return at least one kernel when given
an empty blueprint and exactly one kernel for ostree-commit types.
2021-02-16 13:51:26 +00:00
Achilleas Koutsou
8d9753a4c2 distro/*: remove kernel from image types
The kernel now comes from the blueprint packages even when it's not
specified.  Removing from the base packages of the image types avoids
duplication and allows for alternative kernels to be specified without
also including the default.

The latter is necessary for RHEL for Edge and Fedora IoT images (ostree
commits) that fail to build when multiple kernels are installed.

ImageType tests modified to fix expected package order.
2021-02-16 13:51:26 +00:00
Achilleas Koutsou
d0923af70d blueprint: test kernel customization
Edit GetPackages test to expect automatic kernel inclusion.

New test for all combinations of adding a kernel to customizations and
package list.
2021-02-16 13:51:26 +00:00
Achilleas Koutsou
b861042032 blueprint: add kernel name customization
Blueprints can now be used to specify a kernel as part of the kernel
customizations.  Specifying a kernel adds it to the package list.

If no known kernel is specified (neither in the customizations nor the
package list), the default "kernel" is included automatically.

If kernels are specified in both the package list and the
customizations, both are added (even if they're duplicates).
2021-02-16 13:51:26 +00:00
Ondřej Budai
bf4280d1e2 distro/rhel84: disable s390x and rhel-commit-edge for Centos
s390x isn't supported on Centos.

rhel-commit-edge sounds just wrong for Centos. We can revert this change any
time. The thing is that I wasn't able to find something like CentOS IoT and
we don't want to be in a position of defining a new distribution spin.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-14 16:08:08 +00:00
Ondřej Budai
4492448f49 test/distro/rhel84: invert condition
I'm sorry, I need to extend this condition and my brain isn't powerful enough
to reason about complex negative conditions.

Not a functional change.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-14 16:08:08 +00:00
Ondřej Budai
5eb402415d distro/rhel84: add centos 8 stream support
The image definition is shared with the latest RHEL 8.y one (8.4 currently).
I expect that we the introduction of 8.5 support, we point the centos 8
distro at it.

The test repositories and manifests use the official CentOS composes. From
what I can tell, they are persistent. This is not guaranteed though, so we
might need to switch to RPMRepo at some point.

The "classic" CentOS 8 should also be buildable but due to the chicken and egg
issue (this commit will get into Centos "8.4" but Centos "8.4" isn't a thing
yet), we cannot test it and therefore it might be broken.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-14 16:08:08 +00:00
Ondřej Budai
6feba70758 test/distro/rhel84: add missing image types to TestImageType_Name
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-14 16:08:08 +00:00
Ondřej Budai
4d7b36f08b test/distro/rhel84: add test for Arch.ListImageTypes
We didn't have one so I added it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-14 16:08:08 +00:00
Brian C. Lane
728f2d0f81 weldr: Remove underscores from FreezeHandler error
Error message strings are not guaranteed to be stable, but should
be consistent when used in more than one place.
2021-02-13 08:52:52 +01:00
Achilleas Koutsou
d8c292ca79 distro/*: test expected failure for ostree
Test for each distro that runs through all architecture - image type
combinations and calls the Manifest() method with a kernel boot option
customization and checks if the ostree image types produce the expected
error.
2021-02-12 14:25:48 +01:00
Achilleas Koutsou
fd1cc343a5 distro/*: fail on kernel boot params with ostree
Kernel boot parameters have no effect on ostree type images (Fedora IoT
and RHEL for Edge).  Catch this and fail early in the pipeline creation
and communicate the issue to the user.
2021-02-12 14:25:48 +01:00
Martin Sehnoutka
f98e231f64 cloudapi: extend the API spec with /version and /openapi.json
These endpoints are useful for clients while exploring the API. They are
also required for deploying the service into clouddot.
2021-02-12 14:25:19 +01:00
Jacob Kozol
2cae456094 distro/rhel84: remove dbxtool
dbxtool is not available on s390x or ppc64le. So, it cannot be included
for now without breaking image builds for these architectures.
2021-02-11 14:12:35 +01:00
Tom Gundersen
e513905424 cloudapi: add support for additional packages
Optionally allow a pacakge set to be included in the compose request.

The specified packages are added to the base packages before
depsolving. As the base packages differ between the image types
the package customizations may have different results on the different
images part of the compose request.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-02-11 14:12:11 +01:00
Tomas Hozza
af3c572f9a distro: Disable RHSM DNF plugins on RHEL qcow2 images
Modify RHEL 8.3 and 8.4 KVM guest images definition to produce osbuild
manifest with `org.osbuild.rhsm` stage to disable both RHSM DNF plugins
(`product-id` and `subscription-manager`).

Update `/docs/news/unreleased/osbuild-rhsm-stage.md` to note that RHEL
8.3 and 8.4 qcow2 image definitions are updated to disable RHSM DNF
plugins by default.

Enhance `tools/image-info` tool to add RHSM-specific section to its
output in case RHSM DNF plugins configurations exist in the tree.

Regenerate all RHEL image test cases affected by the patch set.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-11 11:10:47 +01:00
Tomas Hozza
1d48c92953 Add support for org.osbuild.rhsm stage
Add support to configure `org.osbuild.rhsm` osbuild stage. This stage
allows the configuration of Red Hat Subscription Manager (RHSM) related
components. Currently it is possible to configure only the enablement
status of RHSM DNF plugins.

Add `/docs/news/unreleased/osbuild-rhsm-stage.md` with information about
the added support for `org.osbuild.rhsm` osbuild stage.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2021-02-11 11:10:47 +01:00
Jacob Kozol
eea18fc897 distro/rhel84: add sysconfig stage
The org.osbuild.sysconfig stage is now supported. Config updates can be
made to the kernel and network files. Currently, the same values are
used for all image types in rhel84. The image-info script is updated to
allow testing the sysconfig info.
2021-02-09 14:13:25 +01:00
Chloe Kaubisch
899d78f7e1
cloudapi: expose upload status
Expose a more detailed job status result - specifically, include upload status
alongside image status. Expand openapi.yml accordingly and add an UploadStatus
field to the OSBuildJobResult struct. At the moment, only represent the
"success" and "failure" states of UploadStatus - to differentiate between
"pending" and "running" would involve significant design decisions and should be
addressed in a separate commit.
2021-02-05 12:34:28 +01:00
Brian C. Lane
80f833a69b weldr: Fix confusing TOML support for source API
There is some confusion surrounding the format of the source TOML that
can be sent to the server. The format it accepts doesn't match the
output from composer-cli which includes the source id in [] eg.

[k8s]
name = "kubernetes packages"
...

This patch changes the parsing to allow the id to be set as 'id = "k8s"'
or passed as a map in [k8s]. If the id is passed in the body it takes
precedence over the map name.
2021-02-04 15:50:04 -08:00
Brian C. Lane
6bfa7a3e0e weldr: Add tests for V1 source API and better id support 2021-02-04 15:50:04 -08:00
Brian C. Lane
440753a274 weldr: undo unknown commit should return UnknownCommit 2021-02-03 12:23:58 +01:00
Brian C. Lane
98b2dab128 weldr: Add tests for blueprints/undo
Test undo, and undo of an unknown commit.
2021-02-03 12:23:58 +01:00
Ondřej Budai
2241a8d9ed go: vendor the oapi-codegen cmd
See the comment in tools.go, I cannot fully explain what's happening here.
Somehow, Go 1.14 wants to use the vendored version of oapi-codegen but
without this file, oapi-codegen isn't vendored so the generation fails.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2021-02-01 15:32:58 +01:00
Jacob Kozol
ee5d73eb41 distro/rhel84: remove rng-tools from qcow2
rng-tools was added back into the qcow2 packages by mistake. It should
be an excluded package and rngd.service should not be enabled.
2021-02-01 11:20:35 +01:00
Brian C. Lane
d62e813e75 weldr: Return error if source name matches system repo
System repos cannot be overridden by users, return an error if they try
to push a source with the same name/id as a system source.

Resolves: rhbz#1915359
2021-01-29 08:25:23 -08:00
Brian C. Lane
3e510ffc99 test: Add tests for trying to override a system source repo
This add tests to client and weldr to make sure that overriding an
existing system source repo returns an error.

Related: rhbz#1915359
2021-01-29 08:25:23 -08:00
Jacob Kozol
59adc4d11a distro/rhel84: remove packages not in imagefactory image
The last imagefactory nightly did not contain dnf-plugin-spacewalk,
fwupd, nss, or udisks2. These packages are now excluded. The
udisks2.service and mdmonitor.service are no longer enabled. Also, the
fwupd-refresh, mdcheck_continue, mdcheck_start, and mdmonitor-oneshot
timers are no longer listed as disabled services.
2021-01-29 11:22:26 +00:00
Jacob Kozol
a3cb930d6a distro/rhel84: add packages to be match imagefactory
The packages in the last imagefactory nightly differ from ours. The
following packages are now added:

oddjob
oddjob-mkhomedir
psmisc
authselect-compat
rng-tools
dbxtool

Also, the rngd and nfs-convert services are enabled.
2021-01-28 11:31:42 +01:00
Jacob Kozol
e7be1baf25 distro/rhel84: sort package lists alphabetically 2021-01-28 11:31:42 +01:00
Jacob Kozol
be2478e4a5 distro/rhel84: include timedatex in qcow2 image
timedatex was an exlcuded package due to an selinux-policy issue. This
issue is resolved and timedatex is no longer excluded.
2021-01-27 11:38:14 +01:00
Major Hayden
2618e11bfe Apply tags to registered AMI
Adding the tag called `Name` to the AMI ensures that the name appears in
the *Name* column inside AWS' web console.

Fixes #1171.

Signed-off-by: Major Hayden <major@redhat.com>
2021-01-25 15:47:02 +01:00
Jacob Kozol
15969e0adc distro/{rhel8,rhel84}: set systemd default targets
An image only had a systemd stage added if its blueprint contained
services or if its image type contained enabled services. The systemd
stage is now also added if the image type contains disabled services or
a default target.

The RHEL 8.4 qcow2 image type now specifies the multi-user default target.

In order to test this the image-info tool now includes the default
target in its output. Image test manifests are updated to include this
change.
2021-01-21 11:58:06 +01:00
Achilleas Koutsou
487299f09c kojiapi: Job not found should return 404
Not Found (404) is a more appropriate code for requesting a valid
(correctly formatted) UUID that doesn't exist in the job queue.
2021-01-19 10:37:51 +01:00
Achilleas Koutsou
9d3d4dcdea kojiapi/test: Make calls with init, build job IDs
Send requests to the compose/{id}, compose/{id}/logs, and
compose/{id}/manifests using job IDs for non-finalize type jobs to test
the type verification.
2021-01-19 10:37:51 +01:00
Achilleas Koutsou
e59e07a09a kojiapi: Check job type (job status and logs)
The type verification introduced in the previous commit is now also used
when retrieving the job status (GET /compose/{id}) and the logs (GET
/compose/{id}/logs).

In these cases, job retrieval needs to be performed twice:
1. First the job parameters are retrieved (Job()) to check the type.
2. Then the job result is retrieved (JobStatus()) for the status or
   logs.

This makes it unlikely (essentially impossible) that the retrieval will
fail with "not found" on the second retrieval (JobStatus()), but it's
still a good sanity check for the system.

Verifies the Koji job types when retrieving Init and Build jobs as well.
2021-01-19 10:37:51 +01:00
Achilleas Koutsou
a2c4622930 kojiapi: Check job type when retrieving from queue
When a job's arguments are retrieved (for the /manifests API endpoint),
the incoming ID should correspond to a Finalize Job.  The new
worker.Job() method helps us verify the type and produce an error if the
wrong type is found.
Similarly, the dependencies of a Finalize Job should be in order (Init
Job first followed by Build Jobs).  The types are validated while
iterating the dependency list.

Added convenience functions that check the retrieved job type and return
the initialised struct or an error if the ID is not found or does not
match the type.

Currently the getInitJob() function isn't used but it will be useful
later.
2021-01-19 10:37:51 +01:00
Achilleas Koutsou
668fb003ef jobqueue: Replace JobArgs() with Job()
JobArgs() function replaced with more general Job() function that
returns all the parameters used to originally define a job during
Enqueue(). This new function enables access to the type of a job in the
queue, which wasn't available until now (except when Dequeueing).
2021-01-19 10:37:51 +01:00
Achilleas Koutsou
75a96bd99d test: Job args/manifests retrieval
1. Test retrieving the job arguments from the worker using an
   OSBuildJob.
   Very basic test with an empty manifest.
2. Test retrieving job manifests through the Koji API. Uses the existing
   TestCompose test. The returned manifests are empty for all cases.
2021-01-16 13:39:30 +01:00