Commit graph

1479 commits

Author SHA1 Message Date
Lars Karlitski
857570980d tools: add deploy-qemu and gen-user-data
tools/gen-user-data generates a cloud-init user-data file from a
configuration directory. It is mostly useful to embed files in the
user-data.

tools/deploy-qemu uses above tool to make a user-data file and spins up
a virtual machine with it. This is useful to locally run, test, and
debug osbuild-composer.

A simple user-data directory for running tests locally is included in
tests/deploy-user-data. It expects a repository with osbuild-composer
rpms to be served on the host's port 8000.
2020-10-07 11:51:33 +02:00
Tom Gundersen
122ab25476 test: depend on rpms rather than installing them explicitly
The -test subpackage should depend on all that it needs, and we should
never need to install anything explicitly from the test scripts.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-07 11:49:05 +02:00
Lars Karlitski
9246727096 image-tests: use RHEL8.3 nightly instead of snapshot
Snapshots are currently broken. Revert to the same nightly that are used
in schutzbot's repositories.

Regenerate the test case as well.
2020-10-06 13:08:26 +02:00
Tom Gundersen
9e56ac9a8b schutzbot: split provision out from deploy
Deployment is specific to CI, but the provision script is needed to be
run to execute tests locally too.

This should be called from each test, rather than from deploy. For now
this change is a noop.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
107030cc02 test/cmd/koji: pull in podman-plugins explicitly
This was made a weak dep, so we need to be explicit about it:

```
Author:     Jonathan Lebon <jonathan@jlebon.com>
Commit:     Lokesh Mandvekar <lsm5@fedoraproject.org>

    spec: make podman-plugins a weak dep

    That way someone who wants just podman doesn't also get dnsmasq. This is
    a point of contention in FCOS currently:

    https://github.com/coreos/fedora-coreos-tracker/issues/519
    (cherry picked from commit 217f4344ec796dd1134a5ba54a8ce2fb5a32a5b6)
    Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
```

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
dae0f86b35 schutzbot/repositories: use RHEL8.3 nightly rather than snapshot
Our snapshots are currently broken, so until they are fixed revert back
to using an internal RHEL nightly. We choose a slightly older one,
in the hope that it is not going to be deleted anytime soon.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
555934e303 koji: move run-koji-containers.sh to tools
Also install it is part of he tests subpackage. This a helper-tool, not
golang code, so should not live in `internal`. We need access to this
from the integration tests, so install it onto the tests system.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
32f66bb539 test/vendor/dnsname: ship the pre-built fedora version
This is obviously not a good long-term solution, but at least the fedora
version of the binary has a build-id so RPM will not complain.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
805ae59151 tests: ship all tests in the -tests sub-package
No tests should be run directly from git, but should rather be installed
onto the test system using rpm and run from there. This moves towards
unifying our two types of test cases.

The new structure of is now:

`test/cmd`:   the executors, one for each test-case. This is installed
              into `/usr/libexec/test/osbuild-composer`.
`test/data`:  data and config used by the tests. This is installed into
              `/usr/share/tests/osbuild-composer`.
`schutzbot`:  configuration of the actual test run. In particular, this
              is where the distros and repositories to test against are
              configured.

This is very much still work-in-progress, and is only the first step
towards simplifying schutzbot. Apart from moving files around, this
should be a noop.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
21e6ae5ef4 test/integration: move playbook into ansible
This is not an integration test, but an ansible playbook used by one of the
integration tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
b86b18c4fb test/integration: move azure configuration into azure
This is not an integration test, but configuration.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
e835c34678 test/integration: move composer configuration into composer
This is not an integration test, but configuration.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
1425db9789 test/integration: move krb5.conf into kerberos
This is not an integration test, but configuration.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
001c7f682a test/integration: move koji-compose.py into tools
This is not an integration test in itself, but a helper tool.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
272332e5e8 test: rename image-tests to integration
We already have something called image-tests, so this naming was
confusing. This is a collection of generic integration tests, so name
them accordingly.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Tom Gundersen
c7d993d537 scutzbot: deploy pre-generated SSL certs for testing 2020-10-06 13:08:26 +02:00
Tom Gundersen
9d18c3bfa2 tests: rename composer-cli tests
These had the generic name osbulid-tests, rename the binary to more
closely describe what is under test: weldr API as composed by
composer-cli.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Jacob Kozol
678de9d1ef distro: add fedora 33 support
Fedora 33 images can now be built and test cases are added for the new
images. The fedora 33 qcow2 and vmdk images are based off of the
official images and their kickstarters found here:
https://pagure.io/fedora-kickstarts. The fedora 33 iot image is based
off of the the config found here: https://pagure.io/fedora-iot/ostree.
The openstack, azure, and amazon image types have changes made to them
based off of the changes made to the qcow2. The changes between fedora
32 and fedora 33 are as follows:

Grub now loads its kernel command line options from
etc/kernel/cmdline, /usr/lib/kernel/cmdline, and /proc/cmdline instead
of from grub env. This is addressed by adding kernelCmdlineStageOptions
to use osbuild's kernel-cmdline stage to set these options. Alongside
`ro biosdevname=0 net.ifnames=0`, we also set `no_timer_check
console=tty1 console=ttyS0,115200n8` per what is set in the official
qcow2. For azure and amazon, the kernelOptions are still set as they
were in fedora 32.

The timezone is now set to UTC if a user does not set a timezone in the
blueprint customizations. Also, the hostname is set to
localhost.localdomain if the hostname isn't set in the blueprint.

Finally, the following packages have been removed:

polkit
geolite2-city
geolite2-country
zram-generator-defaults
2020-10-01 10:11:03 +02:00
Alexander Todorov
2adf8e660f tests: Use aws-credentials-osbuild-image-test in CI 2020-09-30 21:58:14 +02:00
Alexander Todorov
b48bff75bf tests: Fail if there were no tests executed. Fix #1002 2020-09-30 21:58:14 +02:00
Ondřej Budai
e9b8b7e01f tests/image: fix sudo invocation
We need sudo arguments as a separate ones.
2020-09-30 21:58:14 +02:00
Ondřej Budai
ad969cdda7 tests/image: fix the selector
Using wildcard in quotes doesn't trigger shell expansion, therefore this
commit moves the wildcard out of the quotes
2020-09-30 21:58:14 +02:00
Lars Karlitski
7aca756156 osbuild-composer: split out the actual service
Split the actual service into its own type `Composer` in composer.go.
main.go now (more or less) contains only collecting configuration from
the environment and the file system, as well as activation file
descriptors.

Aside from making the code easier to grok, this is a first step towards
running composer in a different environment than the one set up by
systemd.
2020-09-29 21:52:58 +01:00
Lars Karlitski
13d5129b56 osbuild-composer: use less pointers in config
The default values of fields in both ComposerConfig.Koji and
ComposerConfig.Worker are well-suited for how they're used.

The nil-checks in main.go only checked that the sections exist. This is
quite a weak check for validity, because the sections could be empty. If
anything is required for composer to function, we could add proper
validation in the future.

Do the same for the CA fields, which contain file names. Go has lots of
precedent for using empty strings to denote "no value" in the standard
library. Use it for CA files, too, instead of pointers.
2020-09-29 21:52:58 +01:00
Lars Karlitski
db9bf1c659 osbuild-composer: move config parsing into separate file
The configuration file is API. Let's give it a bit more prominence to
help people treat it as such, and a chance to test it. A basic test is
included in this commit.

Also, this cuts down on the noise in main.go a bit.
2020-09-29 21:52:58 +01:00
Lars Karlitski
af9471e4a2 osbuild-composer: socket always has two listeners
A third listener used to exist for the RCM API, but was removed a while
ago.
2020-09-29 21:52:58 +01:00
Lars Karlitski
6dce21cdc8 osbuild-composer: enforce one listener for worker API
There's no use case for many of those.
2020-09-29 21:52:58 +01:00
Alexander Todorov
fd311fedfd tests: Start osbuild-composer-koji.socket only if installed 2020-09-29 09:00:44 +02:00
Tom Gundersen
eb01680c2e NEWS: clarify the osbuild-composer-cloud entry
We expect to merge this into the main osbuild-composer package in the
future and change the port it is exposed on, so for now communicate that
this is not stable API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-25 00:47:41 +01:00
Ondřej Budai
782895e4be 21
Release osbuild-composer version 21.
2020-09-25 00:47:41 +01:00
Lars Karlitski
40d8440660 kojiapi: prefix all routes with /api/composer-koji/v1
The cloud API will be moved to `/api/composer/v1` in the future.

Mention this in the `servers` section of the openapi.yml (relative URLs
are allowed) too, even though our generator does not consider it.
2020-09-24 21:08:56 +01:00
Lars Karlitski
a8ba969f6e worker: prefix all routes with /api/worker/v1
Mention this in the `servers` section of the openapi.yml (relative URLs
are allowed) too, even though our generator does not consider it.
2020-09-24 21:08:56 +01:00
Lars Karlitski
9008a1defc worker: require workers to pass their architecture
Jobs are scheduled with type "osbuild:{arch}", to ensure that workers
only get jobs with the right architecture assigned.
2020-09-23 14:28:52 +01:00
Lars Karlitski
44c2144994 worker: Server.RequestJob → RequestOSBuildJob
This clarifies what it does, at least until its use is expanded to other
job types.
2020-09-23 14:28:52 +01:00
Lars Karlitski
ba6a480e32 worker: require workers to declare job types they accept
For now, workers must send `[ "osbuild" ]`.
2020-09-23 14:28:52 +01:00
Lars Karlitski
d3c99b8e93 worker: allow passing different jobs to workers
Until now, all jobs were put as "osbuild" jobs into the job queue and
the worker API hard-coded sending an osbuild manifest and upload
targets.

Change the API to take a "type" and "args" keys, which are equivalent to
the job-queue's type and args. Workers continue to support only osbuild
jobs, but this makes other jobs possible in the future.
2020-09-23 14:28:52 +01:00
Ondřej Budai
5b57814664 api/worker, koji: change CA logic for client certificates
Prior this commit, /etc/osbuild-composer/ca-crt.pem certificate was
used as an authority to validate client certificates.

After this commit, the host's trusted certificates are used to do
the validation. Ability to override this behaviour is also introduced:

In osbuild-composer config file, under koji and worker sections, a new CA
option is now available. If set, osbuild-composer uses it as a path
to certificate used to validate client certificates instead of the
default ones.

With this feature, it's possible to restore the validation behaviour
used before this change. Just put following lines in
/etc/osbuild-composer/osbuild-composer.toml:

[koji]
ca = "/etc/osbuild-composer/ca-crt.pem"

[worker]
ca = "/etc/osbuild-composer/ca-crt.pem"
2020-09-23 11:08:21 +01:00
Ondřej Budai
68be242850 tests: introduce auth tests
This commit introduces a new test binary responsible for testing TLS
authentication.

Currently, it covers both remote worker API and Koji API. It tests that
the server refuses certificates issued by an untrusted CA or self-signed ones.
Also, it tests that the certificate is issued for an allowed domain.

TODO: certs with subject alternative name are currently not used in tests.
They should work just right, but a proper testing requires more tinkering with
OpenSSL than I'm willing to accept at this time
2020-09-23 11:08:21 +01:00
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