From 25edad7a7090e5f6b0706e9eae71d6c418b4d31c Mon Sep 17 00:00:00 2001 From: jonathannewman Date: Wed, 4 Oct 2023 09:54:41 -0700 Subject: [PATCH] (FACT-3441) improve reliability of uname resolver In the case that the uname command fails to return expected content, this adds validation to the output looking for both an empty result, or missing results. Logging is added to help identify the condition. --- lib/facter/resolvers/uname.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/facter/resolvers/uname.rb b/lib/facter/resolvers/uname.rb index 56347b519c..49dd3809c5 100644 --- a/lib/facter/resolvers/uname.rb +++ b/lib/facter/resolvers/uname.rb @@ -28,12 +28,16 @@ def uname_system_call(fact_name) def build_fact_list(output) uname_results = output.split("\n") - @fact_list[:machine] = uname_results[0].strip - @fact_list[:nodename] = uname_results[1].strip - @fact_list[:processor] = uname_results[2].strip - @fact_list[:kernelrelease] = uname_results[3].strip - @fact_list[:kernelname] = uname_results[4].strip - @fact_list[:kernelversion] = uname_results[5].strip + if !uname_results.empty? + @fact_list[:machine], + @fact_list[:nodename], + @fact_list[:processor], + @fact_list[:kernelrelease], + @fact_list[:kernelname], + @fact_list[:kernelversion] = uname_results.map(&:strip) + else + log.warn('Request to uname returned no output. Uname related facts are not populated.') + end end end end