Commit graph

4735 commits

Author SHA1 Message Date
Gianluca Zuccarelli
5a4d22cc6d pkg/dbjobqueue: fix enqueue/dequeue race condition
Currently there is a race condition that occurs between the
dbjobqueue enqueue and dequeue functions. Both queries make
use of the postgres `now()` timestamp function which returns
the timestamp of when the transaction started and not when
the statement is executed. The result of this is a timestamp
for a job's `started_at` field to be earlier than its
`queued_at` field causing a constraint violation.

Since the dequeue query will never be executed before the
enqueue query, changing the postgres timestamp function to
`statement_timestamp()` resolves this issue.
2022-09-14 12:44:46 +02:00
Alexander Todorov
3d6256a89d Specify additional package in blueprint for tests
Related RHBZ#2065734
2022-09-13 18:56:00 +02:00
Achilleas Koutsou
eba29c9007 test/ostree-raw: replace default ostree remote URL
The Fedora IoT Raw image sets the default remote URL to the official
Fedora IoT source at build time.  We need to replace it in our tests
with our local test repo.
2022-09-13 16:06:19 +01:00
Ondřej Budai
966049ec3c test: use firmware auto-detection with virt-install >= 4
3013889727

changed the behaviour of --boot uefi. Now, it doesn't pass the loader options
but uses firmware="efi" that uses libvirt's ability to auto-detect the correct
loader.

Therefore, for distributions that ship the new virt-install, we have to change
the --boot argument. --boot uefi should now be able to automatically set the
uefi loader correctly without passing any extra loader options. The only issue
is that CS9 has issues with secure boot and edge, so we need to disable
secure boot using a new (and arcane) syntax (the old loader arguments no
longer work):

firmware.feature0.name=secure-boot,firmware.feature0.enabled=no
(https://libvirt.org/formatdomain.html#bios-bootloader)

See the CS9 bug for secure boot issues on edge:

https://bugzilla.redhat.com/show_bug.cgi?id=2108646

Also, since --os-type is deprecated in libvirt >= 4, let's remove it.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
c373d9971d test: add --import to virt-install for UEFI
The option was already there for the BIOS case and now it (or any other
install method) is required in newer versions of virt-manager.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
7072432b0f test/ostree-raw: separate osname variable in playbook
The image_type variable in the playbook is used for the name of the
deployment, which is 'redhat' by default for RHEL and 'fedora-iot' for
Fedora.
This affects the deployment path checks, for example:
    {{ device_name  }}[/ostree/deploy/{{ image_type  }}/var]
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
b38cfc2ad6 ansible: update boot-complete.target check
In Fedora 37, the message for reaching the boot-complete.target changed
from
    Reached target Boot Completion Check
to
    Reached target boot-complete.target - Boot Completion Check
which is making the string matching test fail.

Instead of looking for message strings, check that the target's status
is good.
2022-09-13 16:06:19 +01:00
yih
9ea694ef0a test: update ansible checks for ostree mount points 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
44cd7cbc76 test: update ansible checks for ostree to match F36+ packages
Update greenboot package checks to match the new rules.

Co-Authored-By: Xiaofeng Wang <henrywangxf@me.com>
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
1d3b0a653e test: update manifests 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
2001b23610 fedora: conditional greenboot package names
Greenboot for Fedora 35 and older has several optional subpackages.
Starting with v36, there is only the 'greenboot-default-health-checks'
subpackage.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
91e581462b common: move VersionLessThan() util function
Move VersionLessThan() utility function to the common package to be
reused.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
c513f08719 test/ostree-raw: move user from commit to deployment
Instead of defining users in the ostree commits, create them during the
deployment and creation of the raw image.
Defining users in commits locks them into the base system: they can't be
removed and their password can't be changed without creating an upgrade
commit and they will always be part of the initial system.

Also, in Fedora 37, password authentication for users in commits is not
working.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
54dc7c7141 test/ostree-raw: remove mentions of installer
Leftover mentions of 'installer' from when this script was copied from
installer tests.  Replaced all mentions with raw-image.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
6cd3a34099 image: add users and groups to edge/iot raw images 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
5bc66f0665 manifest: add Users and Groups to OSTreeDeployment
Support creating users and groups during deployment of the commit to a
live image.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
40c91d7285 manifest: drop blueprint User and Group types from OS
Use the new internal types for setting users and groups in images.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
820d3d0277 users: convenience functions for converting from BP
The types currently map directly, so it's simple to convert from one to
the other.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
86d9611f98 osbuild: generator functions for UsersStage and GroupsStage
Generators for creating UsersStage and GroupsStage from the new internal
types.
These are almost identical to the existing stage option creation
functions.  Those will be removed once every use is replaced with the
new generators.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
e8c242db81 users: new package for internal User and Group types
New types that represent a User or Group for internal representation.
These are meant to be used as intermediate representations between API
or Blueprint user customizations and the final OSBuild stage options.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
6dafa36fc7 image-info: remove base loop device before analysing partitions
Instead of keeping the loop device of the base image and then opening
each partition as a loop device, remove the original loop device of the
base image and then create a loop device for each partition from the
file itself using the partition offsets.

The open_image() function is renamed to convert_image() and now only
handles converting qcow2 files to raw files if necessary.
The loop_open() context is done in analyse_image() instead, so that the
base loop device can be closed without removing the converted image.

This fixes the following issue with LVM partitions:
When the same lvm partition UUID is on two devices (e.g., /dev/loop0p4
and /dev/loop1), the 'vgchange -ay' command fails with the following
error:

  Cannot activate LVs in VG rootvg while PVs appear on duplicate
  devices.

This happens when we open the LVM partition as a separate loop device,
which we do for all partitions that we want to inspect.

NB: It's possible to restrict the vgchange command to a specific device
with --devices, but this isn't available in older versions of lvm2 (it
was introduced in 2.03.11).
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
81e11c7946 test: override hashicorp repo releasever for F37
Set $releasever to 36 when running on Fedora 37 because there is no
hashicorp repo for it yet.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
35f74027a9 Schutzfile: pin osbuild version
Requires fix in https://github.com/osbuild/osbuild/pull/1100
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
bf83bbea38 test: move greenprint and redprint functions to shared_lib.sh
Since we're sharing functions between test scripts, move greenprint(),
the most rewritten function in the history of the project, to
shared_lib.sh and source it everywhere.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
3b14828669 test: new weldr client compatibility for test scripts
- Handle the array responses from the new weldr-client (>= 35.6).
- Move the `get_build_info` function to shared_libs.sh to source and
  reuse in multiple places.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
8e24f5720d osbuild-composer-cli-tests: new weldr-client compatibility
The newest weldr-client (35.6) changed its responses to always be
arrays/lists of json objects.  The tests have been updated to parse this
structure as well.

The current workflow for parsing responses from the weldr-client is as
follows:
- If weldr-client is installed on the system:
    - Try to parse the newest structure version: array of objects, each
      with a body field.
    - If that fails, initialise the first element of the array and parse
      the response into it.
- If the weldr-client is not installed, initialise the array with one
  element and parse the response into the body field of the first
  element of the array.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
fb4309acf4 test: add repos and test manifests for Fedora 38 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
d7d098a857 CI: update terraform SHA for Fedora 37 runners 2022-09-13 16:06:19 +01:00
yih
f606e4c054 test iot-raw-image on fedora37 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0c77e4be60 manifest: rpm stage options for ostree commits
When building a fedora ostree commit, set the new ostree_booted flag in
the rpm stage and the dbpath to /usr/share/rpm
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0b3bfd0d02 osbuild: update rpm stage with new options
- db path: set alternative rpm database path [1]
- ostree-booted: create the /run/ostree-booted marker which marks an
  install as ostree.  Install-time scripts in packages use this marker
  to treat ostree installations differently.

[1] https://github.com/osbuild/osbuild/pull/666
[2] https://github.com/osbuild/osbuild/pull/1085
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
ccbf15878b manifest: add grub config for OSTreeDeployment
These are based on the official Fedora IoT Raw Image but are added to
the base OSTreeDeployment manifest.  For now, let's add them to all
ostree deployments that will use these new types and we can extract the
values to make them configurable when we need to.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
a505defad3 manifest: lock the root password for OSTreeDeployment 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
fbe8c1cb39 manifest: use new ostree mount in fstab stage for commit deployment
Use the new stage mount instead of the old stage-specific options.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
1de55c73e6 ostree: define type for handling ostree remote config
A new struct in ostree can be used to define configuration options for
the ostree remote of an image.  So far remotes were always set up with
the remote URL used to pull the commit.  Now we support setting a
different remote with extra configuration options.

This is used by the fedora-iot-raw-image to set up the remote
configuration of the final image, separately from the source of the
commit.

Test manifests updated.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0386d68db4 manifest: add ostree mount to stages in OSTreeDeployment
Stages that modify files in the ostree deployment need the sysroot
bindmount for any changes to take effect.
Adding the mount to the keymap and locale stages since they need to
modify files in /etc.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0750049739 osbuild: update org.osbuild.ostree.remotes stage
New options added to stage in osbuild [0].

[0] https://github.com/osbuild/osbuild/pull/1097
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
0ff1c3241c osbuild: add mount ostree helper method to Stage
A convenience method that adds an ostree deployment mount to any Stage.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
4a68df45c7 osbuild: add ostree.deployment mount type
New mount type added: org.osbuild.ostree.deployment.

Adding this to a stage will setup all needed bind mounts so that a given
`tree` will look like an active OSTree deployment, very much as OSTree
does during early boot.

This is often necessary when making changes to files in /etc for an
ostree image.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
7246f8fdd5 osbuild: fix base Mount struct properties
Source and Target are not required -> omitempty
Options is of type MountOptions which is an interface, so we don't need
to make it a pointer.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
76031d4104 manifest: add OSTreeDeployment config options
Adding support for config options to OSTreeDeployment that are required
by the IoT raw image:
- Kernel command line options
- Keyboard layout
- Locale

Test manifests updated.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
ce7b251b54 platform: fix error message for invalid image format 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
21d2c78f20 manifest: remove s390x case from OSTreeDeployment
Not supported.  No need to switch.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
901b3a5da9 fedora: add platform packages to RawOSTreeImage build root
Include the platform packages when getting the build packages for the
RawOSTreeImage.
rpm-ostree is explicitly added for this image type.
dracut-config-generic and efibootmgr are temporarily added here, but we
should define a platform that includes them instead (some cleanup
required in general).
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
b85fe8109c manifest: add the platform configuration to the RawOSTreeImage 2022-09-13 16:06:19 +01:00
Achilleas Koutsou
c38c7ad126 disk: add packages for LUKS containers
Add the packages required for LUKS containers to the build root when
getting the list of packages from the PartitionTable.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
eb731e031d test: generate new manifests
Add new image type to format request map and generate manifests.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
f32e653315 store: trim compat string map
The map is meant to maintain compatibility with changes in image type
names.  Most entries however map to themselves.  It's redundant to keep
updating this map with every new image type name and map it to itself.
Instead, check the map for a compat string and if one doesn't exist,
return the original.

Conversely, when the inverse lookup is performed, first check if the
compat string is a valid image type name and only iterate the map if
it's not.

Now we don't need to update the map every time we introduce a new image
type, unless we need to map an old name to a new one.
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
c6843db6b4 fedora: add the iot-raw-image to x86 and aarch64
Add the new image type to the list in each architecture and update
tests.

Ignore ostree raw images in Kernel count test in distro_test_common:

Edge and IoT raw images don't need a kernel specified in their OS
pipeline.  The kernel (and the OS in general, including all packages)
come from the commit that is pulled and deployed in the image.

This test passes on RHEL (for edge-raw-image types) because the
blueprint defaults to returning the main kernel, but this isn't
necessary and is likely to change in the near future.

Co-Authored-By: Ondřej Budai <ondrej@budai.cz>
2022-09-13 16:06:19 +01:00
Achilleas Koutsou
74a196e427 image: complete OSTreeRawImage.InstantiateManifest()
Create all the necessary pipelines for the OSTreeRawImage and return the
artifact from the XZ pipeline.

Co-Authored-By: Ondřej Budai <ondrej@budai.cz>
2022-09-13 16:06:19 +01:00