Commit graph

982 commits

Author SHA1 Message Date
Christian Kellner
cbcb335b3e osbuild: fix spelling mistakes found by codespell
Run codespell on the source ('codespell -f -L msdos -S coverity
-S rpmbuild -S samples') and fix all uncovered mistakes.
2020-10-06 14:41:00 +02:00
Jacob Kozol
549499d2fb runners: add rhel 84
A runner for rhel 8.4 is added. This runner is a sym link to the rhel82
runner as was done for the rhel83 runner.
2020-10-05 18:20:14 +02:00
Chloe Kaubisch
5dc5ddcf29 api: add exception endpoint
Create a new api endpoint called exception, that communicates
exception backtraces separately back to osbuild, as opposed to
dumping them into the normal log. Additionally, add a corresponding
test to check that a call to api.exception correctly sets
API.exception.
2020-10-02 17:49:45 +02:00
Major Hayden
661e202e79 🚚 Bring over osbuild-composer CI changes
Signed-off-by: Major Hayden <major@redhat.com>
2020-09-24 15:53:17 -05:00
Christian Kellner
7f249afe07 20
This completes the development of osbuild version 20.
2020-09-10 13:54:50 +02:00
Christian Kellner
f28753732c NEWS.md: update for osbuild version 21 2020-09-10 13:54:50 +02:00
Christian Kellner
94e5d97836 runners: add Fedora 34 runner
Fedora 33 recently branched off rawhide and thus Fedora 34 was
created. Re-use Fedora 30 runner, as was done for Fedora 33.
2020-09-10 08:25:50 +02:00
chloenayon
01aae91949 api: remove setup_stdio
API.setup_stdio was replaced in PRs 506 and 507,
remove setup_stdio functions and call sites.
2020-09-09 12:52:50 +02:00
chloenayon
b1229de56e pipeline: unify object exporting
Remove output.export and associated logic in pipeline.assemble.
Instead, return output or None, and export only once in pipeline.run.
2020-09-02 17:54:11 +02:00
Christian Kellner
fc0c75f40e test/api: race-free api.metadata access
Access metadata.api only after `api` has exited the context and
thus the event loop has stopped and all incoming messages, like
the one setting the metadata, have been processed.
See commit 803433fb62 for a lecture
about the internals and all the details involved.
2020-08-31 15:06:36 +02:00
Christian Kellner
a3934ab947 test/buildroot: check BuildRoot.output
Now that the `org.osbuild.linux` runner does not use `api.setup_stdio`
anymore, the output of the binary run from the BuildRoot must end up
in `BuildRoot.output`. Check for that.
2020-08-31 15:06:36 +02:00
Christian Kellner
499ae1654e osbuild: replace api.setup_stdio with BuildRoot
Now that the BuildRoot is capable of capturing the output of the
runner and modules (stages, assemblers), there is no need for
using `api.setup_stdio`. Therefore, drop it from all runners and
replace `api.output` with `BuildRoot.output`, which will contain
the output if `api.setup_stdio` is not called from the runners.
2020-08-31 15:06:36 +02:00
Christian Kellner
10579ee6f5 buildroot: return a new CompletedBuild with output
Create a new CompletedBuild object that wraps and is very similar
to the subprocess.CompletedProcess, i.e. it has a process member
but also has shortcuts for returncode. Additionally, the output
of the process is not only forwarded to the monitor, but also
captured and then handed to CompletedBuild, so its output member
will actually contain the full build output. To be compatible
with the previously returned CompletedProcess, `stderr`, `stdout`
members exist on CompletedBuild that also return `output`.
2020-08-31 15:06:36 +02:00
Christian Kellner
61966e3f4c assemblers/tar: use osbuild.api.arguments
Instead of reading the arguments from sys.stdin, which requires
that stdin is setup properly for that in the runner, use the new
api.arguments() method to directly fetch the arguments.

Also fix missing newlines between imports and methods to be more
PEP-8 complaint, where needed.
2020-08-31 15:06:36 +02:00
Christian Kellner
ba94409d23 test/buildroot: check we log bwrap's error output
Check that any errors that bubblewrap spits out on stderr make it
to the log. A common case of bubblewrap failing is a runner failing
to execute.
2020-08-27 08:07:14 +02:00
Christian Kellner
96a5499ed9 buildroot: log bubblewrap's output
In case that bubblewrap fails to, e.g. because it fails to execute
the runner, it will print an error message to stderr. Currently,
this output is not capture and thus not logged. To fix that, the
`BuildRoot.run` method now takes a monitor object and will stream
stdout/stderr to the log via the monitor.
2020-08-27 08:07:14 +02:00
chloenayon
3bf5d26c7a pipeline: replace objectstore logic with get call
In pipeline.run, replace calls to objectstore.contains
and objectstore.new with a call to objectore.get, which
has the same functionality.
2020-08-26 15:10:12 +02:00
chloenayon
35fa429965 objectstore: get returns object not path
Change objectstore.get to return an object or None instead of a path.
2020-08-26 15:10:12 +02:00
Christian Kellner
d6eb78df58 stages: use api.arguments
Instead of reading the arguments from sys.stdin, which requires
that stdin is setup properly for that in the runner, use the new
api.arguments() method to directly fetch the arguments.

Also fix missing newlines between imports and methods to be more
PEP-8 complaint, where needed.
2020-08-25 18:51:55 +02:00
Christian Kellner
fc6e6285ca assemblers: use api.arguments
Instead of reading the arguments from sys.stdin, which requires
that stdin is setup properly for that in the runner, use the new
api.arguments() method to directly fetch the arguments.

Also fix missing newlines between imports and methods to be more
PEP-8 complaint, where needed.
2020-08-25 18:51:55 +02:00
Christian Kellner
fc5e0070c5 test/api: check for 'get-arguments'/api.arguments
Simple check for the new server side method, `get-arguments`, and
client side counterpart, `api.arguments`, that compares that using
the later we get the supplied input (arguments) to API.
2020-08-25 18:51:55 +02:00
Christian Kellner
e273dd0084 api: add 'get-arguments' call and client method
Add a new `get-arguments` API call to fetch the input/arguments.
To avoid running into any limitings on maximum package size on
the socket, the actual data is written to a temp file and a fd
to that passed to the client - very much as in `setup_stdio`.

Additionally, new `arguments` method is provided as a client
counterpart for the new API call.
2020-08-25 18:51:55 +02:00
Christian Kellner
d26cffe585 20
This completes the development of osbuild version 20.
2020-08-13 18:10:57 +02:00
David Rheinsberg
c884030270 build: create NEWS entry for v20
Prepare the v20 release and list the significant changes since v19.
2020-08-13 15:31:08 +02:00
David Rheinsberg
803433fb62 api: prevent early output retrieval
Change the API endpoint to prevent retrieving monitor-output from a
running instance. Instead, we require the caller to exit the API context
before querying the monitor-output. This guarantees that the api-thread
was synchronously taken down and scheduled any outstanding events.

This fixes an issue where a side-channel notifies us of a buildroot
exit, but the api-thread has not yet returned from epoll, and thus might
not have dispatched pending I/O events, yet. If we instead wait for the
thread to exit, we have a synchronous shutdown and know that all
*ordered* kernel events must have been handled.

In particular, imagine a build-root program running (like `echo` in the
test_monitor unittest) which writes data to the stdout-pipe and then
immediately exits. The syscall-order guarantees that the data is written
to the pipe before the SIGCHLD is sent (or wait(2) returns). However, we
retrieve the SIGCHLD from our main-thread usually (p.join() in our test,
and BuildRoot() in our main code), while the pipe-reading is done from
an API thread. Therefore, we might end up handling the SIGCHLD first
(just imagine a single-threaded CPU that schedules the main task before
the thread). To avoid this race, we can simply synchronize with the
api-thread. Since we already have this synchronization as part of the
api-thread takedown, it is as simple as stopping the api-thread before
continuing with operations.

Lastly, if a write operation to a pipe was issued, we are guaranteed
that a SIGCHLD synchronization across processes is ordered correctly.
Furthermore, the python event-loop also guarantees that stopping an
event-loop will necessarily dispatch all outstanding events. A read is
guaranteed to be outstanding in our race-scenario, so the read will be
dispatched. The only possible problem is `_output_ready()` only
dispatching a maximum of 4096 bytes. This might need to be fixed
separately. A comment is left in place.
2020-08-13 14:02:27 +02:00
Christian Kellner
818daef6cb test/stages: metadata checks for the rpm stage
Use the new metadata checking capability of the stage tests to
check the metadata set by the rpm stage.
2020-08-13 10:50:34 +02:00
Christian Kellner
cf48fe8afe test/assembler: check metadata for ostree asm
Check the metadata is in the result and that it has the 'compose'
entry, which should match what is in `compose.json`.
2020-08-13 10:50:34 +02:00
Christian Kellner
f9fc99fe8f test/stages: support for metadata checking
If the stage test folder contains a `metadata.json` file, it will
contain a dictionary where the keys are stage ids and the values
are dictionaries containing the metadata to verify. For each of
those the stage will be looked up in the pipeline result of 'b'
and verified that the metadata matches.
2020-08-13 10:50:34 +02:00
Christian Kellner
19f9fb02bf test: make OSBuild.compile return the result
Load the result data as json and return it to the caller.
2020-08-13 10:50:34 +02:00
Christian Kellner
c298d31ba0 stages/rpm: generate and report package metadata
Generate and report metadata about all the packages that were
installed. This information will be needed by composer, especially
the 'sigmd5' bit, for integration with koji[1].

[1] https://docs.pagure.org/koji/content_generator_metadata/
2020-08-13 10:50:34 +02:00
Christian Kellner
78d46e0388 stages/rpm: fix whitespace
Need double spacing between imports and first statement according
to PEP-8.
2020-08-13 10:50:34 +02:00
Christian Kellner
174a802803 assemblers/ostree.commit: report compose metadata
Pass all the compose metadata, as given by rpm-ostree via the
compose.json, back to osbuild via the new api.metadata method.
2020-08-13 10:50:34 +02:00
Christian Kellner
1af4fc7f2a assemblers/ostree.commit: regroup code for clarity
Re-order the os_version metadata conditional to group all the
optional metadata together. This should make it clearer what
belongs together.
2020-08-13 10:50:34 +02:00
Christian Kellner
30ad32b174 test/api: checks for metadata passing
Add a simple check to make sure that metadata passing via the api
client and api endpoint is working.
2020-08-13 10:50:34 +02:00
Christian Kellner
42b20638c0 pipeline: add metadata to the build result
Include metadata, optionally set by modules, in the build result.
2020-08-13 10:50:34 +02:00
Christian Kellner
fb3a0c5982 api: add support for metadata
Add support for setting metadata via `osbuild.API`. It is meant
to be used by modules (stages, assemblers) to pass additional data
that belong to the result back to osbuild. For this, a new api
method `set-metadata` can be used to set and update a metadata
dictionary on the `osbuild.API` class. A client side method
`metadata` is provided to do so.
2020-08-13 10:50:34 +02:00
Christian Kellner
939a83926e stages/noop: fix whitespaces
Be more like PEP-8 and use two newlines where needed.
2020-08-13 10:50:34 +02:00
Christian Kellner
e0b7361b26 test/buildroot: check selinuxfs is read-only
This is a crucial pre-condition for the org.osbuild.selinux stage
to work properly, especially that it can set labels that are not
present in the policy on the host. If /sys/fs/selinux is writable,
setfiles will try to verify the labels via /sys/fs/selinux/context
and fail for unknown labels.
2020-08-12 16:52:27 +02:00
Christian Kellner
e2231a8bd2 test/buildroot: simple check for bind mounts
Check that bind-mounting works and read only bind mounts are indeed
read-only and "normal" bind mounts are read-write.
2020-08-12 16:52:27 +02:00
Christian Kellner
bcfc2ca29a test/data: add mount_flags.py helper script
Add a new helper script to check if a mount / file-system was
mounted with specific flags. Currently only "ro", "nosuid",
"nodev" and "noexec" flags are supported. This script is in
test/data since it will be used from other tests and is itself
not a test per se.
2020-08-12 16:52:27 +02:00
Christian Kellner
28cea491bd test: move api buildroot test to test_buildroot.py
Create a new test suite for BuildRoot related test and move the
the combined api and buildroot check there.
2020-08-12 16:52:27 +02:00
Christian Kellner
41cf4bf2d3 buildroot: ensure /sys/fs/selinux is read-only
Make sure "/sys/fs/selinux" is read-only, otherwise libselinux and
tools will assume that SELinux is available and active and in turn
use /sys/fs/selinux to e.g. verify the file systems labels; this
will then prevent setting unknown labels via `setfiles`.
2020-08-12 16:52:27 +02:00
Christian Kellner
6e63baa0d4 assemblers/ostree.commit: whitespace fixes
Be more PEP-8 compliant.
2020-08-12 08:08:17 +02:00
Christian Kellner
fdded58cdd test/assembler: check for ostree version metadata
Set the OS version of the commit via the new `os_version` option
and make sure that it is in the compose info as well as in the
commit metadata.
2020-08-12 08:08:17 +02:00
Christian Kellner
b89ef5aa5e assemblers/ostree.commit: version metadata support
Add a new `os_version` option that will result in the `version`
metadata being set as commit metadata. This will then be shown
in the `rpm-ostree status` output.
2020-08-12 08:08:17 +02:00
Christian Kellner
e1e50c3339 runners: add support for ubuntu 20.04
Base it on the ubuntu 18.04 runner.
2020-08-10 21:37:28 +02:00
Christian Kellner
3c556c3386 selinux: allow nnp and nosuid transitions
Allow osbuild_t to no_new_privs (nnp) and nosuid domain transition
into setfiles_mac_t and install_t. nnp is a inheritable per-thread
flag (PR_SET_NO_NEW_PRIVS, see prctl(2)), whereby a promise is made
by execve(2) to not grant any new privileges that could not have
been done without the execv call. This is on contrast to what can
be done via SELinux rules, i.e. in our case `setfiles_mac_t` and
`install_t` can set arbitrary SELinux labels, but `osbuild_t`
itself can not; but `osbuild_t` enables the transitioning of
`setfiles_mac_t` for the `setfiles` binary via execve(2) from a
process with `osbuild_t`. Related, the nosuid mount flag, prevents
the suid, sgid bits to be interpreted and thus are in the same
spirit as nnp, i.e. no new privs during execve(2).

Thus SELinux domain transitions stand in contrast with nnp and
nosuid transitions, and have therefore been de-coupled. See also
the corresponding kernel patch at [1] for more information.

bubblewrap (bwrap) in contrast to `systemd-nspawn` always sets the
nnp flag, as well as the nosuid option for all bind-mounts. Since
we no use bwrap to contain processes we need to allow the nnp and
nosuid transitions from `osbuild_t` to `setfiles_mac_t` and
`install_t`.

[1] https://patchwork.kernel.org/patch/9841441/
2020-08-10 14:05:24 +02:00
chloenayon
fdaa2e1a66 osbuild: require output_directory
Make the output_directory argument in Pipeline.assemble
and Assembler.run required. The qemu assembler assumes
it is passed in args and will crash without it. Making
it mandatory prevents this.
2020-08-07 20:39:14 +02:00
Major Hayden
c0d71c3fa1 monitor: add assembler/stage duration
Allow a user to see the duration for each step in the osbuild pipeline.

This allows a user to optimize the build system for the best performance
and identify performance bottlenecks.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-06 16:19:47 +02:00
Major Hayden
0ee38b00d1 🤖 schutzbot: Bring over updates from o-c
Signed-off-by: Major Hayden <major@redhat.com>
2020-08-06 00:16:39 +02:00