Commit graph

1420 commits

Author SHA1 Message Date
Tom Gundersen
4f39a33d34 osbuild-composer-koji.socket: use standard https port
Rather than using the arbitrary port 8701, use the standard 443. The
worker API will remain on a separate port, and as long as the two APIs
are exposed by the same binary that will have to remain separate at
8700.

Move the test instance of koji on localhost from 443 to 4343, to avoid a
conflict.

In a follow-up we should also give this API a prefix, so the cloud API
can share the same port with it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-17 17:34:57 +02:00
Tom Gundersen
06c582a206 tests: drop osbulid-composer-koji-test
This was not hooked up in CI, and was instead replaced by
`tests/image-tests/koji.sh`.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-17 17:34:57 +02:00
Martin Sehnoutka
d819b26e3f run_image_tests: replace CHANGE_ID with BRANCH_NAME
CHANGE_ID is set for PRs, which is why it worked during the review
process, but in the master branch it is not set. BRANCH_NAME is set for
both PRs and master branch. In case of PRs it is in form `PR-<pull
request number>`.
2020-09-16 23:08:31 +02:00
Ondřej Budai
8ccbde8591 schutzbot: run EL integration tests in PSI
We need RH internal repos which are not available in AWS.
2020-09-16 00:15:02 +01:00
Tom Gundersen
c6cf9de85d koji: add config files to configure kerberos settings
Kerberos keytabs and principals are configured per koji server both in
composer and in the worker.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
9666be2891 schutzbot: add koji integration tests
This sets up containers running koji and supporting infrastructure, and
calls the osbuild-composer-koji API to build and image and push it into
our testing instance.

koji-compose.py and various fixes by Christian Kellner.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
fdc303268f osbuild-composer/koji: require authentication
In the same way we require authentication for the worker API, require
clients of the koji API to authenticate using SSL client certificates.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
a97aac5846 worker/target/koji: mark builds correctly as failed
Otherwise we will leak builds and the NVR will not be possible to reuse.
2020-09-16 00:15:02 +01:00
Tom Gundersen
e52830f530 upload/koji: don't pass task_id to cg_init_build
Contrary to our assumption, we cannot initialize the build with the
link to the task. We can only update the link once the build has
completed.

This seems like a bug in koji, but we keep it like this for now.
2020-09-16 00:15:02 +01:00
Tom Gundersen
9a4c66db03 worker/target/koji: append RPM information
Include metadata about all RPMs in the build environment as well as in
the actual image.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
b6f06da1a7 upload/koji/uploadChunk: fix compilation errors
The API of kolo/xmlrpc changed after the commit that is shipped in
Fedora. Pin the vendored version to that and adjust the API usage.

This should make the RPM compile in both RHEL and Fedora.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
3457038688 upload/koji: support refunding reserved build ids
Add support for both cancelling and failing a build. This is tested, but
not hooked up, as we need some more architecture work before that makes
sense.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
f446613d4a upload/koji: use CGInitBuild and clarify metadata structs
Move to requiring CGInitBuild to be called before CGImport. In the
future we could make the former optional again, but for now we want to
allow the caller to have done CGInitBuild and for composer only to do
the CGImport using the passed in build_id and token.

Also rename and document some struct fields in the metadata struct to
make them more specific to our use-case and hopefully easier to read.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Ondřej Budai
e4b839b31f kojiapi: add koji target to composes
So far, composes created by kojiapi didn't have any targets. This commit
adds the koji target to them.

This is the last piece of the puzzle. From now on, osbuild-composer has
a koji API, which is actually able to upload images to Koji! Yay!
2020-09-16 00:15:02 +01:00
Ondřej Budai
e7fbf4b660 upload/koji: add support for uploading to Koji
Introduce a target for Koji and hooked it up in the worker, so if koji
target is specified, the image is uploaded to koji.

[teg: use system kerberos config rather than reading from env]
2020-09-16 00:15:02 +01:00
Ondřej Budai
91b86a1369 osbuild-composer: add a socket for Koji API
Add a systemd socket for Koji API. If enabled when osbuild-composer.service
is started, the service will also listen on the socket and serve Koji API
there.

Note that Koji API doesn't upload to Koji yet, this still needs to be hooked
up.

Based on a patch from Tom Gundersen, thanks!
2020-09-16 00:15:02 +01:00
Tom Gundersen
67e4182ba4 kojiapi: add a server/client implementation of the OpenAPI spec
This just translates between the OpenAPI spec and our internal
API.

This still lacks tests, but a follow-up commit adds integration tests.

`internal/kojiapi/openapi.gen.go` was automatically generated from
`internal/kojiapi/openapi.yml`. To regenerate use `go generate ./...`.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
7109f49692 kojiapi: add OpenAPI spec
This adds the OpenAPI spec for the new composer-koji API. This API is meant
to expose expose just the functionality needed to generate images and push
them to koji.

Each compose may consist of several images, each image may have a
different architecture and image type, and the set of repositories with
their contents may be distinct. However, a compose is restricted to one
distro and one koji transaction.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Martin Sehnoutka
509964bede image-tests: don't use random names for CI artifacts
When using random names for artifacts like AWS snapshots, or Azure
images, it becomes hard to clean them up in case of CI failure. See this
issue for more details:
https://github.com/osbuild/osbuild-composer/issues/942

This PR introduces predictable names so that we can easily determine
which artifact belongs to which PR and therefore we can decide to wipe
all resources that are not needed any more.
2020-09-15 14:30:51 +02:00
Martin Sehnoutka
e80110a12c azuretest: Refactor clean up code to separate functions
In order to run the clean up in a separate binary it is necessary to
refactor the clean up code away from the context manager.
2020-09-15 14:28:22 +02:00
Major Hayden
a3478ffff0 🦛 Bump osbuild submodule to v21
Signed-off-by: Major Hayden <major@redhat.com>
2020-09-14 14:06:45 +02:00
Lars Karlitski
85423d403c worker: clarify 404 error message
When a token doesn't exist, the URL is invalid. Nothing to do with a
job.
2020-09-11 14:23:24 +01:00
Lars Karlitski
ca35f25fcf worker/client: expose server errors
The worker API returns errors of the form:

  { "message": "..." }

Print the message of those errors when receiving an error on the client.

This adds an `Error` type to openapi.yml and marks all routes as
returning it on 4XX and 5XX.
2020-09-11 14:23:24 +01:00
Lars Karlitski
3bedd25087 worker/api: send job id to worker after all
Full circle. After switching the worker to not operate on jobs directly,
send the id anyway, so that workers can print it in their logs.
2020-09-11 14:23:24 +01:00
Lars Karlitski
b03e1254e9 worker/api: remove token in favor of callback URLs
Instead of sending a `token` to workers, send back to URLs:

 1. "location": URL at which the job can be inspected (GET) and updated
    (PATCH).
 2. "artifact_location": URL at which artifacts should be uploaded to.

The actual URLs remain the same, but a client does not need to stitch
them together manually (except appending the artifact's name).

Unfortunately, the client code generated by `deepmap` does not lend
itself to this style of APIs. Use standard http.Client again, which is a
partial revert of 0962fbd30.
2020-09-11 14:23:24 +01:00
Lars Karlitski
901d724622 osubild-worker: don't use job token as aws key
The job token will be deprecated in favor of URLs.

If a key is not set, use a new random UUID. Also, don't overwrite the
options struct with that new key.
2020-09-11 14:23:24 +01:00
Lars Karlitski
ccebfb014c worker: echo.NewHTTPError() does not take format string
Use a plain string where possible and `fmt.Errorf` for internal server
errors (echo converts all non-HTTPError errors to 500s)
2020-09-11 14:23:24 +01:00
Lars Karlitski
26b36ba704 worker/api: introduce job tokens
Don't give out job ids to workers, but `tokens`, which serve as an
indirection. This way, restarting composer won't confuse it when a stray
worker returns a result for a job that was still running. Also,
artifacts are only moved to the final location once a job finishes.

This change breaks backwards compatibility, but we're not yet promising
a stable worker API to anyone.

This drops the transition tests in server_test.go. These don't make much
sense anymore, because there's only one allowed transition, from running
to finished. They heavily relied on job slot ids, which are not easily
accessible with the `TestRoute` API. Overall, adjusting this seemed like
too much work for their benefit.
2020-09-11 14:23:24 +01:00
Lars Karlitski
783a88d8cc worker/api: give operations simpler names
The code generator uses the `operationID` field to generate server
handlers, client functions, and types. Use simpler names to make the
generated code easier to read.
2020-09-11 14:23:24 +01:00
Lars Karlitski
bf0dd66382 worker/api: drop /job-queue/v1 from api paths
This kind of common base path is better set in the top-level
`server.url` field, so that it can be adjusted.

For now, drop it completely, as we already broke the consistency when
introducing the `/status` route.

This change breaks backwards compatibility, but we're not yet promising
a stable worker API to anyone.
2020-09-11 14:23:24 +01:00
Lars Karlitski
c07674e1f4 tools/prepare-source: also call go generate ./...
To ensure that all generated code is up to date.
2020-09-08 20:40:08 +02:00
Lars Karlitski
0962fbd306 worker/client: use code generated from openapi spec 2020-09-06 18:42:23 +01:00
Lars Karlitski
b984fd33a8 worker: require full url to be passed to NewClient()
This lets us get of stitching URLs together with string concatenation in
favor of using package `url`.
2020-09-06 18:42:23 +01:00
Lars Karlitski
ad11ceecf4 worker: use openapi spec and generated code
Write an openapi spec for the worker API and use `deepmap/oapi-codegen`
to generate scaffolding for the server-side using the `labstack/echo`
server.

Incidentally, echo by default returns the errors in the same format that
worker API always has:

    { "message": "..." }

The API itself is unchanged to make this change easier to understand. It
will be changed to better suit our needs in future commits.
2020-09-06 18:42:23 +01:00
Martin Sehnoutka
396c2cedce weldr: make URL mandatory part of a new source
Sources without URL are useless. Make it mandatory.

Fixes: https://github.com/osbuild/osbuild-composer/issues/951
2020-09-04 20:20:24 +01:00
Alexander Todorov
951e5e66b6 Shutzbot: add pipeline for RHEL nightly builds. Refs #912
Notes:
ATM will not run any actual tests b/c we want to make sure the
pipeline configuration is correct.

run_tests() will call the deploy.sh script and then do nothing
b/c of the "dummy-" prefix which doesn't match any actual tests!
2020-09-04 09:56:25 -05:00
Alexander Todorov
c0d9bb13fc Shutzbot: show info for osbuild-composer sources
so we can actually see what sources are being used
2020-09-04 09:56:25 -05:00
Tom Gundersen
4afbaec8e0 schutzbot/ci_details: print the username
We are storing some data in the user's home directory, so let's print
the username so we know what that is.

In particular, this would tell us which user has been authorized to log
in via ssh.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-03 22:54:02 +01:00
Xiaofeng Wang
bb94c76818 test: Add rhel-8-beta.json to override default one
OSTree testing needs redhat-release-8.3-0.4.el8.x86_64 to
fix BZ#1848453
2020-09-03 22:51:39 +01:00
Xiaofeng Wang
c1b0d348d6 test: Add ostree image installation and upgrade test and add a
new parallel stage for ostree test
2020-09-03 22:51:39 +01:00
Martin Sehnoutka
125fce92db internal/boot: Make some function public
More specifically only those that are needed in
/cmd/osbuild-image/tests.

This patch can be merged with the previous one if we want to make sure
every commit can be built, but I'm going to keep it like this for now so
that we can easily see the changes.
2020-09-03 15:12:59 +01:00
Martin Sehnoutka
ec6ce8387d internal/boot: introduce package for booting images
The package takes the existing code from /cmd/osbuild-image-tests and
makes it available for other executables.
2020-09-03 15:12:59 +01:00
Tom Gundersen
7e0711b805 test/generation/rhel8: move to today's nightly
We need this for greenboot-status, in the RHEL for Edge images. This
updates the generator for x86_64 and aarch64 and updates the test cases
for rhel-edge-commit.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-03 11:02:44 +01:00
Peter Robinson
d609371a5a distro/rhel8: Updates for RHEL for Edge
We now have greenboot available so update the packages and services
also add exclude sections as subscription-manager is for some reason
getting pulled in which brings dnf and other deps we explicitly don't
want.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
[teg: minor fixes and squash several fixup commits]
2020-09-03 11:02:44 +01:00
Alexander Todorov
25c3deda83 tests: Use -pool when importing vmdk & booting a VM. Fixes #953
explicitly specify the cluster and the default resource pool
when importing b/c the import process creates a temporary VM,
which requires a ResourcePool to provision. Same thing when
provisioning a VM.
2020-09-01 11:55:45 +01:00
Major Hayden
d5ddcbc921 ⛈ Use AWS more often for testing
Now that we've reduced how much of our PSI quota we are using so the
OpenStack boot tests will work, we need to use AWS for jobs more often.
This should allow test runs to complete a little sooner by freeing up
PSI resources for the jobs that are only able to run there.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-28 13:31:52 +02:00
Ondřej Budai
05fd221bd4 upload/koji: add support for GSSAPI/Kerberos auth
Prior this commit we only had support for username/password authentication
in the koji integration. This wasn't particularly useful because this
auth type isn't used in any production instance.

This commit adds the support for GSSAPI/Kerberos authentication.
The implementation uses kerby library which is very lightweight wrapper
around C gssapi library.

Also, the koji unit test and the run-koji-container script were modified
so the GSSAPI auth is fully tested.
2020-08-27 17:29:57 +01:00
Ondřej Budai
ecc7340570 upload/koji: allow passing a custom transport to koji.Login
In the near future, we will need to communicate with Koji using HTTPS.
This will surely bring the need for ignoring bad certificates/providing
our own self-signed ones. Thus, this commit prepares the Koji integration
by adding a way to accept a custom http transport which can be used to
customize the TLS settings.
2020-08-27 17:29:57 +01:00
Ondřej Budai
bc02da786d upload/koji: ensure that Koji type instance is always logged-in
Previously, Koji instance could be both logged-in and not logged-in.
This change disallows it: Now, the Koji instance is created by calling
koji.Login, so it must be always logged-in. This change should lead to more
robust code.
2020-08-27 17:29:57 +01:00
Ondřej Budai
f77f570202 upload/koji: extract RoundTripper from Koji type
The RoundTripper bits are not dependant on the Koji type, this commit extracts
them, so the responsibilities are clearly separated.
2020-08-27 17:29:57 +01:00