Commit graph

45 commits

Author SHA1 Message Date
sanne
6fac4dcb70 distribution: Add cache dir to composer clouddot deployment 2021-06-23 10:33:22 +02:00
sanne
95cd5b782e distribution: The composer-api listens on 9196
The openshift service is listening on 443, but composer is running on
9196.
2021-06-21 17:31:15 +02:00
Achilleas Koutsou
d701d237d0 Fix cache path creation in worker Dockerfile 2021-06-18 14:02:09 +01:00
sanne
2a42d05a10 distribution: Add PVC to clouddot template
This will make the job queue persistent over redeployments.
2021-06-04 20:21:16 +02:00
sanne
65b7ce10ba distribution: Add second service to composer clouddot deployment 2021-05-18 12:07:30 +02:00
sanne
0518933676 distribution: Add state directory
This should become a PersistentVolumeClaim in future, but let's get the
deployment running first.
2021-05-17 21:43:55 +02:00
sanne
a825b87c35 distribution: Add OCP template for clouddot 2021-04-28 14:07:23 +02:00
Achilleas Koutsou
14183ba10a containers: Make config path configurable
Container configuration directory can be set in the .env file which is
automatically used by docker-compose.  The default value is the one used
previously (containers/config).
The HACKING.md guide is updated to describe how to set this and how it
affects other commands.
2021-01-30 13:20:11 +00:00
Achilleas Koutsou
7c3a3c785f containers: docker-compose for multi-container setup
Defines how to build and run two containers for osbuild-composer and
worker in the same subnet for testing.
2021-01-30 13:20:11 +00:00
Achilleas Koutsou
172cd4f816 dockerfile: Second image for worker
Worker container image. Follows the same general structure as the
composer image
2021-01-30 13:20:11 +00:00
Achilleas Koutsou
937911feac dockerfile: dnf-json requires python3-dnf 2021-01-30 13:20:11 +00:00
Sanne Raymaekers
946a0b425a containers: Specify port for the composer-api as argument 2020-12-23 17:31:29 +01:00
Tom Gundersen
c3185466ae containers: simplify Dockerfile and container build
This changes the following:
 - Only produce one container. There is no particular benefit to
   supporting several different base containers, so unify on ubi
   as that is what we need ourselves.
 - Build directly from git. Now that the RPM we include in our
   container does not have any dependencies and only contains a
   couple of executables, the indirection via RPM has less value.
   Eventually the value will be reduced even further as we merge
   the entrypoint into the main binary and move dnf-json into the
   worker, leaving us with only a go binary. The only potential
   benefit might be that the build environment of RPMs is more
   clearly defined, but there is no real reason to believe that
   our mockbuild is any better than using the UBI golang build
   container.

This simplifies the container builds, and brings us more in line
with what is done in image-builder, and what is needed to deploy
to openshift.
2020-12-22 15:27:39 +01:00
Ondřej Budai
71428d3131 composer: do not require the weldr socket
It should be totally possible to run osbuild-composer without the Weldr API
and local worker socket. This commit accomplishes this task!

In cloud environments where we don't want the Weldr API, it's now totally
possible to run osbuild-composer without it. If you also want to get rid of
the local worker, this command still works:

systemctl mask osbuild-worker@1.service

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-17 17:01:18 +00:00
Ondřej Budai
dc1b84fcfe composer: split out the local worker socket
Everybody hates the local workers. The first step of getting rid of them
is to split their socket out of osbuild-composer.socket - we need to keep
this one to support the Weldr API but the local worker socket can live in
its own file.

The behaviour should be the same for now: osbuild-composer.service always
starts the local worker socket.

However, this split allows the osbuild-composer executable to be run without
the Weldr API activated. The following commit explores this option more
in depth.

Note that the new socket can be used by root only because workers are always
run as root.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-17 17:01:18 +00:00
Ondřej Budai
0ac554c139 sockets: clarify their descriptions
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2020-11-17 17:01:18 +00:00
Lars Karlitski
41a797547a distribution: remove osbuild-composer-koji
Remove both the package osbuild-composer-koji, and the only file it
shipped: osbuild-composer-koji.socket.

It's been deprecated since 835b556, but the backwards-compatible
solution in that commit never worked, because osbuild-composer only
checks for "osbuild-composer-api.socket" when starting up.

Since this has been meant to be deprecated for a while, just remove it
outright.

Add an "Obsoletes:" for the package, so that it gets uninstalled on
existing systems.
2020-11-10 16:26:03 +01:00
Lars Karlitski
b25a350502 osbuild-composer: merge cloud API into main binary
This removes the osbuild-composer-cloud package, binary, systemd units,
the (unused) test binary, and the (only-run-on-RHEL) test in aws.sh.

Instead, move the cloud API into the main package, using the same
socket as the koji API, osbuild-composer-api.socket. Expose it next to
the koji API on route `/api/composer/v1`.

This is a backwards incompatible change, but only of the -cloud parts,
which have been marked as subject to change.
2020-10-16 09:37:04 +02:00
Lars Karlitski
835b556db7 distribution: deprecate osbuild-composer-koji.socket
Instead, call it osbuild-composer-api.socket, but provide a symlink for
backwards compatibility. Change `schutzbot/provision.sh` to only enable
osbuild-composer-api.socket.

In the future, this new socket is the only API socket, which provides
both the "cloud" API and the one for koji.

This means that the koji API is always enabled.
2020-10-16 09:37:04 +02:00
sanne raymaekers
9ca50ae3ac osbuild-composer-cloud: introduce the cloud-specific service 2020-09-22 11:38:28 +02: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
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
Major Hayden
1dbc271506 Add Install section to remote worker unit file
Although the obuild-remote-worker@.service unit can be started, it can't
be enabled at boot time since the `Install` section is missing in the
unit file.

Add a small `[Install]` section with the same `WantedBy` as
osbuild-composr.service.

Fixes #924.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-24 12:56:45 -05:00
Tom Gundersen
fbfa191c81 rcm: drop sub-package
The osbuild-composer-rcm package was never finished, not in use and will be replaced by osbulid-composer-koji.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-07-17 19:13:15 +01:00
Lars Karlitski
aa0c037bb2 osbuild-worker: support canceling jobs
Exit the whole worker process when a job was canceled, because osbuild
does not clean up all child processes when receiving SIGKILL.

Change the service to restart osbuild-worker also on success, and
decrease the restart timeout.
2020-06-12 10:00:50 +02:00
Tom Gundersen
6002a128b8 osbuild-worker: don't flush cache between jobs
Until osbuild-14, the images were unconditionally kept in the cache,
meaning the cache could grow very large. Now only the downloaded RPMs
are saved, which greatly limits how big it can grow.

Having the RPMs cached should speed up all but the first image build a
lot, so we should take advantage of that by not flushing the cache
between each build.

The cache is still flushed when the worker is stopped / restarted.

This moves the cache from /var/tmp/osbulid-worker* to
/var/cache/osbulid-worker/osbulid-worker-*. This means that each worker
gets a dedicated cache, in case there are several on one machine. In the
future we may want to combine them and only ever have one cache, but for
that we need improvements in parallel access and cache-cleanup.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 19:22:52 +02:00
Major Hayden
b452a31eed Remove CacheDirectory for remote worker
Setting the cache directory to `/var/cache` causes problems on the
remote worker startup and it needs to be removed.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-26 15:46:29 -05:00
Lars Karlitski
b0daa82fad distribution: set permissions on api sockets
This fixes permission for the weldr sockets: allow users in group
`weldr` to access them, but nobody else. Also add this group to the
sysusers file.

Fixes #646
2020-05-20 01:55:26 +02:00
Lars Karlitski
f8982f4a1a worker: don't hard code path to unix domain socket
Introduce a mandatory argument `address`, which is interpreted as a path
to a unix socket when `-unix` is given or a network address otherwise.

Move the default path to the service file.

Add a more useful usage message when passing `-help` or no arguments.
2020-03-25 14:05:44 +01:00
Martin Sehnoutka
9f4042af6c osbuild-composer: don't use hardcoded state directory
Use $STATE_DIRECTORY environment variable which is set by systemd
because we use: StateDirectory=osbuild-composer in the service unit.

also change systemd unit to include STATE_DIRECTORY, because
RHEL comes with older systemd version, so we need to set this variable explicitly.
2020-03-16 21:05:39 +01:00
Lars Karlitski
cdcb6c2f84 distribution: set CACHE_DIRECTORY in the .service file
systemd >= 240 sets this variable to `/var/cache/` + the value of
CacheDirectory. osbuild-composer must run on earlier versions though
(specifically RHEL 8.2).
2020-03-03 14:25:26 +01:00
Martin Sehnoutka
c8ea14e561 distribution: socket unit for RCM API 2020-02-24 12:03:25 +01:00
Tom Gundersen
44c03cf61e dnf-json: make cachedir mandatory
Without passing in a cachedir, dnf would create a random one for every
invocation. This meant that caches were never reused, nor cleaned up
properly.

Let systemd create a cache directory for us in /var/cache/ and use
that via the environment variable systemd sets for us.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-20 15:26:54 +01:00
Tom Gundersen
8b7b592bd2 disbtribution/worker: drop cache directory
This is not currently used. Drop it for now, until we use it, and
when we do, it should be reintroduced with the right name, to avoid
clashing with osbuild-composer (they are owned by different users,
so cannot be shared).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-20 15:26:54 +01:00
Ondřej Budai
820d23fd9d Add tcp and tls support for worker and job API
There's a usecase for running workers at a different machine than
the composer. For example when there's need for making images for
architecture different then the composer is running at. Although osbuild has
some kind of support for cross-architecture builds, we still consider it
as experimental, not-yet-production-ready feature.

This commit adds a support to composer and worker to communicate using TCP.
To ensure safe communication through the wild worlds of Internet, TLS is not
only supported but even required when using TCP. Both server and client
TLS authentication are required. This means both sides must have their own
private key/certificate pair and both certificates must be signed using one
certificate authority. Examples how to generate all this fancy crypto stuff
can be found in Makefile.

Changes on the composer side:
When osbuild-remote-worker.socket is started before osbuild-composer.service,
osbuild-composer also serves jobqueue API on this socket. The unix domain
socket is not affected by this changes - it is enabled at all times
independently on the remote one. The osbuild-remote-worker.socket listens
by default on TCP port 8700.

When running the composer with remote worker socket enabled, the following
files are required:
- /etc/osbuild-composer/ca-crt.pem     (CA certificate)
- /etc/osbuild-composer/composer-key.pem (composer private key)
- /etc/osbuild-composer/composer-crt.pem (composer certificate)

Changes on the worker side:
osbuild-worker has now --remote argument taking the address to a composer
instance. When present, the worker will try to establish TLS secured TCP
connection with the composer. When not present, the worker will use
the unix domain socket method. The unit template file osbuild-remote-worker
was added to simplify the spawning of workers. For example

systemctl start osbuild-remote-worker@example.com

starts a worker which will attempt to connect to the composer instance
running on the address example.com.

When running the worker with --remote argument, the following files are
required:
- /etc/osbuild-composer/ca-crt.pem     (CA certificate)
- /etc/osbuild-composer/worker-key.pem (worker private key)
- /etc/osbuild-composer/worker-crt.pem (worker certificate)

By default osbuild-composer.service will always spawn one local worker.
If you don't want it you need to mask the default worker unit by:
systemctl mask osbuild-worker@1.service

Closing remarks:
Remember that both composer and worker certificate must be signed by
the same CA!
2020-02-20 13:47:59 +01:00
Ondřej Budai
412ce45667 worker: Remove unused -C argument
It isn't defined anywhere in the code, therefore it had no effect in the
unit file.
2020-02-20 13:47:59 +01:00
Tom Gundersen
b9e20c4c06 service: adjust the IO and CPU scheduling classes
Image generation is very much a batch job, latency is not important
and because it is so CPU and IO intensive, it really affects the
overall responsiveness of the system if left on the default settings.

Set scheduling to idle/batched for the worker. The composer service
is still left in the normal scheduling classes as its latency is
important for the UI.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-13 20:13:15 +01:00
Tom Gundersen
22d57ff1a6 service: don't pull down the socket when the service goes down
The intention is for the sockets always to stay around, even when
the service is restarted. This way the worker can always connect.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-11 15:23:24 +01:00
Tom Gundersen
df73a9bfad service: make sure the worker pulls in the socket
The worker cannot be started unless the socket is available, so make
this a hard requirement.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-11 15:23:24 +01:00
Tom Gundersen
ef6fbe2a25 service: pull in the worker at runtime
Rather than enabling the worker when composer is enabled, make sure
it is started whenever composer is.

This means that one worker instance is always available, and more can
be enabled if required. They are then also started whenever composer
is.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-11 15:23:24 +01:00
Tom Gundersen
88c0cf4b27 distro: move binaries to /usr/libexec to follow Fedora packaging guidelines
This makes no difference, so let's just put them where the Fedora
guidelines say they should be.

Also, make sure to own the containing directory.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-11-11 21:13:43 +00:00
Tom Gundersen
029dd0a81b build-sys: rework makefiles
Unify into one make file, with two targets:

build:
  This unconditionally builds the binaries that wolud be shipped in the package,
  this is marked as a phony target, and relies on the go compiler to know what
  is up-to-date and what needs to be rebuilt.

install:
  This installs binaries and config files into the file system and runs any
  scripts to set things up correctly, as if the rpm had been installed.

This drops the old `run` target, which could still be done from the commandline,
but we want to be able to rely on systemd features, so it is not something we
want to test or support.

To run osbuild-composer from a checkout one should now do:
```
$ make build
$ sudo make install
```

This has the same effect as installing the RPM would have, starting and stopping
the sokcets/services is still left to the user.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-11 17:40:31 +02:00
msehnout
7cf8c2e875 Remove RuntimeDirectory
This directory is currently only used for unix-domain sockets but they are created by systemd with the socket unit and therefore this line is redundant and maybe even causes problems.

We want the sockets to live even when the service is down (either because of error or intentional suspension) and it seems that setting the RuntimeDirectory to the directories that contain the sockets makes systemd remove both directories and unlink the sockets when the service fails and that is exactly what we don't want.
2019-10-04 11:17:10 +02:00
Martin Sehnoutka
4dbba6398a fix worker service template
It is not properly named so it does not work for starting multiple
instances. This should fix it.
2019-10-04 01:49:16 +02:00
Martin Sehnoutka
ed185b41ce Integration of osbuild composer with systemd
osbuild-composer now uses socket activation instead of hardcoded paths
in the code. osbuild-worker is an http client therefore it uses only
service unit. osbuild-worker must be started after the socket is
created. osbuild-composer service requires osbuild-worker to run, because without
it no jobs can be started.

osbuild-composer is executed as a regular user (newly created
_osbuild-composer user) as opposed to the worker which must run as root
in order to execute osbuild itself
2019-10-02 17:56:59 +02:00