From b2a008e30ea57f0c94d605de855c45c0fdf0e5ce Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Thu, 9 Jul 2009 20:59:41 +0200 Subject: Fix #2391 - Exported resources never make to the storeconfigs db The issue is that when we convert Puppet::Parser::Resource catalog to a Puppet::Resource catalog before storing it to the database, we don't allow virtual resource to be converted. Unfortunately exported resources are virtual by design, and as such aren't converted, and we lose them, so it isn't possible to store them in the database. Unfortunately, the client will get the exported resources too. The fix is dual-fold: * we make sure exported resource are skipped when the transaction is applied as a last safeguard * we filter-out the catalog through the catalog compiler terminus before the catalog is returned to the client Signed-off-by: Brice Figureau --- lib/puppet/resource/catalog.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/puppet/resource') diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 42e92f407..bb82906f3 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -468,6 +468,13 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph to_catalog :to_resource end + # filter out the catalog, applying +block+ to each resource. + # If the block result is false, the resource will + # be kept otherwise it will be skipped + def filter(&block) + to_catalog :to_resource, &block + end + # Store the classes in the classfile. def write_class_file begin @@ -534,7 +541,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph map = {} vertices.each do |resource| - next if resource.respond_to?(:virtual?) and resource.virtual? + next if virtual_not_exported?(resource) + next if block_given? and yield resource #This is hackity hack for 1094 #Aliases aren't working in the ral catalog because the current instance of the resource @@ -589,4 +597,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph return result end + + def virtual_not_exported?(resource) + resource.respond_to?(:virtual?) and resource.virtual? and (resource.respond_to?(:exported?) and not resource.exported?) + end end -- cgit