| 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). |