Bug 2155233

Summary: Virt-what does not return correct result when running inside a container using podman
Product: Red Hat Enterprise Linux 8 Reporter: Alessandro Valentini <alessandro.valentini>
Component: virt-whatAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: YongkuiGuo <yoguo>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.7CC: palo.simo, qzhang, rjones, virt-maint, ymao
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: virt-what-1.25-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2158431 (view as bug list) Environment:
Last Closed: 2023-05-16 09:11:18 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:    
Bug Blocks: 2158431    
Attachments:
Description Flags
Add oci environment to virt-what cases
none
container subscribed as physical system none

Description Alessandro Valentini 2022-12-20 13:19:48 UTC
Created attachment 1933763 [details]
Add oci environment to virt-what cases

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.

Comment 1 YongkuiGuo 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?

Comment 2 Richard W.M. Jones 2022-12-22 10:27:06 UTC
Definitely going to need exact steps to reproduce this, so setting needinfo.

Comment 4 Alessandro Valentini 2022-12-29 09:21:52 UTC
Created attachment 1934858 [details]
container subscribed as physical system

Comment 5 Alessandro Valentini 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.

Comment 6 YongkuiGuo 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

Comment 7 Richard W.M. Jones 2023-01-03 15:47:13 UTC
*** Bug 2077879 has been marked as a duplicate of this bug. ***

Comment 9 YongkuiGuo 2023-01-09 11:58:07 UTC
Tested with the virt-what-1.25-2.el8.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 ubi8/ubi-init:8.7
# podman run -it ubi8/ubi-init:8.7 /bin/bash

Inside the container:
[root@1919a2d450bc ~]# virt-what
oci
[root@1919a2d450bc ~]# rpm -q virt-what
virt-what-1.25-2.el8.x86_64

Comment 14 YongkuiGuo 2023-01-18 07:36:08 UTC
Verified this bug per comment 9.

Comment 18 errata-xmlrpc 2023-05-16 09:11:18 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:3033