puppetlabs / facter

Collect and display system facts
https://puppet.com/open-source/#osp
Apache License 2.0
621 stars 498 forks source link

Resolving the `virtual` fact on FreeBSD produce warning #2742

Open smortex opened 3 months ago

smortex commented 3 months ago

Describe the Bug

root@puppet:~ # facter --version
4.8.0
root@puppet:~ # facter virtual
[2024-07-30 09:30:11.629353 ] WARN Facter::Resolvers::Containers - Unable to getenv for pid 1, 'uninitialized constant Facter::Util::Linux' 
jail

Expected Behavior

root@puppet:~ # facter virtual
jail

No warning about something that looks suspiciously Linux-related :-)

Steps to Reproduce

Run facter 4.8.0 on a FreeBSD system

Environment

Additional Context

The problem is incidentally introduced by #2574 where Linux specific code is added to lib/facter/resolvers/containers.rb, a file which based on its name is supposed to be platform-agnostic.

After further investigation, this file is really platform-specific and not in the right directory. A few other files have the same problem. I will open two PR to:

  1. Fix files located in the wrong directory to make it explicit if they are specific to a platform or not: #2743;
  2. Change the way the virtual fact is resolved on FreeBSD to stop the warning from being produced: #2744.
bibi21000 commented 3 months ago

same problem here in a lxc container with Ubuntu 22.04 and Ubuntu 20.04

Warning: Facter: Container runtime, 'lxc', is unsupported, setting to, 'container_other'

joshcooper commented 3 months ago

@bibi21000 you're running into https://github.com/puppetlabs/facter/issues/2737

bibi21000 commented 3 months ago

@joshcooper ty for information

buzzdeee commented 2 months ago

same here on OpenBSD with facter 4.8.0:

facter33 virtual [2024-08-19 08:04:38.279003 ] WARN Facter::Resolvers::Containers - Unable to getenv for pid 1, 'uninitialized constant Facter::Util::Linux' physical