Assertion error in RootwrapTestCase.test_KillFilter within py39 / rhel9 OSP 18 job

Bug #2037383 reported by Herve Beraud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.rootwrap
In Progress
Undecided
Unassigned

Bug Description

we observe a failure in RPM job executed as part of Component CI for OSP 18

```
oslo_rootwrap.tests.test_rootwrap.RootwrapTestCase.test_KillFilter
------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/home/zuul/src/code.engineering.redhat.com/oslo.rootwrap/oslo_rootwrap/tests/test_rootwrap.py", line 211, in test_KillFilter
    self.assertTrue(f.match(usercmd) or f2.match(usercmd))

      File "/usr/lib64/python3.9/unittest/case.py", line 688, in assertTrue
    raise self.failureException(msg)

    AssertionError: False is not true
```

In the broken unit test described here, for the needs of the unit test, we launch the `cat` command in a python subprocess [1]. This subprocess allow us to retrieve the pid related to the `cat` command [2].
The match function of the KillFilter class is designed to see if the passed argument match the command to kill [3].

This test is based on the command related to the pid, however [4], in this case, the returned command for the pid of `cat` is `/usr/bin/coreutils`, rather than `/bin/cat` or `/usr/bin/cat` this is why the match function return false and then the test fails.

I think this is due to the way the rhel 9 containers are builts. As the call of the python os.readlink function [5] against `/proc/<pid-of-cat>/exe` return the path of the symbolic link points of the given pid, in this case it correspond to `coreutils`. This is why the string doesn't match and the test fails.

From an oslo POV the code of oslo.rootwrap looks correct, and until now it never caused us issues.

I'll check if we can extend the test case to see if I can append coreutils at the list of tested values, but I wonder why this have suddently changed.

[1] https://opendev.org/openstack/oslo.rootwrap/src/branch/master/oslo_rootwrap/tests/test_rootwrap.py#L197
[2] https://opendev.org/openstack/oslo.rootwrap/src/branch/master/oslo_rootwrap/tests/test_rootwrap.py#L209
[3] https://opendev.org/openstack/oslo.rootwrap/src/branch/master/oslo_rootwrap/filters.py#L272
[4] https://opendev.org/openstack/oslo.rootwrap/src/branch/master/oslo_rootwrap/filters.py#L211
[5] https://docs.python.org/3.9/library/os.html#os.readlink

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.rootwrap (master)
Changed in oslo.rootwrap:
status: New → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.