Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

facter fail on vservers after upgrade to puppet7 (facter 4.6.1) #2695

Open
aqueos opened this issue Mar 27, 2024 · 6 comments
Open

facter fail on vservers after upgrade to puppet7 (facter 4.6.1) #2695

aqueos opened this issue Mar 27, 2024 · 6 comments
Labels
bug Something isn't working triaged Jira issue has been created for this

Comments

@aqueos
Copy link

aqueos commented Mar 27, 2024

Describe the Bug

After upgrading puppet 6.x to puppet 7.X facter failed in various ways:


Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ
Error: Facter: Resolving fact cores_per_socket, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
Error: Facter: Resolving fact threads_per_core, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
Error: Facter: Permission denied @ rb_sysopen - /proc/1/environ

Expected Behavior

the puppet working on this container type (vservers) worked perfectly for many years but this upgrade it seems facter is a lot more brittle and need some files to be here even in container and chroot :)

Steps to Reproduce

enter a vserver container, launch facter 4.6.1

[2024-03-27 09:56:19.163808 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.163908 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.163953 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.163995 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.164036 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.164083 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.164126 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.164166 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 

[2024-03-27 09:56:19.167729 ] ERROR Facter::Resolvers::Linux::Lscpu - Resolving fact cores_per_socket, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core' 
[2024-03-27 09:56:19.176157 ] ERROR Facter::Resolvers::Linux::Lscpu - Resolving fact threads_per_core, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core' 

[2024-03-27 09:56:19.176304 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.176361 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.176469 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.176542 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.179346 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.179404 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 

[2024-03-27 09:56:19.199505 ] ERROR Facter::InternalFactManager - No such file or directory @ dir_initialize - /sys/block 
[2024-03-27 09:56:19.199539 ] ERROR Facter::InternalFactManager - No such file or directory @ dir_initialize - /sys/block 
[2024-03-27 09:56:19.199559 ] ERROR Facter::InternalFactManager - No such file or directory @ dir_initialize - /sys/block 
[2024-03-27 09:56:19.199586 ] ERROR Facter::InternalFactManager - No such file or directory @ dir_initialize - /sys/block 
[2024-03-27 09:56:19.199603 ] ERROR Facter::InternalFactManager - No such file or directory @ dir_initialize - /sys/block 

[2024-03-27 09:56:19.211224 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.247188 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.291965 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 
[2024-03-27 09:56:19.293036 ] ERROR Facter::InternalFactManager - Permission denied @ rb_sysopen - /proc/1/environ 

Environment

  • Version puppet agent and server 7
  • Platform ubuntu jammy for server, debian 10/11 for containers

Additional Context

the issue arrived after upgrading from puppet 6.x to 7.29

the first error seems to be in resolvers/containers.rb see farther for why.
the second one is lscpu in a container returning an error because the containers have an empty /sys directory

[~]: lscpu
lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory

the third is access to /sys/block as there is no /sys/block file at all in resolvers/partitions.rb and resolvers/disks.rb, i think a little check could be missing for this case ?

the first is generated because the container system show the /proc/1/environ file as here and readable but it block the access, so it is readable but not really. On previous factor it was not an issue this was skipped for vserver container but not here.

The second error is that lscpu is using /sys that is not present in the container (or chroot) and therefor the facts linked to it fail in error, /proc/cpuinfo is here and readable but not /sys/.

best regards,
Ghislain.

@aqueos aqueos added the bug Something isn't working label Mar 27, 2024
@cthorn42 cthorn42 added the triaged Jira issue has been created for this label Apr 23, 2024
@cthorn42
Copy link
Collaborator

@aqueos thanks for the bug report, we're looking into this.

Copy link

Migrated issue to FACT-3464

@joshcooper
Copy link
Contributor

@aqueos can you try a more recent version of facter? Please list which facts are resolving differently and their before and after values. Also can you try installing virt-what 1.25 as using your package manager and see if that resolves the issue?

@aqueos
Copy link
Author

aqueos commented Aug 4, 2024

hi,

i tried, the facter version is the one in the puppet7 packages.

VSGUEST:root@whmcs02:[~]: facter -v
4.8.0
VSGUEST:root@whmcs02:[~]: puppet facts facterversion
{
  "facterversion": "4.8.0"
}
VSGUEST:root@whmcs02:[~]: puppet facts |grep facter
Warning: Facter: Unable to getenv for pid 1, 'Permission denied @ rb_sysopen - /proc/1/environ'
Warning: Facter: Unable to getenv for pid 1, 'Permission denied @ rb_sysopen - /proc/1/environ'
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: Resolving fact cores_per_socket, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
Error: Facter: Resolving fact threads_per_core, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
  "facterversion": "4.8.0",
VSGUEST:root@whmcs02:[~]: facter os
{
  architecture => "amd64",
  distro => {
    codename => "bullseye",
    description => "Debian GNU/Linux 11 (bullseye)",
    id => "Debian",
    release => {
      full => "11.10",
      major => "11",
      minor => "10"
    }
  },

installation do not change the issue:


VSGUEST:root@whmcs02:[~]: virt-what --version
1.19
VSGUEST:root@whmcs02:[~]: virt-what 
cat: /proc/1/environ: Permission denied
VSGUEST:root@whmcs02:[~]: puppet facts |grep facter
Warning: Facter: Unable to getenv for pid 1, 'Permission denied @ rb_sysopen - /proc/1/environ'
Warning: Facter: Unable to getenv for pid 1, 'Permission denied @ rb_sysopen - /proc/1/environ'
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: Resolving fact cores_per_socket, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
Error: Facter: Resolving fact threads_per_core, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
  "facterversion": "4.8.0",

@joshcooper
Copy link
Contributor

joshcooper commented Aug 5, 2024

ah interesting, so:

Warning: Facter: Unable to getenv for pid 1, 'Permission denied @ rb_sysopen - /proc/1/environ'

Is coming from virt-what 1.19 and then facter falls back to other resolution methods. And facter fails with:

Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: No such file or directory @ dir_initialize - /sys/block
Error: Facter: Resolving fact cores_per_socket, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'
Error: Facter: Resolving fact threads_per_core, but got undefined method `split' for nil:NilClass at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/processors_lscpu.rb:34:in `build_threads_per_core'

Could you try running virt-what that's installed in the puppet-agent?

/opt/puppetlabs/puppet/bin/virt-what --version
/opt/puppetlabs/puppet/bin/virt-what

@aqueos
Copy link
Author

aqueos commented Aug 6, 2024

Here it is:

[~]: /opt/puppetlabs/puppet/bin/virt-what --version
1.22
[~]: /opt/puppetlabs/puppet/bin/virt-what
cat: /proc/1/environ: Permission denied
cat: /proc/1/environ: Permission denied

as you know perhaps vserver containers do not let you access thoses files. It worked fine on older facter versions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Jira issue has been created for this
Projects
None yet
Development

No branches or pull requests

3 participants