linux-system-roles / rhc

Role to manage RH subscription management and Insights
https://linux-system-roles.github.io/rhc/
MIT License
10 stars 15 forks source link

feat: support again EL7 #151

Closed ptoscano closed 11 months ago

ptoscano commented 11 months ago

Enhancement: After yet another internal discussion, re-enable the support for EL7; no other changes are needed in the role.

Issue Tracker Tickets (Jira or BZ if any): https://issues.redhat.com/browse/RHEL-16976 https://issues.redhat.com/browse/RHEL-16977

ptoscano commented 11 months ago

[citest]

richm commented 11 months ago
TASK [Start Candlepin container] ***********************************************
task path: /WORKDIR/git-el77tlm7wdc/tests/tasks/setup_candlepin.yml:34
Thursday 07 December 2023  09:09:51 +0000 (0:00:00.702)       0:00:01.533 ***** 
fatal: [sut]: FAILED! => {
    "changed": false
}

STDERR:

Error: error creating container storage: the container name "candlepin" is already in use by "335a59c41a515e50435af7f2ac700071f8fadc87603771c4923047070a85c0c6". You have to remove that container to be able to reuse that name.: that name is already in use

missing some cleanup somewhere in some test?

ptoscano commented 11 months ago

[citest bad]

richm commented 11 months ago

@ptoscano maybe a difference of behavior of containers.podman.podman_container on EL7 vs. later releases? NOTE that baseos ci will reuse the same VM for each test. The rhc tests that call start_candlepin.yml do not clean up, so the candlepin container will be running after the test is complete.

For example, here is the Start Candlepin container task on rhel 9.4 ansible-core 2.16:

TASK [Start Candlepin container] ***********************************************
task path: /WORKDIR/git-el7uggnl2zl/tests/tasks/setup_candlepin.yml:34
Thursday 07 December 2023  09:08:36 +0000 (0:00:01.199)       0:00:02.284 ***** 
changed: [sut] => {
    "actions": [
        "recreated candlepin"
    ],

and here is rhel 7:

TASK [Start Candlepin container] ***********************************************
task path: /WORKDIR/git-el7ew7f9vwd/tests/tasks/setup_candlepin.yml:34
Thursday 07 December 2023  14:53:35 +0000 (0:00:00.718)       0:00:01.537 ***** 
fatal: [sut]: FAILED! => {
    "changed": false
}

STDERR:

Error: error creating container storage: the container name "candlepin" is already in use by "3ecce0017f2fd8db8eea8d6608b687d1648f3b544337bb82c1cecc3b1498edd3". You have to remove that container to be able to reuse that name.: that name is already in use

That is - on rhel9, the candlepin container is recreated and restarted, but not on rhel7. Looking at the documentation - https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_container_module.html#parameter-recreate - you could try adding recreate: true to the task.

What's odd is that the behavior on RHEL8 and 9 seems to be recreate: true by default even though the default value is false according to the documentation.

ptoscano commented 11 months ago

NOTE that baseos ci will reuse the same VM for each test.

Hm is it really the case? Looking at the output of each test that actually runs (e.g. not the Insights-related tests), it seems to install podman again, which means the guest is clean... except for the last test, i.e. tests_repositories.yml.

Regarding the behaviour of podman_container: considering that it uses state: started, then I don't understand why it tries to create the container again, rather than using the existing running container. According to the doc:

started - Asserts there is a running container matching the name and any provided configuration. If no container matches the name, a container will be created and started. Use recreate to always re-create a matching container, even if it is running. Use force_restart to force a matching container to be stopped and restarted.

ptoscano commented 11 months ago

[citest]

richm commented 11 months ago

I guess the version of podman on el7 is just too old for the module :-(

This is how I get all of the tests to pass:

@@ -32,6 +32,11 @@
         use: "{{ __rhc_is_ostree |
                  ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

+    - name: Stop and remove Candlepin container
+      containers.podman.podman_container:
+        name: candlepin
+        state: absent
+
     - name: Start Candlepin container
       containers.podman.podman_container:

testing on centos-9 now

richm commented 11 months ago

centos-9 passes - so it looks like the right way is to set the container state: absent first

ptoscano commented 11 months ago

Let try then: #153.

richm commented 11 months ago

Let try then: #153.

merged

ptoscano commented 11 months ago

[citest]