Commit graph

1441 commits

Author SHA1 Message Date
Ondřej Budai
fbaaf31a34 makefile: clean up certificate targets
1) generating a private key and signing request was merged into one command
2) -sha256 was dropped, let openssl decide which digest should be used
3) signing request is deleted after the it's signed
2020-09-23 11:08:21 +01:00
Ondřej Budai
c6b5dd8977 kojiapi: add /status route
It works the same way as in the worker API. It's very handy when we just want
to test whether the API is up and running.
2020-09-23 11:08:21 +01:00
Ondřej Budai
28aff2259a schutzbot: start also the remote socket
The following commits will add testing of authentication on this socket.

This commit also sets up the config for composer other it won't start
with remote socket enabled.
2020-09-23 11:08:21 +01:00
Ondřej Budai
e296a3dea7 schutzbot: greenprintify deploy.sh
It's a word, trust me.
2020-09-23 11:08:21 +01:00
Ondřej Budai
7fc3b47348 kojiapi: add domain allowlist
This commit adds a domain allowlist which works the same way as the one
for remote workers.

To accept just w1.osbuild.org and w2.osbuild.org, use:

[koji]
domain_allowlist = [ "w1.osbuild.org", "w2.osbuild.org" ]
2020-09-23 11:08:21 +01:00
Ondřej Budai
c9abb66637 osbuild-composer/config: rework the structure
Prior this change, the structure was following:

[koji.localhost.kerberos]

This change modifies it to:

[koji.servers.localhost.kerberos]

This allows us to put more config options under the koji section. See
following commits, they use this new possibility.
2020-09-23 11:08:21 +01:00
Ondřej Budai
9a26d077db worker/api: add domain allowlist
There's need for control which certificates to accept. This commit introduces
the domain allowlist. The basic idea is that composer accepts only
certificates issued to domain names specified in osbuild-composer config file.
It allows multiple domains to be specified.

To accept just w1.osbuild.org and w2.osbuild.org, use:
domain_allowlist = [ "w1.osbuild.org", "w2.osbuild.org" ]
2020-09-23 11:08:21 +01:00
Ondřej Budai
03768e5f18 api/worker, koji: fix race condition when using multiple listeners
When remote worker socket was enabled, this was happening:

e := echo.New()

go func() {
    e.Listener = listener1
    e.Start("")
}()

e.Listener = listener2
e.Start("")

Yeah, this is a race condition. None of the echo's Start methods cannot safely
handle multiple listeners.

This commit fixes this issue by using Echo only as a router for standard
http.Server which handles multiple listeners in a non-racy way.
2020-09-23 09:38:29 +02:00
Alexander Todorov
2370de7a4b tests: print SSH error for more info. Refs #987 2020-09-22 16:03:30 +02:00
Alexander Todorov
456bf242c4 tests: Add option to fail qemu boot. Fix #888
as @teg suggests in
https://github.com/osbuild/osbuild-composer/issues/888#issuecomment-662942314
this is ON by default so we can be alerted for missing cloud
credentials in CI!

If you want to disable it then -fail-local-boot=off

Note: special case the qemu image types which always need to be
booted locally.
2020-09-22 16:02:43 +02:00
Lars Karlitski
18e5b2e448 go.mod: update 2020-09-22 14:13:06 +02:00
sanne raymaekers
d5938d52b2 cloudapi: Add rhsm parameter to repository 2020-09-22 11:38:28 +02:00
sanne raymaekers
9404b0640a test: Regenerate the rhel-8 cases to add subscriptions 2020-09-22 11:38:28 +02:00
sanne raymaekers
9ca50ae3ac osbuild-composer-cloud: introduce the cloud-specific service 2020-09-22 11:38:28 +02:00
sanne raymaekers
96c1de9f98 osbuild: add support for the first-boot stage 2020-09-22 11:38:28 +02:00
Tom Gundersen
6bab73f378 kojiapi: move from chi to echo
Follow the worker API so we standardise on one library. This simplifies
the code quite a bit.

No functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-21 11:18:45 +01:00
Tom Gundersen
504a5890d9 kojiapi: move api definition
Move the API definition into a sub-directory to follow the style
of the worker API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-21 11:18:45 +01:00
Martin Sehnoutka
369d5d3e4d GH workflow: introduce shellcheck job
This job uses shellcheck to analyze all our bash scripts except for
those in /vendor directory.

It also allows sourcing /etc/os-release without checking it, because
it doesn't make any sense to check that the CI machine has correct
/etc/os-release file. Also allow useless cats because I don't think they
cause any harm.
2020-09-19 15:10:39 +02:00
Martin Sehnoutka
d9f254f9d1 *.sh: apply fixes suggested by shellcheck
also:
tweak some automatic fixes to be more readable
fix automatically generated bash fixes for SSH options
2020-09-19 15:10:39 +02:00
Martin Sehnoutka
b06e6dd916 *.sh: apply automatically all suggestions from shellcheck
This commit was automatically generated using:
```
$ fd --exclude vendor sh | xargs shellcheck -f diff | git apply
```
2020-09-19 15:10:39 +02:00
Major Hayden
4c476f32c2 📜 mockbuild: Reduce log output
Running mock with verbose enabled made sense a while back when we were
still unsure if things would work, but it's generating a ton of logs now
that eventually clogs Jenkins' disk.

Disable the verbose flag to reduce mock's log output.

Signed-off-by: Major Hayden <major@redhat.com>
2020-09-18 07:30:03 -05:00
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