Skip to content

Commit

Permalink
(FACT-3441) improve reliability of uname resolver
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathannewman committed Oct 19, 2023
1 parent cb9a7c2 commit 61f18e6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/facter/resolvers/uname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61f18e6

Please sign in to comment.