summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider_resolver.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb
index c819b0c87f..0c3a798d3c 100644
--- a/lib/chef/provider_resolver.rb
+++ b/lib/chef/provider_resolver.rb
@@ -67,13 +67,16 @@ class Chef
Chef::Log.debug "providers that refused resource #{resource} were: #{enabled_handlers - supported_handlers}"
Chef::Log.debug "providers that support resource #{resource} include: #{supported_handlers}"
+ # if none of the providers specifically support the resource, we still need to pick one of the providers that are
+ # enabled on the node to handle the why-run use case.
handlers = supported_handlers.empty? ? enabled_handlers : supported_handlers
+ Chef::Log.debug "no providers supported the resource, falling back to enabled handlers" if supported_handlers.empty?
if handlers.count >= 2
+ # this magic stack ranks the providers by where they appear in the provider_priority_map, it is mostly used
+ # to pick amongst N different ways to start init scripts on different debian/ubuntu systems.
priority_list = [ get_provider_priority_map(resource.resource_name, node) ].flatten.compact
-
handlers = handlers.sort_by { |x| i = priority_list.index x; i.nil? ? Float::INFINITY : i }
-
handlers = [ handlers.first ]
end
@@ -81,6 +84,8 @@ class Chef
raise Chef::Exceptions::AmbiguousProviderResolution.new(resource, handlers) if handlers.count >= 2
+ Chef::Log.debug "dynamic provider resolver FAILED to resolve a provider" if handlers.empty?
+
return nil if handlers.empty?
handlers[0]