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

Aggregate facts are broken

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • FACT 4.0.48
    • FACT 4.0.49
    • None
    • None
    • Needs Assessment
    • Bug Fix
    • Fixed a bug where facter was breaking when trying to add a debug message for the location where an aggregate facts is resolved from. This only happed for aggregate facts that return an array or hash, without having an aggregate block call.
    • Needs Assessment

    Description

      Commit d48c237c added debugging but broke aggregate fact handling. To reproduce:

      $ mkdir facts
      $ cat > facts/agg.rb <<EOF
      Facter.add(:foo, :type => :aggregate) do
          chunk :first do
              ['foo']
          end
       
          chunk :second do
              ['bar']
          end
      end
      END
      $ bx facter --custom-dir `pwd`/facts foo
      bundler: failed to load command: facter (/Users/josh/work/facter/.bundle/ruby/2.5.0/bin/facter)
      Traceback (most recent call last):
      	39: from /usr/local/opt/rbenv/versions/2.5.8/bin/bundle:23:in `<main>'
              ...
      	16: from /Users/josh/work/facter/lib/facter/framework/cli/cli.rb:114:in `query'
      	15: from /Users/josh/work/facter/lib/facter.rb:414:in `to_user_output'
      	14: from /Users/josh/work/facter/lib/facter.rb:473:in `resolve_facts_for_user_query'
      	13: from /Users/josh/work/facter/lib/facter/framework/core/fact_manager.rb:25:in `resolve_facts'
      	12: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:7:in `resolve_facts'
      	11: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:19:in `external_facts'
      	10: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:19:in `each'
      	 9: from /Users/josh/work/facter/lib/facter/framework/core/fact/external/external_fact_manager.rb:21:in `block in external_facts'
      	 8: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:121:in `value'
      	 7: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:167:in `searching'
      	 6: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:124:in `block in value'
      	 5: from /Users/josh/work/facter/lib/facter/framework/benchmarking/timer.rb:18:in `measure'
      	 4: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:125:in `block (2 levels) in value'
      	 3: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:199:in `find_first_real_value'
      	 2: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:199:in `each'
      	 1: from /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:208:in `block in find_first_real_value'
      /Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:217:in `log_fact_path': undefined method `source_location' for nil:NilClass (NoMethodError)
      

      Also I noticed that 4.x facter does not accept a relative custom dir:

      $ bx facter --custom-dir facts foo
      Excluding facts from search path. Fact file paths must be an absolute directory
      

      But 3.x facter does, is the facter 4 behavior intentional?

      [root@aural-heater ~]# facter --custom-dir facts/ foo
      [
        "foo",
        "bar"
      ]
      

      It took me a little while to reproduce the problem because the docs for aggregate facts show each chunk returning a string, but it needs to be an array or hash:

      Attachments

        Activity

          People

            gheorghe.popescu Gheorghe Popescu
            josh Josh Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support