Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Avoid exceptions for zone facts on FreeBSD
Browse files Browse the repository at this point in the history
FreeBSD currently loads all Solaris facts, but FreeBSD does not have
"zones", and the zone related facts fail hardly when being processed.

Improve error detection when building the zone facts, and do not emit
these facts when an error occurred.
  • Loading branch information
smortex committed Mar 25, 2020
1 parent 106aebd commit 4fb3469
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/facts/solaris/solaris_zones/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def call_the_resolver
zones = {}

results = Facter::Resolvers::SolarisZone.resolve(:zone)
return unless results

results&.each do |result|
zones.merge!(parse_result(result))
resolved_facts << create_legacy_zone_facts(result)
Expand Down
2 changes: 2 additions & 0 deletions lib/resolvers/solaris/solaris_zone_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def build_current_zone_name_fact(fact_name)
end
@fact_list[:current_zone_name] = zone_name_output.chomp
@fact_list[fact_name]
rescue Errno::ENOENT
# zonename is not available
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/resolvers/solaris/zone_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def build_zone_fact(fact_name)
@fact_list[:zone] = create_zone_facts(zone_adm_output)

@fact_list[fact_name]
rescue Errno::ENOENT
# zoneadm is not available
end

def create_zone_facts(zones_result)
Expand Down

0 comments on commit 4fb3469

Please sign in to comment.