Jira (FACT-3063) Facter unable to get processor speed on OS 11 arm64 which causes the resolver to blow up

11 views
Skip to first unread message

Gabriel Nagy (Jira)

unread,
Aug 4, 2021, 7:26:02 AM8/4/21
to puppe...@googlegroups.com
Gabriel Nagy created an issue
 
Facter / Bug FACT-3063
Facter unable to get processor speed on OS 11 arm64 which causes the resolver to blow up
Issue Type: Bug Bug
Affects Versions: FACT 4.2.2
Assignee: Unassigned
Created: 2021/08/04 4:25 AM
Priority: Normal Normal
Reporter: Gabriel Nagy

Facter queries the following items on macOS using sysctl:

        ITEMS = { logical_count: 'hw.logicalcpu_max',
                  physical_count: 'hw.physicalcpu_max',
                  brand: 'machdep.cpu.brand_string',
                  speed: 'hw.cpufrequency_max',
                  cores_per_socket: 'machdep.cpu.core_count',
                  threads_per_core: 'machdep.cpu.thread_count' }.freeze 

The outputs get passed like this to build_fact_list:

          def build_fact_list(processors_data)
            build_logical_count(processors_data[0])
            build_physical_count(processors_data[1])
            build_models(processors_data[2])
            build_speed(processors_data[3])
            build_cores_per_socket(processors_data[4])
            build_threads_per_core(processors_data[5], processors_data[4])
          end

The problem surfaces when processors_data is missing one of the outputs from ITEMS and methods end up being called with nil.

In our case hw.cpufrequency_max is empty so the entire processors_data output is shifted and one element short.

We need to ensure the resolver works even if not all sysctl queries resolve; and fix the processor speed fact (if possible).

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Gabriel Nagy (Jira)

unread,
Aug 4, 2021, 7:28:03 AM8/4/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
Change By: Gabriel Nagy
Facter queries the following items on macOS using sysctl:
{code:java}

        ITEMS = { logical_count: 'hw.logicalcpu_max',
                  physical_count: 'hw.physicalcpu_max',
                  brand: 'machdep.cpu.brand_string',
                  speed: 'hw.cpufrequency_max',
                  cores_per_socket: 'machdep.cpu.core_count',
                  threads_per_core: 'machdep.cpu.thread_count' }.freeze {code}


The outputs get passed like this to {{build_fact_list}}:
{code}

          def build_fact_list(processors_data)
            build_logical_count(processors_data[0])
            build_physical_count(processors_data[1])
            build_models(processors_data[2])
            build_speed(processors_data[3])
            build_cores_per_socket(processors_data[4])
            build_threads_per_core(processors_data[5], processors_data[4])
          end
{code}

The problem surfaces when {{processors_data}} is missing one of the outputs from {{ITEMS}} and methods end up being called with {{nil}}.


In our case {{hw.cpufrequency_max}} is empty so the entire {{processors_data}} output is shifted and one element short.

We need to ensure the resolver works even if not all sysctl queries resolve; and fix the processor speed fact (if possible).


Resolver in question: https://github.com/puppetlabs/facter/blob/main/lib/facter/resolvers/macosx/processor.rb (nit: the filename should be processors not processor)

Gheorghe Popescu (Jira)

unread,
Aug 16, 2021, 10:37:01 AM8/16/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Aug 18, 2021, 4:14:02 AM8/18/21
to puppe...@googlegroups.com

Ciprian Badescu (Jira)

unread,
Aug 18, 2021, 4:14:03 AM8/18/21
to puppe...@googlegroups.com

Dorin Pleava (Jira)

unread,
Aug 18, 2021, 5:50:03 AM8/18/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages