Description
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.