Fix Queue Manager in podman containerised env

When commands such as ``nova-manage`` are invoked via a podman call,
e.g. ``podman exec nova_conductor nova-manage ...``, the process group
ID assigned is 0. This break the check of start time since system boot
as ``/proc/0`` does not exist.

Fix this behaviour by instead using the process ID to look up the start
time since system boot.

Closes-Bug: #2095178
Change-Id: Ie89783d1e8a2891bfbb5b516eff08ed694353d6d
This commit is contained in:
Matt Crees
2025-01-17 15:09:10 +00:00
parent fe149aefb7
commit 9043d6583e
2 changed files with 13 additions and 1 deletions

View File

@@ -70,7 +70,13 @@ class QManager:
# parse start time (in jiffies) since system boot
#
# https://www.man7.org/linux/man-pages//man5/proc_pid_stat.5.html
with open(f'/proc/{self.pg}/stat') as f:
#
# We fallback to process id here when process group id is 0, as /proc/0
# does not exist. This is only hit in an edge case with the crun
# container runtime (default for podman), see issue for more details:
# https://github.com/containers/crun/issues/1642
proc_id = self.pg if self.pg != 0 else os.getpid()
with open(f'/proc/{proc_id}/stat') as f:
self.start_time = int(f.read().split()[21])
def get(self):

View File

@@ -0,0 +1,6 @@
---
fixes:
- |
Fixes a bug where calling some OpenStack utilites, such as ``nova-manage``,
within podman containers would fail when using Queue Manager.
`LP#2091703 <https://bugs.launchpad.net/oslo.messaging/+bug/2095178>`__