chef / ohai

Ohai profiles your system and emits JSON
https://docs.chef.io/ohai.html
Apache License 2.0
681 stars 452 forks source link

Filesystem plugin fails when btrfs partition does not have sysfs files #1830

Closed dafyddcrosby closed 4 weeks ago

dafyddcrosby commented 1 month ago

Description

There are situations where a btrfs partition may not have a directory in /sys/fs/btrfs (which is expected), so we should check for the directory before trying to read any files in it.

Ohai Version

18.5.0

Platform Version

CentOS 9

Ohai Output

Requires ohai -l trace to track down:

TRACE: Plugin Filesystem threw #<Errno::ENOENT: No such file or directory @ rb_sysopen - /sys/fs/btrfs/SANITIZED_UUID/allocation/data/total_bytes>
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/chef-utils-18.5.0/lib/chef-utils/dsl/train_helpers.rb:62:in `initialize'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/chef-utils-18.5.0/lib/chef-utils/dsl/train_helpers.rb:62:in `open'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/chef-utils-18.5.0/lib/chef-utils/dsl/train_helpers.rb:62:in `file_open'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/chef-utils-18.5.0/lib/chef-utils/dsl/train_helpers.rb:68:in `file_read'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:290:in `block (2 levels) in collect_btrfs_data'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:289:in `each'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:289:in `block in collect_btrfs_data'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:279:in `each'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:279:in `collect_btrfs_data'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:423:in `block (3 levels) in <main>'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:421:in `each'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/plugins/filesystem.rb:421:in `block (2 levels) in <main>'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/dsl/plugin/versionvii.rb:137:in `instance_eval'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/dsl/plugin/versionvii.rb:137:in `run_plugin'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/dsl/plugin.rb:115:in `run'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/dsl/plugin.rb:200:in `safe_run'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/runner.rb:99:in `run_v7_plugin'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/runner.rb:57:in `block in run_plugin'
TRACE: /opt/chef/embedded/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/runner.rb:50:in `run_plugin'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/system.rb:131:in `block in run_plugins'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/system.rb:130:in `each'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/system.rb:130:in `run_plugins'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/system.rb:105:in `all_plugins'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/application.rb:147:in `run_application'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/application.rb:92:in `block in run'
TRACE: /opt/chef/embedded/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/lib/ohai/application.rb:90:in `run'
TRACE: /opt/chef/embedded/lib/ruby/gems/3.1.0/gems/ohai-18.1.11/bin/ohai:25:in `<top (required)>'