Issue #14674 has been updated by Alex Harvey.

Status changed from Accepted to In Topic Branch Pending Review
Branch set to https://github.com/alexharv074/facter/tree/1.6.x

I have submitted a patch in line with my understanding of what Josh Cooper has 
proposed.
----------------------------------------
Bug #14674: Facter processor fact executes commands on platforms that it 
shouldn't
https://projects.puppetlabs.com/issues/14674#change-71120

Author: Josh Cooper
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: Alex Harvey
Category: library
Target version: 
Keywords: 
Branch: https://github.com/alexharv074/facter/tree/1.6.x
Affected Facter version: 


When evaluating the processor fact, it calls the following on all platforms:

<pre>
## We have to enumerate these outside a Facter.add block to get the processorN 
descriptions iteratively
## (but we need them inside the Facter.add block above for tests on 
processorcount to work)
processor_list = Facter::Util::Processor.enum_cpuinfo
processor_list_aix = Facter::Util::Processor.enum_lsdev
processor_list_sunos = Facter::Util::Processor.enum_kstat
</pre>

It should only call these methods on the appropriate platform, and it should 
only call them when needed (if processor_list is empty).

This is causing build failures when running Windows specific processor spec 
test on a Linux host. Because although we stub the kernel fact, the processor 
fact sees that /proc/cpuinfo exists, and tries to load the architecture fact, 
which tries to load the hardwaremodel fact, which on Windows was recently 
changed to use WMI instead of using RbConfig.

This appears to be new behavior as a result of 
<https://github.com/puppetlabs/facter/commit/328ff7584e0353a609cba6d9fa08c0b6a26be664>,
 which used to conditionally execute the commands depending on the value of the 
kernel fact.

This is the build failure:

<pre>
1) Processor facts on Windows 2003 should count 2 processors
    Failure/Error: Facter.collection.loader.load(:processor)
    Mocha::ExpectationError:
      unexpected invocation: Facter::Util::WMI.execquery('select Architecture, 
Level from Win32_Processor')
      satisfied expectations:
      - allowed any number of times, not yet invoked: 
#<AnyInstance:Facter::Util::Loader>.load_all(any_parameters)
      - allowed any number of times, invoked 7 times: 
#<Facter::Util::Fact:0x7fa9282f4cb0>.value(any_parameters)
      - allowed any number of times, not yet invoked: 
#<RSpec::Core::ExampleGroup::Nested_44::Nested_1::Nested_1:0x7fa9282fb650>.proc(any_parameters)
      - allowed any number of times, not yet invoked: allowed any number of 
times, not yet invoked: 
#<RSpec::Core::ExampleGroup::Nested_44::Nested_1::Nested_1:0x7fa9282fb650>.proc(any_parameters).Name(any_parameters)
      - allowed any number of times, not yet invoked: allowed any number of 
times, not yet invoked: 
#<RSpec::Core::ExampleGroup::Nested_44::Nested_1::Nested_1:0x7fa9282fb650>.proc(any_parameters).NumberOfLogicalProcessors(any_parameters)
      - allowed any number of times, not yet invoked: 
Facter::Util::WMI.execquery('select * from Win32_Processor')
    # ./spec/../lib/facter/hardwaremodel.rb:39
    # ./spec/../lib/facter/util/resolution.rb:162:in `call'
    # ./spec/../lib/facter/util/resolution.rb:162:in `value'
    # ./spec/../lib/facter/util/resolution.rb:160:in `value'
    # ./spec/../lib/facter/util/fact.rb:78:in `value'
    # ./spec/../lib/facter/util/loader.rb:81:in `inject'
    # ./spec/../lib/facter/util/fact.rb:74:in `each'
    # ./spec/../lib/facter/util/fact.rb:74:in `inject'
    # ./spec/../lib/facter/util/fact.rb:74:in `value'
    # ./spec/../lib/facter/util/fact.rb:120:in `searching'
    # ./spec/../lib/facter/util/fact.rb:70:in `value'
    # ./spec/../lib/facter/util/collection.rb:118:in `value'
    # ./spec/../lib/facter.rb:98:in `send'
    # ./spec/../lib/facter.rb:98:in `value'
    # ./spec/../lib/facter/architecture.rb:16
    # ./spec/../lib/facter/util/resolution.rb:162:in `call'
    # ./spec/../lib/facter/util/resolution.rb:162:in `value'
    # ./spec/../lib/facter/util/resolution.rb:160:in `value'
    # ./spec/../lib/facter/util/fact.rb:78:in `value'
    # ./spec/../lib/facter/util/loader.rb:81:in `inject'
    # ./spec/../lib/facter/util/fact.rb:74:in `each'
    # ./spec/../lib/facter/util/fact.rb:74:in `inject'
    # ./spec/../lib/facter/util/fact.rb:74:in `value'
    # ./spec/../lib/facter/util/fact.rb:120:in `searching'
    # ./spec/../lib/facter/util/fact.rb:70:in `value'
    # ./spec/../lib/facter/util/collection.rb:118:in `value'
    # ./spec/../lib/facter.rb:98:in `send'
    # ./spec/../lib/facter.rb:98:in `value'
    # ./spec/../lib/facter/util/processor.rb:8:in `enum_cpuinfo'
    # ./spec/../lib/facter/processor.rb:83
    # ./spec/../lib/facter/util/loader.rb:81:in `load'
    # ./spec/../lib/facter/util/loader.rb:81:in `load_file'
    # ./spec/../lib/facter/util/loader.rb:21:in `load'
    # ./spec/../lib/facter/util/loader.rb:17:in `each'
    # ./spec/../lib/facter/util/loader.rb:17:in `load'
    # ./spec/unit/processor_spec.rb:23:in `load'
    # ./spec/unit/processor_spec.rb:32


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to