summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-06-10 10:48:36 -0700
committerNick Lewis <nick@puppetlabs.com>2011-06-10 11:51:55 -0700
commit413b136671232a8a0a9e27c18c1b6547241276e7 (patch)
treeec034a324b658e492ec504141c0212b60ab9aef1 /lib/puppet
parentd866ce187d45897acb9b099e7a4d77a2aadced8d (diff)
downloadpuppet-413b136671232a8a0a9e27c18c1b6547241276e7.tar.gz
puppet-413b136671232a8a0a9e27c18c1b6547241276e7.tar.xz
puppet-413b136671232a8a0a9e27c18c1b6547241276e7.zip
(#4416) Always remove old provider before recreating it
In the case where provider class evaluation failed midway, the provider class would be created but not registered. Thus, when checking whether it should be removed, it wasn't found, and wasn't removed. This caused it to then fail to be recreated, because it collided with the existing class. Now we don't bother checking whether the provider is registered before we remove it, since rmclass has the appropriate checks to do the unregistration, and class removal safely. Removing a provider class that has been created but not registered should not be a problem since the only time this can happen is when the class is unusable because of parsing or other fatal errors in the provider itself. Paired-with: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/type.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 58673462a..1933097da 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1416,9 +1416,8 @@ class Type
def self.provide(name, options = {}, &block)
name = Puppet::Util.symbolize(name)
- if obj = provider_hash[name]
+ if unprovide(name)
Puppet.debug "Reloading #{name} #{self.name} provider"
- unprovide(name)
end
parent = if pname = options[:parent]
@@ -1441,7 +1440,6 @@ class Type
self.providify
-
provider = genclass(
name,
:parent => parent,
@@ -1509,18 +1507,11 @@ class Type
end
def self.unprovide(name)
- if provider_hash.has_key? name
-
- rmclass(
- name,
- :hash => provider_hash,
-
- :prefix => "Provider"
- )
- if @defaultprovider and @defaultprovider.name == name
- @defaultprovider = nil
- end
+ if @defaultprovider and @defaultprovider.name == name
+ @defaultprovider = nil
end
+
+ rmclass(name, :hash => provider_hash, :prefix => "Provider")
end
# Return an array of all of the suitable providers.