Skip to content

feat: Support this role in container builds#212

Merged
martinpitt merged 4 commits intolinux-system-roles:mainfrom
martinpitt:bootc-container-test
May 5, 2025
Merged

feat: Support this role in container builds#212
martinpitt merged 4 commits intolinux-system-roles:mainfrom
martinpitt:bootc-container-test

Conversation

@martinpitt
Copy link
Copy Markdown
Collaborator

@martinpitt martinpitt commented Apr 24, 2025

Feature: Support running the cockpit role during container builds.

Reason: This is particularly useful for building bootc derivative OSes.

Result: These flags enable running the bootc container scenarios in CI, which ensures that the role works in buildah build environment. This allows us to officially support this role for image mode builds.

Do not enable the role for system containers (the container) flag. That currently fails due to SELinux not working properly there, and needs to be looked at separately if desired.

https://issues.redhat.com/browse/RHEL-88423

Skip the certmonger tests for non-booted environments, as certmonger requires a running system by design (these are a case for running the role in a deployed system). Also skip the firewall managed related checks for the time being, until the firewall role works during container builds (https://issues.redhat.com/browse/RHEL-88425).

@martinpitt
Copy link
Copy Markdown
Collaborator Author

martinpitt commented Apr 24, 2025

The initial run failed due to a runcontainer.sh bug, fixed in linux-system-roles/tox-lsr#189. Re-running. Now it locally fails in the "right" way:

TASK [linux-system-roles.cockpit : Ensure Cockpit Web Console is started/stopped and enabled/disabled] ***********************************
fatal: [sut]: FAILED! => {"changed": false, "msg": "Service is in unknown state", "status": {}}

This now happens in CI as well.

@martinpitt
Copy link
Copy Markdown
Collaborator Author

In classic rpm mode, tests_port2 fails without a "fatal:". This makes the log harder to evaluate.

It fails due to

TASK [fedora.linux_system_roles.selinux : Set an SELinux label on a port] ****************************************************************
task path: /var/home/martin/upstream/lsr/cockpit/.tox/ansible_collections/fedora/linux_system_roles/roles/selinux/tasks/main.yml:87
redirecting (type: connection) ansible.builtin.podman to containers.podman.podman
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: SELinux policy is not managed or store cannot be accessed.
failed: [sut] (item={'ports': 443, 'proto': 'tcp', 'setype': 'websm_port_t', 'state': 'present', 'local': 'true'}) => {"__selinux_item": {"local": "true", "ports": 443, "proto": "tcp", "setype": "websm_port_t", "state": "present"}, "ansible_loop_var": "__selinux_item", "changed": false, "msg": "ValueError: SELinux policy is not managed or store cannot be accessed.\n"}

I fixed that in an extra commit here, I sent it to linux-system-roles/.github#103 as well.

Beyond that I'll ignore that error. Running the classic rpm OSes in containers is nice while I develop runcontainer.sh, to ensure I don't break anything existing. But it's more of a "nice to have" by itself, so at the moment I think I won't actually land these in production, and concentrate on the bootc ones.

@martinpitt martinpitt force-pushed the bootc-container-test branch from cf7e00f to ef73805 Compare April 24, 2025 10:59
@martinpitt martinpitt changed the title WIP: ci: Add container integration test for rpm and bootc WIP: ci: Add container integration test for rpm and bootc; fix: Skip runtime operations in non-systemd environments Apr 24, 2025
@martinpitt
Copy link
Copy Markdown
Collaborator Author

martinpitt commented Apr 24, 2025

Better! Some tests pass. packages_full and port fail in the firewalld rule, so I suppose that will be my next target. The certificate tests still need work.

Update: I added a tests::booted tag for skipping tests in a buildah environment, and updated linux-system-roles/tox-lsr#189 accordingly.

@martinpitt martinpitt force-pushed the bootc-container-test branch from ef73805 to 4d9f357 Compare April 24, 2025 12:28
@martinpitt martinpitt force-pushed the bootc-container-test branch from 4d9f357 to 4d18ffc Compare April 25, 2025 05:03
@martinpitt martinpitt force-pushed the bootc-container-test branch 3 times, most recently from 366a6a6 to 5e77f17 Compare April 25, 2025 13:58
@martinpitt martinpitt force-pushed the bootc-container-test branch from 5e77f17 to 07e9a10 Compare May 5, 2025 07:11
@martinpitt martinpitt changed the title WIP: ci: Add container integration test for rpm and bootc; fix: Skip runtime operations in non-systemd environments feat: Support this role in container builds May 5, 2025
@martinpitt martinpitt force-pushed the bootc-container-test branch from 07e9a10 to 439e11c Compare May 5, 2025 07:12
@martinpitt martinpitt marked this pull request as ready for review May 5, 2025 07:13
@martinpitt martinpitt marked this pull request as draft May 5, 2025 07:34
martinpitt added 4 commits May 5, 2025 09:35
Generalize qemu-kvm-integration-tests.yml to run some "container-*"
environments as well. For "classic rpm" OSes that does not give us too
much beyond making sure that the container tests actually work
(developers might use them locally, after all). 90% of the logic (setup,
compatibility check, status updates, etc.) is the same, so it's not
economic to duplicate all of that into a new workflow.

Add Fedora/CentOS *-bootc scenarios: These check that our role works
during a bootc container build, without any systemd, processes, or other
runtime environment. tox-lsr added support for this in
linux-system-roles/tox-lsr#188.

However, as most roles don't currently work in that environment,
introduce and check a new `containerbuild` tag in meta/main.yml. We'll
add this to roles as we adjust them.

Similarly, as not every role works in a running container (e.g. due to
assuming SELinux), check a new `container` tag in their tests.

See https://issues.redhat.com/browse/RHEL-78157
Cause: Both the actual role and the tests were previously assuming that
the system was booted with systemd and could run services. But this is
not the case when running the role during container builds.

Consequence: The role did not work during bootc container builds.

Fix: Detect if the system is booted (with systemd), and skip all runtime
operations and checks if not.

Result: The role now works during container builds.

Add a config file only test to tests_port.yml to cover container runs,
as all the other assertions depend on cockpit running. Skip the
certmonger tests for non-booted environments, as certmonger requires a
running system by design (these are a case for running the role in a
deployed system). Also skip the firewall managed related checks for the
time being, until the firewall role works during container builds
(https://issues.redhat.com/browse/RHEL-88425).

https://issues.redhat.com/browse/RHEL-88423
Feature: Support running the cockpit role during container builds.

Reason: This is particularly useful for building bootc derivative OSes.

Result: These flags enable running the bootc container scenarios in CI,
which ensures that the role works in buildah build environment. This
allows us to officially support this role for image mode builds.

Do *not* enable the role for system containers (the `container`) flag.
That currently fails due to SELinux not working properly there, and
needs to be looked at separately if desired.

https://issues.redhat.com/browse/RHEL-88423
@martinpitt martinpitt force-pushed the bootc-container-test branch from 439e11c to 8b319a5 Compare May 5, 2025 07:35
@martinpitt martinpitt marked this pull request as ready for review May 5, 2025 07:54
@martinpitt martinpitt requested a review from richm May 5, 2025 07:54
@martinpitt martinpitt merged commit 892e272 into linux-system-roles:main May 5, 2025
20 checks passed
@martinpitt martinpitt deleted the bootc-container-test branch May 5, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants