Commit graph

867 commits

Author SHA1 Message Date
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
Christian Kellner
7171eb2bf3 osbuild: add custom selinux policy
A usual step in creating OS file system trees is to apply the
correct SELinux labels for all files and directories. This is
done by the org.osbuild.selinux stage, which internally uses the
setfiles command in order to do so. The SELiunx policy to be
used for this operation is the one of the newly created system,
not the host one. It therefore can contain labels that are not
known on the host. The kernel will prevent setting invalid,
i.e. unknown, labels unless the caller has the CAP_MAC_ADMIN
capability. By default, setfiles is executed in the setfiles_t
domain, where it lacks that capability. Therefore a custom
osbuild SELinux policy was created, with a special transition
rule that will execute setfiles in the setfiles_mac_t
domain. All stages, sources and assemblers as well as the main
binary are label with the new osbuild_exec_t label.

Additionally, allow a transition from osbuild_t to install_t by
using `anaconda_domtrans_install`, so that ostree and
rpm-ostree, which are labeled as install_exec_t, can transition
to the install_t domain when called form osbuild.  Update the
spec file to build the policy and include it in a new
osbuild-selinux sub-package.
2020-06-10 01:35:05 +02:00
Christian Kellner
696219dab9 util/ostree: accept typing.List for List[str]
In python 3.6 the value of `__origin__` for typing.List[str] is
typing.List. This then changed to the actual `list` type in later
versions. Accept both versions.
2020-06-09 13:42:35 +02:00
Christian Kellner
7a2ad6f0f8 osbuild: replace capture_output in subprocess.run
The `capture_output` argument for subprocess.run was added in 3.7,
but want to support 3.6 as well. Change all the usages of it with
`stdout=subprocess.PIPE` that will have the same effect, at least
for stdout.
2020-06-09 13:42:35 +02:00
Lars Karlitski
d7d1d9dbbf Take care not to put large content on /tmp
Most stages and assemblers already use `/var/tmp` to store large
files or trees. Do this in the qemu assembler and copy stage as well.
2020-06-09 09:12:05 +02:00
Tom Gundersen
cf8216aea9 sources/files: don't spam stderr with error messages
Silence the errors, but include instead the error code in the returned
error message.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 22:08:34 +02:00
Tom Gundersen
d8e0469516 sources/files: don't retry curl on the same URL
The retry logic was meant to work around issues where a round-robin
redirect of mirrors gave us random mirrors of varying quality. This was
not used in practice, rather fixed mirrors were always used (either
hard-coded as basurl, or resolved from metalink).

The retry logic meant that when we did hit very slow mirrors we would
time-out and retry, potentially failing altogether, even though the data
was coming. Each retry would not help, as the mirror was anyway the
same. As a result our CI gave us avoidable false negative test results
some of the time.

The proper solution to this is to gain support for librepo and metalinks
to adopt the same retry logic that dnf uses.

For now, improve on the retry logic by retrying until a max total time,
rather than an increasing timeout on each try. Up the given timeouts to
be one minute to connect and five minutes to complete the download. This
avoids hanging forever if the mirror is truly broken, but still gives
more time to finish the download than each iteration in the old code
did.

There are no new tests for this, as before this change the tests mostly
passed, and after it they will hopefully still mostly pass (but more
often).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-07 22:08:34 +02:00