From 53f40bd336d709e717edb621a9d68dde9a4d5bce Mon Sep 17 00:00:00 2001 From: Rein Henrichs Date: Wed, 11 Nov 2009 11:17:13 -0800 Subject: Fix #2681 Incorrectly duplicating resources Ensure that resources whose refs are included in the catalog are skipped to avoid duplication. * Refactor to avoid early bailout on resources that cannot be ensured absent. * Remove check for managed? in generate Checking if a resource is managed is unnecessary when checking for its inclusion in the catalog. * Add test coverage for Puppet::Type::Resources#generate --- lib/puppet/type/resources.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 87bde972b..e1de55711 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -99,18 +99,18 @@ Puppet::Type.newtype(:resources) do def generate return [] unless self.purge? resource_type.instances. - reject { |r| managed? }. - reject { |r| catalog.resources.include? r.ref }. - select { |r| check(r) }. - select { |r| able_to_ensure_absent?(r) }. - each { |resource| - @parameters.each do |name, param| - resource[name] = param.value if param.metaparam? - end - - # Mark that we're purging, so transactions can handle relationships - # correctly - resource.purging + reject { |r| catalog.resources.include? r.ref }. + select { |r| check(r) }. + select { |r| r.class.validproperty?(:ensure) }. + select { |r| able_to_ensure_absent?(r) }. + each { |resource| + @parameters.each do |name, param| + resource[name] = param.value if param.metaparam? + end + + # Mark that we're purging, so transactions can handle relationships + # correctly + resource.purging } end -- cgit