Commit graph

1635 commits

Author SHA1 Message Date
Tom Gundersen
b081cf7f64 35
Release osbuild 35

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-08-29 20:09:59 +02:00
Christian Kellner
3c565347a3 stages/kickstart: quote ssh-key
Surround the ssh key by quotes since it might contain spaces.
2021-08-29 20:09:30 +02:00
Tom Gundersen
b430bd8682 34
Release osbuild 34

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-08-29 18:28:55 +02:00
Christian Kellner
4a5508e086 stages/bootiso.mono: support for aarch64 tempates
Use the aarch64 templates if the efi architecture was set to AA64.
NB: since we only support efi booting for aarch64 this should be
good enough for aarch64 selection.
2021-08-29 16:33:13 +02:00
Christian Kellner
597f5f9ea7 stages/kickstart: add schema for remote option
The code of the `org.osbuild.kickstart` stage already supported
adding the `--remote` option for `ostreesetup` via the `remote`
option but it was not included in the schema.
2021-08-29 16:33:06 +02:00
Christian Kellner
82cc2aeb4e test/data: use cloud-init in ostree image
Although zezere is the official tool, cloud init is easier to use
for local testing so switch to that.
2021-08-28 16:34:37 +02:00
Christian Kellner
c788a74fb5 stages/ostree.deploy: add remote option
Add an optional `remote` to the deployment of the ostree so that
the it is tied to the specified remote. This is needed later for
updating the commit from that remote.
2021-08-28 16:34:37 +02:00
Christian Kellner
7ea9796d9b stages/ostree.pull: add remote parameter
Add an optional `remote` parameter that can be used to specify the
the remote to track for the pulled commits.
2021-08-28 16:34:37 +02:00
Simon Steinbeiss
4459a37a66 33
Release osbuild 33

Signed-off-by: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
2021-08-25 22:24:46 +02:00
Christian Kellner
877f2ba3c3 stages/grub2: greenboot support
Greenboot is the idea of automatically rolling back bad updates,
i.e. updates that do not boot successfully. The implementation
is split between the boot loader and a user space component.
The latter sets two variables `boot_counter`, which indicates
the maximum number of boot attempts and `boot_success` which
tells the boot laoder if a previous boot was successful. The
bootloader on the other hand will decrement the counter variable
and reset the success indicator one.
An implementation of the user space component for rpm-ostree is
called `greenboot`.
2021-08-25 20:53:12 +02:00
Diaa Sami
7a676667d6 Don't save name or timestamp for compressed file 2021-08-24 20:47:00 +02:00
Diaa Sami
b93dedf353 stages: add org.osbuild.gzip to compress files
Add a new stage that will take a file from the input and compress
it via gzip.
2021-08-24 20:47:00 +02:00
Tom Gundersen
a40cf616f5 32
Release osbuild 32

Signed-off-by: Tom Gundersen <teg@jklm.no>
2021-08-24 14:48:14 +02:00
Christian Kellner
ca3941feb6 inputs/ostree.checkout: don't overwrite refs
The `refs` variable is used as parameter to indicate which commits
to checkout, but it also was used as result variable to store the
ids of the commits that actually got checked out; naturally, it
was initialized to the empty array. This of course meant nothing
was ever actually checked out. Doh.
2021-08-24 01:21:03 +02:00
Christian Kellner
da8f45ef48 stages/grub2: add new uefi.unified option
Fedora 34 and thus RHEL 9 have adopted the unified grub config
scheme[1], where the main config is always placed in the same
location across all platforms, i.e. `boot/grub2`, and a stub
config that redirects to the main config is placed into the ESP.
osbuild has always done that in the case of hybrid boot, but not
for pure EFI systems. The new `uefi.unified` config option can
be used to select that new unified scheme even for the case of
pure EFI systems (aarch64 or non-hybrid boot).

Add a simple test for the grub stage.

[1] https://fedoraproject.org/wiki/Changes/UnifyGrubConfig
2021-08-23 13:55:32 +02:00
Christian Kellner
f3f3904368 stages/lvm2.metadata: fix typo in regex
It is zero to nine, not zero and nine.

Reported-b: Achilleas Koutsou <achilleas@koutsou.net>
2021-08-21 09:10:42 +02:00
Christian Kellner
e8c2190363 runners: add Fedora 36 runner
New `org.osbuild.fedora36` which is re-using the f30 runner.
Needed since Fedora 36 was branched already.
2021-08-20 23:02:36 +02:00
Christian Kellner
2a53814058 packit: create downstream prs on release
Create the downstream, i.e. fedora dist-git, pr on releases.
2021-08-19 18:33:46 +02:00
Christian Kellner
572d963f0d 31
Release osbuild 31

Signed-off-by: Christian Kellner <christian@kellner.me>
2021-08-19 13:38:58 +02:00
Ondřej Budai
b24f9858c3 schutzbot: update images for RHEL 9
Previously:
We used images built from pre-mass-rebuild composes but installed packages
from post-mass-rebuild composes. This caused weird stuff like sshd crashing
when installing non-related packages via dnf.

Now:
Both the image and repositories are post-mass-rebuild ones. This should solve
these weird issues.
2021-08-19 01:42:40 +02:00
Martin Sehnoutka
8b0ea15817 stages: add org.osbuild.ostree.passwd
This stage takes /usr/lib/passwd and /usr/etc/passwd from an OSTree
checkout, merges them into one file, and store it as /etc/passwd in the
buildroot.

It does the same for /etc/group.

The reason for doing this is that there is an issue with unstable UIDs
and GIDs when creating OSTree commits from scratch. When there is a
package that creates a system user or a system group, it can change the
UID and GID of users and groups that are created later.

This is not a problem in traditional deployments because already created
users and groups never change their UIDs and GIDs, but with OSTree we
recreate the files from scratch and then replace the previous one so it
can actually change.

By copying the files to the build root before doing any other
operations, we can make sure that the UIDs and GIDs of already existing
users and groups won't change.

Co-author: Christian Kellner <christian@kellner.me>
2021-08-17 13:53:00 +02:00
Christian Kellner
3695e22369 inputs: add org.osbuild.ostree.checkout
New input type that takes a ostree repo and checks out any number
of commits inside that repo to a temporary directory. Each commit
will be checked out to a separate sub-directory. The name of the
dir is the commit id of the corresponding commit.
This input can thus be used to access files and directories of
commits in stages.
2021-08-17 13:53:00 +02:00
Christian Kellner
a93c874c47 devcontainer: include packit, boto3 & more tools
Include the packit tool to be able to do updates from the container.
Additionally, include python-boto3 so that `make test-src` now does
not complain about missing `boto3` imports.
Also include ipython3 for quick python code snippet testing and
lsof to debug processes that keep files open.

NB: for packit to work you have to have the right tokens in your
local packit configration file (see the upstream doc). Additionally,
`packit propose-downstream`, to create PRs for a new downstream
release, needs kerberos auth to work correctly.
2021-08-17 10:42:03 +02:00
Christian Kellner
dbfc04cbb0 test/data: use generic build for fedora-boot
Instead of using the version specific, pre-depsolved f34 build manifest,
use the new version agnostic build manifest (fedora-build.mpp). NB: this
is included directly as mpp so that its variables get defined by the
including manifest. This should make it even easier to update manifests
to new fedora releases.
2021-08-17 10:42:03 +02:00
Christian Kellner
bab3639731 test/data: add version agnostic build manifest
Include a build manifest that is itself not have tied to a specified
version and thus is meant to be included with the following vars
pre-defined as .mpp file:
  - arch          architecture (x86_64)
  - releasever    release version (f34)
  - snapshot      rpmrepo snapshot (20210326)
2021-08-17 10:42:03 +02:00
Christian Kellner
f49d8fb30a packit: configure tag template
We use `v{version}` as tags.
2021-08-17 10:42:03 +02:00
Christian Kellner
563d56bc61 devices/loopback: it is flush_buf not flushbuf
That ironically fix the underlying bug that flush_buf is trying to
fix too, since now an exception is thrown and we are back to auto
clear. The file fd is then closed when the process is terminated.
Anyway, the right fix is to call the correct function.
2021-08-14 13:25:19 +02:00
Christian Kellner
1d13b0c1f1 devices/loopback: clear the buffer cache
Manually clear the buffer cache of the loop device, which seems to
be required in order to make sure that data written via the loop
device is actually landing in the file:
Since commit c1379f6 the file descriptor of the loop device is
explicitly cleared. This broke manifests that involved creating a
FAT filesystem. Said file system could later not be mounted. The
breaking change was identified to indeed be commit c1379f6. Using
`biosnoop` we saw that some write operations were missing when
clearing the file descriptor that were present when using the
auto-clearing feature of the loop device (see below). Reading the
corresponding kernel source (v5.13.8), the current theory is that
when using the auto clear feature, once the last handle on the
loop device is closed, the code path in the kernel is:
    blkdev_close (fs/block_dev.c)
    blkdev_put (fs/block_dev.c)
    __blkdev_put (fs/block_dev.c)
    sync_blockdev (fs/block_dev.c)

On the other hand when manually clearing the file descriptor, the
code path seems to be:
    loop_clr_fd (fs/loop.c)
    __loop_clr_fd (fs/loop.c)

The latter first removes the backing file and then calls `bdput`,
and thus no call to sync_blockdev is made.

Luckily, sync_blockdev can be called via an ioctl, `BLKFLSBUF`,
which we no do, via the new helper function `lo.flush_buf`. This
fixes the observed issue and leads to the same biosnoop trace as
observed when using the auto clear feature without explicitly
clearing the fd.

NB: we considered reverting the commit c1379f6, but we want to make
sure that we control to point when the backing file is cleared from
the fd, since sub-sequent osbuild stages will re-use the file and
we want to ensure no loop device still has the file open and that
all the data in is in the file.

-- biosnoop trace --
4.115946    mkfs.fat       731297 loop1   R 0          4096      0.08
4.116096    mkfs.fat       731297 loop1   R 8          4096      0.02
4.116176    mkfs.fat       731297 loop1   R 16         4096      0.02
 [...]
4.120632    mkfs.fat       731297 loop1   R 400        4096      0.02
4.200354    org.osbuild.lo 731281 vda     W 4182432    32768     0.64
4.200429    org.osbuild.lo 731281 vda     W 6279584    32768     0.70
4.200657    ?              0              R 0          0         0.19
4.200946    org.osbuild.lo 731281 vda     W 3328128    4096      0.20
4.201109    ?              0              R 0          0         0.13
 [the following entires were missing with manual flushing:]
4.201601    org.osbuild.lo 731281 loop1   W 0          4096      0.24
4.201634    org.osbuild.lo 731281 loop1   W 8          4096      0.26
4.201645    org.osbuild.lo 731281 loop1   W 16         4096      0.27
 [...]
4.203118    org.osbuild.lo 731281 loop1   W 432        4096      0.25

Reported-by: Achilleas Koutsou <achilleas@koutsou.net>
Reported-by: Tomas Hozza <thozza@redhat.com>
2021-08-13 17:35:32 +02:00
Christian Kellner
4126a3af7c test/loop: check for data integrity
Add a simple check that data written through the loop device is
actually ending up in the file. NB: this this will _fail_ if the
fd is cleared via `clear_fd` without the use of `flush_buf`. It
seems that the kernel (as of 5.13.8) will indeed not clear the
buffer cache of the loop device if the backing file is detached
via `LOOP_CLR_FD`. On the other hand, if the autoclear flag is,
i.e. the backing file cleared when the last file descriptor of
the loop device is closed, the buffer cached will be cleared as
part of the `release` operation of the block device.
2021-08-13 17:35:32 +02:00
Christian Kellner
43fb869860 loop: helper to call ioctl_blockdev_flushbuf
Add a small new helper that calls `linux.ioctl_blockdev_flushbuf`
for the block device.
2021-08-13 17:35:32 +02:00
Christian Kellner
7762f46594 util/linux: add helper for BLK_IOC_FLSBUF ioctl
Add a helper method to call `ioctl(fd, BLK_IOC_FLUSH_BUFFER, 0)`
from python. NB: the ioctl number 0x1261 is wrong on at least
alpha and sparc. A later test will use this call so we should
catch the usage of it on those platforms.
2021-08-13 17:35:32 +02:00
Christian Kellner
8014ab5f1c test/data: use LVM in fedora-ostree-image
Now that we have support for LVM convert the ostree image manifest
to use it for the root partition.
2021-08-13 12:20:54 +02:00
Christian Kellner
c1c9c550d8 test/data: include lvm2 package in v2 build root
Needed to create lvm2 volume groups and logical volumes.
2021-08-13 12:20:54 +02:00
Christian Kellner
2789080d79 test/data: label build root for f34-build-v2
Properly label the build root for the f34 build root manifest v2.
Also label the cp and tar binaries with `install_exec_t` so they
can read and copy labels unknown to the host.
2021-08-13 12:20:54 +02:00
Christian Kellner
363fb88518 device: add org.osbuild.lvm2.lv 2021-08-13 12:20:54 +02:00
Christian Kellner
23d3981d50 stages: add org.osbuild.lvm2.metadata
Add a new stage that allows the modification of LVM2 metadata,
most importantly it allows for renaming of the volume group.
It internally uses the new `utils.lvm2` module.
2021-08-13 12:20:54 +02:00
Christian Kellner
56d9dea416 stages: add org.osbuild.lvm2.create 2021-08-13 12:20:54 +02:00
Christian Kellner
45d0594b1b device: add support for parent devices
This allows device nesting, i.e. one device being opened inside another
one.
2021-08-13 12:20:54 +02:00
Christian Kellner
6ea5ce1836 test: add rename check for lvm2 module
Check we can create and successfully rename a lvm2 volume group.
2021-08-13 12:20:54 +02:00
Christian Kellner
0e31e628d7 utils: add lvm2 utility module
This module provides a `Disk` class that can be used
to read in LVM images and explore and manipulate its
metadata directly, i.e. it reads and writes the data
and headers directly. This allows one to rename an
volume group without having to involve the kernel,
which does not like to have two active LVM volume
groups with the same name.
2021-08-13 12:20:54 +02:00
Christian Kellner
5ba1807837 ci: use new ci image that includes lvm2
Use a new CI container that now includes lvm2[1].

[1] https://github.com/osbuild/containers/pull/20
2021-08-13 12:20:54 +02:00
Christian Kellner
36a5f9263a formats/v2: better error reporting for validation 2021-08-13 12:20:54 +02:00
Christian Kellner
062fc2a793 gitignore: ignore macos metadata file 2021-08-13 12:20:54 +02:00
Thomas Lavocat
1b145701f4 test: convert to pytest test_noop.py
Split the tests and add verification for access to mount when necessary.
2021-08-12 09:34:33 +02:00
Christian Kellner
78bc042bae test/run: add devices test for loopback devices
Add a new devices run time test and add basic checks for the
org.osbuild.loopback device.
2021-08-11 20:59:51 +02:00
Christian Kellner
ce312f47be devices: wire close up as rpc method
Normally `DeviceService.close` would be called when the connection
was closed on the other end. Expose that close method via RPC so
that clients can call it explicitly. This should be mostly useful
in testing.
2021-08-11 20:59:51 +02:00
Christian Kellner
bd0e5f19fd devices/loopback: option to lock the device
Implement a new `lock` option (default: False), which will lock
the device by passing `lock=True` to `LoopControl.loop_for_fd`.
The main purpose for this is to block udev from probing the device
while the stage is run.
NB: some tools might also try to lock the device and fail.
2021-08-11 20:59:51 +02:00
Christian Kellner
c1379f63ab devices/loopback: explicitly clear the fd
Explicitly clear the fd. There might be a race with udev or some
other process that still as a reference to the loop device so we
might not be able to immediately clear it. Thus wait for it with
a timeout of 30 seconds which should hopefully be enough. If the
device does not clear then any consecutive action that involves
it might not be safe to execute so we let the timeout exception
be reported to osbuild.
2021-08-11 20:59:51 +02:00
Christian Kellner
43ae79cabf devices/loopback: set partscan to false
Pass "partscan=False" to `LoopControl.loop_for_fd` to ensure that the
kernel does indeed not try to scan the partition table for the device.
2021-08-11 20:59:51 +02:00
Christian Kellner
2af964a1d5 loop: support for locking via flock
Add support for locking the loopback block device via `flock(2)`.
The main use case for this is to prevent systemd-udevd from
proben the device while any modification is done to it. See the
systemd page, https://www.freedesktop.org/software/systemd, for
more details.
Add the corresponding tests to it.
2021-08-11 20:59:51 +02:00