Bug #2242

Simplify OpenVZ detection, based on /proc/self/status

Added by Christian Hofstaedtler almost 3 years ago. Updated 3 months ago.

Status:Closed Start date:05/12/2009
Priority:Normal Due date:
Assignee:Ben Hughes % Done:

0%

Category:library
Target version:1.6.2
Keywords: Affected Facter version:
Branch:https://github.com/barn/facter/tree/ticket%2F1.5.9%2F6728-facter_improperly_detects_openvzve_on_cloudlinux_systems
Votes: 0

Description

virtual.rb currently does lot’s of things to detect different virtualization environments. As some of them represent their state in /proc/self/status, it would be cool if this could be unified. Paul also wanted to create tests for virtual.rb, based on /proc/self/status.

OpenVZ states in /proc/self/status:

envID == 0 -> openvzhn
envID present but > 0 -> openvzve

f74155e7e.txt - /proc/self/status from an openvzhn (814 Bytes) Christian Hofstaedtler, 05/12/2009 07:43 am


Related issues

related to Facter - Bug #6728: Facter improperly detects openvzve on CloudLinux systems Closed 03/16/2011

History

Updated by James Turnbull over 2 years ago

  • Status changed from Unreviewed to Accepted

Updated by Paul Nasrat over 2 years ago

TODO after #2292 merged

Updated by Benedikt Böhm over 2 years ago

isn’t the current detection, based on the fact that /proc/vz/version exists, a lot simpler than doing regex and ==/> comparison?

Updated by Christian Hofstaedtler over 2 years ago

Benedikt Böhm wrote:

isn’t the current detection, based on the fact that /proc/vz/version exists, a lot simpler than doing regex and ==/> comparison?

Maybe. But /proc/self/status is read anyway already in the virtual fact, so reading more files is pointless.

Updated by Matthew Cluver over 1 year ago

Christian Hofstaedtler wrote:

Benedikt Böhm wrote:

isn’t the current detection, based on the fact that /proc/vz/version exists, a lot simpler than doing regex and ==/> comparison?

Maybe. But /proc/self/status is read anyway already in the virtual fact, so reading more files is pointless.

The problem is that it’s not reliable that way, all that has to happen is a file being put into that directory to break the logic.

This is solid and all in one nice little statement:

(%x[cat /proc/self/status | awk ‘$1 == “envID:” {print $2}’]) ? result = “openvzhn” : result =“openvzve”

Updated by Rein Henrichs over 1 year ago

  • Status changed from Accepted to Needs Decision

Thanks for giving the ticket some attention, Matthew. Not using OpenVZ makes it difficult for me to assess the proposed solution. Anyone?

Updated by James Turnbull 10 months ago

  • Assignee set to Nigel Kersten

Updated by Nigel Kersten 10 months ago

I’m happy to follow the recommendation of anyone who uses OpenVZ a lot. Anyone?

Updated by Christian Hofstaedtler 10 months ago

What I said in the original report still holds true. The point of this was that virtual.rb already gets a lot of info out of /proc/self/status, so OpenVZ detection can also use this. Obviously this is only useful if virtual.rb would read /proc/self/status once, and then do all the testing against the file contents in memory. Else this will still fork a lot more than needed and therefore be unnecessarily slow.

Updated by Nigel Kersten 10 months ago

  • Status changed from Needs Decision to Accepted
  • Assignee deleted (Nigel Kersten)

Sounds reasonable. I’d like to see the patch written by someone who knows it well though.

Updated by Daniel Pittman 10 months ago

The information is technically correct, from someone who knows OpenVZ well. :)

What I am not certain of is what, if any, information the LXC-based containers expose in this regard. I assume they don’t bundle the various namespace segregations, so they don’t expose a single “environment ID” like value, but would want confirmation from someone who knows that part of the Linux kernel code.

Updated by Ben Hughes 8 months ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • Assignee set to Ben Hughes

Updated by Michael Stahnke 8 months ago

  • Target version changed from 1.6.0 to 1.6.x

If this is in a topic branch, where is it?

Updated by James Turnbull 6 months ago

  • Category set to library

Updated by Nigel Kersten 5 months ago

Ben, I think we’re missing the actual branch this is in?

Updated by Ben Hughes 5 months ago

https://github.com/barn/facter/tree/ticket%2F1.5.9%2F6728-facter_improperly_detects_openvzve_on_cloudlinux_systems

Updated by James Turnbull 5 months ago

  • Branch set to https://github.com/barn/facter/tree/ticket%2F1.5.9%2F6728-facter_improperly_detects_openvzve_on_cloudlinux_systems

Updated by Adrien Thebo 4 months ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

Merged in commit:2512ff0dabb7b107b7af89aa015b7653d5de9e13

Updated by Ken Barber 3 months ago

  • Target version changed from 1.6.x to 1.6.2

Updated by Ken Barber 3 months ago

  • Status changed from Merged - Pending Release to Closed

Also available in: Atom PDF