Commit graph

873 commits

Author SHA1 Message Date
Christian Kellner
5d226b2e15 test: add basic checks for monitoring and API
Add a basic test that will set up an 'API' endpoint, then spawn a
child process that uses that 'API' endpoint to setup its stdio in
very much the same way as runners do. This is used to verify that
the API itself works properly as well as the new LogMonitor class
by comparing the inputs and outputs.
2020-07-21 13:25:04 +02:00
Christian Kellner
3e18d8118c api: introduce pipeline monitoring
Introduce the concept of pipeline monitoring: A new monitor class is
passed to the pipeline.run() function. The main idea is to separate
the monitoring from the code that builds pipeline. Through the build
process various methods will be called on that object, representing
the different steps and their targets during the build process. This
can be used to fully stream the output of the various stages or just
indicate the start and finish of the individual stages.

This replaces the 'interactive' argument throughout the pipeline
code. The old interactive behavior is replicated via the new
`LogMonitor` class that logs the beginning of stages/assembler,
but also streams all the output of them to stdout.
The non-interactive behavior of not reporting anything is done by
using the `NullMonitor` class, which in turn outputs nothing.
2020-07-21 13:25:04 +02:00
Christian Kellner
5d55bc9aca api: use io.StringIO as output data buffer
Instead of using plain python strings and appending to them, use
'io.StringIO' which is a data structure meant to be used for i/o.
This should increase performance compared to plain strings.
2020-07-21 13:25:04 +02:00
Christian Kellner
1e88ee62e3 api: use pipe for output
Instead of either using a text file, in non-interactive mode, or
directly stdout otherwise, create a pipe and always use that as
for stdout/stderr when preparing the output for 'setup_stdio'.
This streamlines the two cases (interactive, non-interactive) and
as a result 'API.output' will always contain the full output data.
2020-07-21 13:25:04 +02:00
Christian Kellner
4c6ca0b4a0 api: properly close the event loop
Close the event loop when the context is exited, which will clear
the internal queues and shut down the executor of the event loop.
Not doing this will create a warning when the object is garbage
collected.
2020-07-21 13:25:04 +02:00
Christian Kellner
e9c4075bb3 remoteloop: properly close the event loop
Close the event loop when the context is exited, which will clear
the internal queues and shut down the executor of the event loop.
Not doing this will create a warning when the object is garbage
collected.
2020-07-21 13:25:04 +02:00
Christian Kellner
291fadd0b2 pylint: increase max attributes to 10
In three places we have more than 7 instances attributes, but less
then 10; instead of disabling the warning for all these cases,
increase the limit to a reasonable size of 10 and re-enable the
warnings in all the places.
2020-07-21 13:25:04 +02:00
Ondřej Budai
4b290dd2a4 test: use a dummy pipeline when testing assemblers
#471 extends the assembler test suite to also test xfs and btrfs filesystems
in raw and qemu assemblers. However, this change leads to long running times
of this suite.

The running time of these test consist of 3 main steps:

1) Building the build pipeline
2) Building the stages
3) Running the assembler

There are two optimization approaches:

1) Caching
   OSBuild supports caching, therefore it's possible to cache results of first
   two steps.

2) Minimizing the operating system tree
   Assemblers don't care about the image contents. Therefore, it's possible
   to create just a small tree which would be used to test the assemblers.
   This should lead to speed up in the step 2 (smaller tree should be built
   quicker) and in step 3 (big part of assembling is just copying files over
   to the image).

This commit implements the second approach. A new test manifest is now added,
which just installs the filesystem package and its dependencies and this tree
is then labeled. This solution was chosen, so that the assemblers get
something that looks as a proper filesystem tree but also can be built pretty
quickly.

Before this change, the test_rawfs method with #471 merged ran for 842 seconds.
After this change, it ran for 391 seconds.
2020-07-21 10:25:47 +02:00
chloenayon
58bd7a204a osbuild: return if output-directory not specified
If the user does not specify an output directory or checkpoints
to osbuild, exit successfully without building.

Previously, if a user did not include an output directory or
checkpoints, it would build the manifest and throw out the result.
Returning early will be clearer to the user and avoid wasting work.
2020-07-20 19:17:30 +02:00
Major Hayden
dd6981c481 Use script for telegram notification
Jenkins' declarative pipelines have interesting requirements around when
you can use traditional groovy scripting in the pipeline and some items
in `post` require special handling.

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-20 16:22:21 +02:00
Ondřej Budai
cc494ec04b schutzbot: remove enabling of rcm socket unit
The whole rcm subpackage was removed in osbuild-composer's commit fbfa191.
Unfortunately, this broke osbuild's schutzbot because it tries to start
the rcm socket.

This commit removes enabling of the not-anymore-existing socket unit.
2020-07-20 08:57:27 +02:00
Major Hayden
be2f7dc795 💣 Notify via telegram on master CI failure
We've come a long way and we need to triage failures that occur during
CI for the master branch. This will help us find problems with CI as
well as find other issues that could show up in a customer environment.

Also, let's send a happy notification when everything goes well. 💚

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-17 13:56:30 -05:00
Christian Kellner
53f6c41917 osbuild: use osbuild_cli directly as main entry
Instead of having a another indirection via `main_cli`, directly
use `osbuild_cli` in as main function in `__main__.py`. Also use
that in as the entry point for the generated `osbuild` executable.
Change `osbuild_cli` to be self-contained, i.e. it directly uses
`sys.argv` and `sys.exit`.
2020-07-17 16:30:46 +01:00
Christian Kellner
7e392f819e stages/noop: fix the schema to allow any props
The documentation states that the stage accepts any options and
dumps them but the schema was not allowing any. Fix that and also
change the sample to include a random option.
2020-07-16 19:02:25 +02:00
Major Hayden
1a7f286578 ⚙ Bring over CI improvements from osbuild-composer
Signed-off-by: Major Hayden <major@redhat.com>
2020-07-14 13:05:18 +02:00
Christian Kellner
e3eccbe491 osbuild: remove ability to pass in secrets
The way secrets work has been changed via commit 372b117: instead
of passing them in via the command line, the information how to
obtain secrets are encoded along the sources themselves.
The only stage that still has support for the old style way is the
deprecated org.osbuild.dnf stage, which might be removed in the
near future.
2020-07-10 11:44:15 +02:00
Christian Kellner
9fd28c8c21 pipeline: remove extra empty line
More PEP-8. No semantic change.
2020-07-10 11:44:15 +02:00
Christian Kellner
a505a82169 ci: schedule coverity only for osbuild/osbuild
Don't schedule the run of coverity on forks of osbuild, but only
on the main repository.
2020-07-07 08:26:53 +02:00
Martin Sehnoutka
cd0db46601 samples/ppc64le: change the URL to the RPM packages
The mirror used in f30-ppc64le example did contain the RPM packages but
there were two issues
 * f32 is not in development any more
 * ppc64le is available as a secondary arch

The patch also renames the file as it contains packages for fedora 32.
2020-07-02 12:39:16 +02:00
Martin Sehnoutka
a4bdf965e3 samples/s390: Modify the URL to the RPM packages
mirrors.kernel.org does include packages for s390 but they are available
in /fedora-secondary directory.
2020-07-02 12:39:16 +02:00
Ondřej Budai
7b0db90c76 sources/files: do not pass floats to --max-time
curl uses strtod from the C standard library to convert the --max-time's value
from string to double. However, this is what strtod expects:

nonempty sequence of decimal digits optionally containing decimal-point
character (as determined by the current C locale)

Yeah, unfortunately, the decimal-point character is determined by the current
C locale. For example, Czech and German locale uses a comma as the
decimal-point character.

For reasons I don't fully understand, Python thinks it's running on en_US
locale, even though LC_NUMERIC is set to cs_CZ, so it uses a full stop as the
decimal-point character when converting float to string. However, as written
before, curl fails to parse this because it expects comma.

The fix I chose is simple: Use math.ceil, so only an integer can be passed to
curl. Why ceil? Because --max-time == 0 sounds fishy. math.ceil should return
an integer (and it does in Python 3.8) but the documentation is not 100% clear
on this topic, so let's be paranoid and also convert it to int after the
ceiling.
2020-06-25 21:25:17 +02:00
Christian Kellner
6baacf14ee stages/systemd: small whitespaces fixes
Be more PEP-8 conforming.
2020-06-24 10:05:11 +02:00
Christian Kellner
23aa98bfe6 stages/systemd: make enabled_services optional
It should be possible to use the stage to only set the default
target or disable services. There is no need to always require
having `enabled_services`.
2020-06-24 10:05:11 +02:00
Christian Kellner
7ac8f41798 stages/systemd: ability to mask services
Add the ability to mask services, which is done e.g. when building
installers. See systemctl(1) for more information about masked
services.
Modify the existing stage test to include a test for it.
2020-06-24 10:05:11 +02:00
Christian Kellner
3d13c825c0 ci: run coverity check every night
Add a github workflow that will trigger the run of coverity every
night at 05:00 UTC. Uses the new Makefile coverity targets.
2020-06-24 10:01:24 +02:00
Christian Kellner
b5cc1a6f1a test: add coverity targets to the Makefile
Add the scaffolding and various targets to run a coverity analysis,
including downloading the tool, running the "build", archiving
the results and submitting it to coverity for analysis.
The downloading and submitting need COVERITY_{EMAIL, TOKEN} to be
defined in the environment.

Co-authored-by: David Rheinsberg <david.rheinsberg@gmail.com>
2020-06-24 10:01:24 +02:00
Christian Kellner
c1a98af56a 18
This completes the development of osbuild version 18.
2020-06-23 20:02:42 +02:00
Christian Kellner
94840dccd7 NEWS.md: update for osbuild version 18
Major change is that all RHEL based runners now use platform-python.
2020-06-23 20:02:42 +02:00
Christian Kellner
53651fa3da Makefile: rename 'test-mod' target to match help
Rename the 'test-mod' target to 'test-module' to match the help
string.
2020-06-23 16:06:53 +02:00
Christian Kellner
cb265e8b58 runners: use platform-python on RHEL
Runner are invoked to prepare the execution of stages and assemblers
inside the container. The setup tasks are specific to the distribution
and maybe the version of it, therefore specific runners are used for
each distribution+version combination.
The build the first (most nested) build root, `/usr` is taken from the
host to bootstrap the container. On RHEL, the python interpreter to be
used for software that belongs to the platform is platform-python, as
it provides a stable API. Therefore the RHEL runners should use that
instead of relying on the presence of /usr/bin/python3.6, which might
not be installed and is indeed not installed by default.
2020-06-19 08:07:07 +02:00
Christian Kellner
54dffeaaa0 test/stage/selinux: add check for new label option
Manually set a label for '/usr/bin/cp' to 'isntall_exec_t' and
verify it has been set correctly.
2020-06-15 20:36:48 +02:00
Christian Kellner
d70c5a7334 stages/selinux: support label overwrites
Add a new `labels` option that can contain `path`: `label` pairs
to overwrite the default labels for `path`.
NB: These manually set labels will not survive a relabeling and
are most useful to adjust policy in the buildroot, e.g. for `cp`
to be able to copy labels unknown to the host, by labeling it
as `system_u:object_r:install_exec_t:s0`.
2020-06-15 20:36:48 +02:00
Christian Kellner
15986d9297 test: add selinux stage test
Add a simple check for the selinux check by building the f32-base
image with an added selinux stage. Use the options from a test
json file and verify the labels against a set of labels given in
the aforementioned test file.
2020-06-15 20:36:48 +02:00
Christian Kellner
0cf581a9a4 util/selinux: add gefilecon helper
Add a simple helper that gets the security context for a given
path as a plain string.
2020-06-15 20:36:48 +02:00
Christian Kellner
85cd334945 test/stages: narrow test detection via diff.json
Only generate stage tests for sub-directories in stages_tests
that contain a diff.json. This should allow us to have specialized
stage tests that don't use the current {a, b}.json & diff.json
pattern.
2020-06-15 20:36:48 +02:00
Christian Kellner
9ce8ed38cb stages/selinux: whitespace fix
Be more like PEP-8 likes it.
2020-06-15 20:36:48 +02:00
Christian Kellner
00f06dff16 test/assemblers/ostree: check rpm-ostree.inputhash
Verify the rpm-ostree.input hash is set correctly for the repository
itself as well. This will in turn also verify that the repository
is existent and can be accessed.
2020-06-15 13:44:01 +02:00
Christian Kellner
da80259ea0 test: add a test for the ostree.commit assembler
Create a ostree commit and check that it successfully was created
by inspecting the resulting `compose.json`.
2020-06-15 13:44:01 +02:00
Christian Kellner
5a54dfcf9f manifests: install rpm-ostree in the build root
Install rpm-ostree in the (mpp-)f32-build.json build manifest, so
ostree commits can be created using the same build root. Update
all affected manifests.
2020-06-15 13:44:01 +02:00
Christian Kellner
953583d636 tools/mpp-depsolve: support excluding packages
Support excluding packages when dep-solving; needed for e.g. the
ostree commits to not create a rescue kernel by excluding the
'dracut-config-rescue' package.
2020-06-15 13:44:01 +02:00
Christian Kellner
cf03ca0715 test/assemblers: remove the need to use nbd
Using the network block device (nbd) kernel module to test all
the non-raw image formats often caused tests to fail due to nbd
not being stable itself (see below).
Instead convert non-raw images to the raw format via qemu-img
convert and mount those with loop-back devices. All the testing
code itself stays the same.

Example nbd error messages:
  kernel: block nbd15: NBD_DISCONNECT
  kernel: block nbd15: Disconnected due to user request.
  kernel: print_req_error: 89 callbacks suppressed
  kernel: blk_update_request: I/O error, dev nbd15, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
  kernel: buffer_io_error: 134 callbacks suppressed
  kernel: Buffer I/O error on dev nbd15, logical block 0, async page read
  kernel: blk_update_request: I/O error, dev nbd15, sector 1 op 0x0:(READ) flags 0x0 phys_seg 7 prio class 0
2020-06-15 11:51:31 +02:00
Christian Kellner
21e0475031 test/assemblers: split partition reading and test
Split up the partition table test into reading the partition table
and then asserting it has the correct entries. Prepares the usage
of the partition information later.
2020-06-15 11:51:31 +02:00
Christian Kellner
1800f2a711 17
This completes the development of osbuild version 17.
2020-06-10 15:43:24 +02:00
Christian Kellner
1e7b41d5da NEWS.md: update for osbuild version 17
Major feature is the new custom SELinux policy to fix labeling.
Important bug fixes to the files source, the rpm stage. Also
restore Python 3.6 support.
2020-06-10 15:43:24 +02:00
Tom Gundersen
72e1e7217b stages/rpm: allow check_gpg to be omitted
This brings it in line with the JSON schema. Also fix a bug where the
wrong root was used for checking the signatures.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-10 15:10:27 +02:00
Christian Kellner
b0bf9c9392 assemblers/ostree.commit: set inputhash metadata
Use the new `meta` information passed to the assembler and use
the id as the `rpmostree.inputhash` metadata that will get set
on the commit.
2020-06-10 15:08:49 +02:00
Christian Kellner
72e00f3f2b pipeline: pass meta data to stages & assemblers
Pass a new `meta` object to the stages and assemblers that for now
only contains the `id` of the corresponding stage or assembler.
2020-06-10 15:08:49 +02:00
Tom Gundersen
82f4d1cc96 sources/files: reduce the concurrent curl processes
We appear to be throttled by some mirrors if we are too eager. Back off.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-10 14:42:10 +02:00
Christian Kellner
65e1b35102 selinux: Allow unconfined_service_t → osbuild_t
When osbuild is invoked via the osbuild composer worker, the latter
is run in the unconfined_service_t domain, so add a rule that
allows that transition.
2020-06-10 01:35:05 +02:00
Christian Kellner
a419ee9038 buildroot: grant CAP_MAC_ADMIN for labeling
When applying labels inside the container that are unknown to the
host, the process needs to have the CAP_MAC_ADMIN capability in order
to do so, otherwise the kernel will prevent setting those unknown
labels. See the previous commit for more details.
2020-06-10 01:35:05 +02:00