Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-2928

Error: Facter: statvfs() function failed: No such file or directory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: FACT 4.2.0
    • Component/s: None
    • Template:
    • Team:
      Night's Watch
    • Story Points:
      1
    • Sprint:
      NW - 2021-04-28, NW - 2021-05-19
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      When a mountpoint file cannot be read, or is missing, Facter would throw
      an error, without specifying what mountpoint/file has failed.
      The error is now silent, allowing Facter to continue resolving facts. The detailed error is still shown when running Facter with debug logging enabled.
      Show
      When a mountpoint file cannot be read, or is missing, Facter would throw an error, without specifying what mountpoint/file has failed. The error is now silent, allowing Facter to continue resolving facts. The detailed error is still shown when running Facter with debug logging enabled.
    • QA Risk Assessment:
      Needs Assessment

      Description

      1. puppet --version
        7.3.0

      on CentOS 7 with up2date system.

      When running puppet or gathering facts, I had the following error:

      # puppet facts show
      [...]
      Debug: Facter: Executing command: which blkid
      Error: Facter: statvfs() function failed: No such file or directory
      Debug: Facter: Executing command: /bin/cat /proc/uptime
      [...]
      

      After poking around in the vendored ruby, I figured out this error is raised in `/opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/sys-filesystem-1.3.2/lib/sys/unix/sys/filesystem.rb` on line 205.

      After instrumenting the code with:

            if statvfs(path, fs) < 0
      puts path
      puts fs.inspect
      puts caller
              raise Error, 'statvfs() function failed: ' + strerror(FFI.errno)
            end
      

      I got the following:

      # puppet facts show
      [...]
      /var/named/chroot/etc/localtime (deleted)
      #<Sys::Filesystem::Structs::Statvfs:0x00000000030e92e8>
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/resolvers/filesystem_helper.rb:20:in `read_mountpoint_stats'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:70:in `get_mount_sizes'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:54:in `block in read_mounts'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:48:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:48:in `read_mounts'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:16:in `block in post_resolve'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:16:in `fetch'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/mountpoints.rb:16:in `post_resolve'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/base_resolver.rb:26:in `block in resolve'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/base_resolver.rb:24:in `synchronize'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/resolvers/base_resolver.rb:24:in `resolve'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/facts/linux/partitions.rb:14:in `partitions'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/facts/linux/partitions.rb:9:in `call_the_resolver'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/core_fact.rb:16:in `block in create'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/benchmarking/timer.rb:18:in `measure'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/core_fact.rb:15:in `create'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/internal_fact_manager.rb:47:in `block in resolve_sequentially'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/internal_fact_manager.rb:44:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/internal_fact_manager.rb:44:in `resolve_sequentially'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/internal/internal_fact_manager.rb:12:in `resolve_facts'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact_manager.rb:24:in `resolve_facts'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:385:in `values'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli.rb:126:in `arg_parser'
      /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
      /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
      /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
      /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:116:in `invoke'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:43:in `resolve'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/facts/facter.rb:107:in `find_with_options'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/facts/facter.rb:37:in `find'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:223:in `find'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/face/facts.rb:148:in `block (3 levels) in <top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/interface/action.rb+eval[wrapper]:261:in `show'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/face_base.rb:254:in `main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:437:in `run_command'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:421:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:735:in `exit_on_fail'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:421:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:143:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      Error: Facter: statvfs() function failed: No such file or directory
      

      So I looked at my mounts:

      # mount
      [...]
      /dev/mapper/vg-root on /var/named/chroot/etc/localtime type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/named.root.key type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/named.conf type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/named.rfc1912.zones type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/rndc.key type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/named.iscdlv.key type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/protocols type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/services type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/etc/named type ext4 (rw,relatime,seclabel,data=ordered)
      /dev/mapper/vg-root on /var/named/chroot/usr/lib64/bind type ext4 (rw,relatime,seclabel,data=ordered)
      tmpfs on /var/named/chroot/run/named type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
      /dev/mapper/vg-root on /var/named/chroot/var/named type ext4 (rw,relatime,seclabel,data=ordered)
      

      Ok, this seems to be the chroot from named, what about the file:

      # ls -l /var/named/chroot/etc/localtime
      -rw-r--r--. 0 root root 1892 Nov  4 22:14 /var/named/chroot/etc/localtime
      

      Looks like the file got replaced and thus deleted.

      Restarting named-chroot, re-setup the chroot AND the file has a size again:

      # ls -l /var/named/chroot/etc/localtime
      -rw-r--r--. 3 root root 1892 Jan 26 22:55 /var/named/chroot/etc/localtime
      

      And now also the error is gone.

      So there seem to have been an update that deleted the file in the chroot and thus the service needed to be restarted.

      However facter just tries to blindly get file stats from even deleted files. So maybe this should be checked before passing it down to the filesystem lib. At least it does not seem very descriptive if the error appears.

        Attachments

          Activity

            People

            Assignee:
            dorin.pleava Dorin Pleava
            Reporter:
            duritong Peter Meier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support