Bug 2158431

Summary: Virt-what does not return correct result when running inside a container using podman
Product: Red Hat Enterprise Linux 9 Reporter: Richard W.M. Jones <rjones>
Component: virt-whatAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: YongkuiGuo <yoguo>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.2CC: alessandro.valentini, palo.simo, qzhang, rjones, virt-maint, ymao, yoguo
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: virt-what-1.25-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2155233 Environment:
Last Closed: 2023-05-09 08:24:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2155233    
Bug Blocks:    

Description Richard W.M. Jones 2023-01-05 12:54:55 UTC
+++ This bug was initially created as a clone of Bug #2155233 +++

Description of problem:
When running a ubi8/ubi-init:8.7 container using podman virt-what does not detect that RHEL is running inside a container when we try to register the system using the subscription manager the system is registered as physical machine.

Version-Release number of selected component (if applicable):
This behavior does not happen on ubi8/ubi-init:8.7 container. IT happens only using virt-what 1.25

How reproducible:
run a ubi8/ubi-init:8.7 using podman and execute virt-what

Steps to Reproduce:
1.Start a ubi8/ubi-init:8.7
2.Run virt-what

Actual results:
#virt-what

returns empty output and return code 0

Expected results:
#virt-what
oci

returns oci (or other container engine) and return code 0

Additional info:
This behavior happens only using podman, the container workss properly using docker-ce.

A patch for the issue is attached, it simply adds oci among other possible options.

--- Additional comment from YongkuiGuo on 2022-12-21 02:55:43 UTC ---

Hi, Alessandro

I can not reproduce this issue with the following steps:

On my rhel8.8 host:
# podman pull ubi8/ubi-init:8.7
# podman run -it ubi8/ubi-init:8.7 /bin/bash
[root@fa4c3c1ba2a1 /]# virt-what
podman
[root@fa4c3c1ba2a1 /]# rpm -q virt-what
virt-what-1.25-1.el8.x86_64


The output of virt-what is podman. I think it's expected according to the man page.

# man virt-what
...
podman
           This is a Podman container.

Is there anything I missed?

--- Additional comment from Richard W.M. Jones on 2022-12-22 10:27:06 UTC ---

Definitely going to need exact steps to reproduce this, so setting needinfo.

--- Additional comment from Alessandro Valentini on 2022-12-29 09:21:52 UTC ---



--- Additional comment from Alessandro Valentini on 2022-12-29 09:26:41 UTC ---

We face this issue on Fedora 37 with podman, which we use as development.

Environment
# podman --version
podman version 4.3.1
# cat /etc/redhat-release
Fedora release 37 (Thirty Seven)

Steps to reproduce

Run the container:
# podman pull ubi8/ubi-init:8.7
# podman run -it ubi8/ubi-init:8.7 /bin/bash

Inside the container
[root@96d2e63f6cd9 /]# virt-what
[root@96d2e63f6cd9 /]# echo $?
0
[root@96d2e63f6cd9 /]# subscription-manager status
+-------------------------------------------+
System Status Details
+-------------------------------------------+
Overall Status: Unknown
System Purpose Status: Unknown

If we subscribe the container it is recognized as physical system.

--- Additional comment from YongkuiGuo on 2023-01-03 05:40:21 UTC ---

(In reply to Alessandro Valentini from comment #5)
> We face this issue on Fedora 37 with podman, which we use as development.
> 
> Environment
> # podman --version
> podman version 4.3.1
> # cat /etc/redhat-release
> Fedora release 37 (Thirty Seven)
> 
> Steps to reproduce
> 
> Run the container:
> # podman pull ubi8/ubi-init:8.7
> # podman run -it ubi8/ubi-init:8.7 /bin/bash
> 
> Inside the container
> [root@96d2e63f6cd9 /]# virt-what
> [root@96d2e63f6cd9 /]# echo $?
> 0
> [root@96d2e63f6cd9 /]# subscription-manager status
> +-------------------------------------------+
> System Status Details
> +-------------------------------------------+
> Overall Status: Unknown
> System Purpose Status: Unknown
> 
> If we subscribe the container it is recognized as physical system.

Thanks. I can reproduce this issue with the following steps:

On Fedora 37 host:
# cat /etc/redhat-release 
Fedora release 37 (Thirty Seven)

# podman --version
podman version 4.3.1

# podman pull ubi8/ubi-init:8.7
# podman run -it ubi8/ubi-init:8.7 /bin/bash

Inside the container:
[root@2df77826f101 /]# virt-what
[root@2df77826f101 /]# rpm -q virt-what
virt-what-1.25-1.el8.x86_64
[root@2df77826f101 /]# cat "/proc/1/environ" | tr '\000' '\n' | grep container
container=oci

After applying your patch in the attachment:
[root@2df77826f101 /]# virt-what
oci

--- Additional comment from Richard W.M. Jones on 2023-01-03 15:47:13 UTC ---



--- Additional comment from Richard W.M. Jones on 2023-01-05 12:52:46 UTC ---

Fixed upstream in:
http://git.annexia.org/?p=virt-what.git;a=commit;h=54c2ad4a764658ec8a9aadc52c749eabf1de73a0

Comment 1 YongkuiGuo 2023-01-09 12:14:57 UTC
Tested with the virt-what-1.25-2.el9.x86_64 package:

On Fedora 37 host:
# cat /etc/redhat-release 
Fedora release 37 (Thirty Seven)

# podman --version
podman version 4.3.1

# podman pull ubi9/ubi-init
# podman run -it ubi9-init /bin/bash

Inside the container:
[root@f89c6ef9e53b /]# virt-what
oci
[root@f89c6ef9e53b /]# rpm -q virt-what
virt-what-1.25-2.el9.x86_64

Comment 4 YongkuiGuo 2023-01-18 07:52:46 UTC
Verified this bug per comment 1.

Comment 6 errata-xmlrpc 2023-05-09 08:24:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt-what bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2557