Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processors.extensions fact #2664

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

jcpunk
Copy link
Contributor

@jcpunk jcpunk commented Jan 4, 2024

This should add in an extra set of attributes for finding your microarch or CPU extensions.

Addresses #2663

I'll probably need help with the tests...

@jcpunk jcpunk requested a review from a team as a code owner January 4, 2024 21:58
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@jcpunk jcpunk force-pushed the processors-extensions branch 5 times, most recently from b0a0915 to 5977abb Compare January 9, 2024 17:21
@jcpunk jcpunk force-pushed the processors-extensions branch 3 times, most recently from 456fe92 to 951ab1b Compare January 16, 2024 18:04
@jcpunk jcpunk force-pushed the processors-extensions branch 5 times, most recently from 90d1586 to a09d504 Compare January 30, 2024 19:03
@jcpunk jcpunk requested a review from joshcooper January 30, 2024 19:08
@jcpunk jcpunk force-pushed the processors-extensions branch 2 times, most recently from f25a5c1 to cd8cc11 Compare January 30, 2024 19:36
@jcpunk jcpunk force-pushed the processors-extensions branch 5 times, most recently from 8e6f350 to 40a198a Compare February 13, 2024 21:15
@jcpunk jcpunk force-pushed the processors-extensions branch from 40a198a to 8de941e Compare April 9, 2024 15:10
@joshcooper joshcooper added the enhancement New feature or enhancement label Apr 11, 2024
@joshcooper
Copy link
Contributor

Adding notes from some debugging about the order-dependent test failure, which is showing up on Windows.

This passes:

PS C:\work\facter> bundle exec rspec './spec/facter/resolvers/uname_spec.rb[1:6]' --order random:12882
Run options: include {:ids=>{"./spec/facter/resolvers/uname_spec.rb"=>["1:6"]}}

Randomized with seed 12882
.

Finished in 0.03427 seconds (files took 2.63 seconds to load)
1 example, 0 failures

But this doesn't:

PS C:\work\facter> bundle exec rspec './spec/facter/resolvers/processors_spec.rb[1:1:1:1,1:1:1:2,1:1:1:3,1:1:1:4,1:1:2:1,1:1:2:2,1:1:2:3,1:2:1,1:2:2,1:2:3,1:3:1]' './spec/facter/resolvers/uname_spec.rb[1:6]' --order random:12882
Run options: include {:ids=>{"./spec/facter/resolvers/processors_spec.rb"=>["1:1:1:1", "1:1:1:2", "1:1:1:3", "1:1:1:4", "1:1:2:1", "1:1:2:2", "1:1:2:3", "1:2:1", "1:2:2", "1:2:3", "1:3:1"], "./spec/facter/resolvers/uname_spec.rb"=>["1:6"]}}

Randomized with seed 12882
.E, [2024-04-09T17:29:24.293199 #4448] ERROR -- : Facter::Resolvers::Linux::Processors - Resolving fact models, but got undefined method `error' for Facter::Log:Class

        log.error("Resolving fact #{fact_name}, but got #{e} at #{e.backtrace[0]}")
           ^^^^^^
Did you mean?  errors? at C:/work/facter/lib/facter/resolvers/base_resolver.rb:31:in `rescue in resolve'
...

It seems there's a logger instance spy leaking from one test to another.

First, we're not consistent with how loggers are initialized, for example, this is evaluated as soon as the resolver is required:

@log = Facter::Log.new(self)

But this is done lazily:

def self.log
@log ||= Log.new(self)
end

Also the resolver tests aren't consistent with using instance_spy's, for example, here we use the real Facter::Log class:

let(:log_spy) { Facter::Log }

Here we use an instance_spy:

let(:logger) { instance_spy(Facter::Log) }

And here we don't specify a logger at all:

describe Facter::Resolvers::Linux::Processors do
after do
Facter::Resolvers::Linux::Processors.invalidate_cache
end

@jcpunk
Copy link
Contributor Author

jcpunk commented May 24, 2024

Rebased off HEAD

@jcpunk jcpunk force-pushed the processors-extensions branch from d4ceb12 to 71cc964 Compare May 24, 2024 18:03
@jcpunk jcpunk requested a review from joshcooper May 24, 2024 18:03
@jcpunk jcpunk force-pushed the processors-extensions branch from 71cc964 to d6a0020 Compare June 6, 2024 18:06
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ bundle exec facter processors.extensions
[
  "x86_64",
  "x86_64-v1",
  "x86_64-v2",
  "x86_64-v3",
  "x86_64-v4"
]

@joshcooper joshcooper merged commit 066e4f5 into puppetlabs:main Jun 7, 2024
18 checks passed
@joshcooper
Copy link
Contributor

Thanks @jcpunk !

@joshcooper joshcooper changed the title feat(processor.extensions) Add support for CPU flag detection Add processors.extensions fact Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants