summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-08-07 22:45:12 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-08-13 08:10:00 +1000
commitaad3b76da045d2fd845866fb6e8a7c9866307cd8 (patch)
tree6e8cd7c46a4f58d66b95bcdd14ef85710f44f253 /lib
parent63cb1ade80187ebc6f7f24c74e4d1e4db53422c1 (diff)
downloadpuppet-aad3b76da045d2fd845866fb6e8a7c9866307cd8.tar.gz
puppet-aad3b76da045d2fd845866fb6e8a7c9866307cd8.tar.xz
puppet-aad3b76da045d2fd845866fb6e8a7c9866307cd8.zip
Fix #2507 - Exported resources were not correctly collected.
#2507 contains two issues: * a crash when we filters-out an unwanted resource which had edges pointing to it. * resources are losing their virtuality when they are transformed from Puppet::Parser::Resource to Puppet::Resource. This means we weren't able to distinguish anymore between an exported resource collected in the same node as it was exported and an exported resource collected in another node. The net result is that we can't apply exported resources that are collected in the same node because they are filtered out by the catalog filter (see the commits for #2391 for more information). The fix is to keep the virtuality of the resources so that we can differentiate those two types of exported resources. We keep this until the catalog is ready to be sent, where we filter out the virtual resouces only, the other still exported ones needs to be sent to the client. To be real sure, the transaction also skips virtual resources. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb2
-rw-r--r--lib/puppet/parser/resource.rb1
-rw-r--r--lib/puppet/resource.rb8
-rw-r--r--lib/puppet/resource/catalog.rb7
-rw-r--r--lib/puppet/transaction.rb4
-rw-r--r--lib/puppet/type.rb11
6 files changed, 22 insertions, 11 deletions
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 12da4de32..4f6b0602a 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -43,7 +43,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# filter-out a catalog to remove exported resources
def filter(catalog)
- return catalog.filter { |r| r.exported? } if catalog.respond_to?(:filter)
+ return catalog.filter { |r| r.virtual? } if catalog.respond_to?(:filter)
catalog
end
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 6632d2bba..7218ac0c0 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -268,6 +268,7 @@ class Puppet::Parser::Resource
result.file = self.file
result.line = self.line
result.exported = self.exported
+ result.virtual = self.virtual
result.tag(*self.tags)
return result
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 0de089cd7..134076580 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -9,7 +9,7 @@ class Puppet::Resource
include Puppet::Util::Tagging
extend Puppet::Util::Json
include Enumerable
- attr_accessor :file, :line, :catalog, :exported
+ attr_accessor :file, :line, :catalog, :exported, :virtual
attr_writer :type, :title
ATTRIBUTES = [:file, :line, :exported]
@@ -106,8 +106,10 @@ class Puppet::Resource
@parameters.each { |p,v| yield p, v }
end
- def exported?
- exported
+ %w{exported virtual}.each do |m|
+ define_method(m+"?") do
+ self.send(m)
+ end
end
# Create our resource.
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index bb82906f3..6ccfe73ad 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -576,8 +576,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
message = convert.to_s.gsub "_", " "
edges.each do |edge|
# Skip edges between virtual resources.
- next if edge.source.respond_to?(:virtual?) and edge.source.virtual?
- next if edge.target.respond_to?(:virtual?) and edge.target.virtual?
+ next if virtual_not_exported?(edge.source)
+ next if block_given? and yield edge.source
+
+ next if virtual_not_exported?(edge.target)
+ next if block_given? and yield edge.target
unless source = map[edge.source.ref]
raise Puppet::DevError, "Could not find resource %s when converting %s resources" % [edge.source.ref, message]
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index f57eda6c9..d04856d39 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -590,8 +590,8 @@ class Transaction
resource.debug "Not scheduled"
elsif failed_dependencies?(resource)
resource.warning "Skipping because of failed dependencies"
- elsif resource.exported?
- resource.debug "Skipping because exported"
+ elsif resource.virtual?
+ resource.debug "Skipping because virtual"
else
return false
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 33b4e92da..ee87c2680 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1855,6 +1855,9 @@ class Type
# is the resource exported
attr_accessor :exported
+ # is the resource virtual (it should not :-))
+ attr_accessor :virtual
+
# create a log at specified level
def log(msg)
Puppet::Util::Log.create(
@@ -1888,7 +1891,7 @@ class Type
self.title = resource.ref
end
- [:file, :line, :catalog, :exported].each do |getter|
+ [:file, :line, :catalog, :exported, :virtual].each do |getter|
setter = getter.to_s + "="
if val = resource.send(getter)
self.send(setter, val)
@@ -2069,8 +2072,10 @@ class Type
return trans
end
- def exported?
- exported
+ %w{exported virtual}.each do |m|
+ define_method(m+"?") do
+ self.send(m)
+ end
end
end # Puppet::Type