summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/indirector.rb4
-rw-r--r--lib/puppet/indirector/code/configuration.rb20
-rw-r--r--lib/puppet/indirector/indirection.rb6
-rw-r--r--lib/puppet/node/configuration.rb6
4 files changed, 27 insertions, 9 deletions
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index a2eb41763..6009a7ba7 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -59,6 +59,10 @@ module Puppet::Indirector
def search(*args)
indirection.search(*args)
end
+
+ def version(*args)
+ indirection.version(*args)
+ end
end
module InstanceMethods
diff --git a/lib/puppet/indirector/code/configuration.rb b/lib/puppet/indirector/code/configuration.rb
index 949926a3c..50728757c 100644
--- a/lib/puppet/indirector/code/configuration.rb
+++ b/lib/puppet/indirector/code/configuration.rb
@@ -47,15 +47,19 @@ class Puppet::Indirector::Code::Configuration < Puppet::Indirector::Code
$0 =~ /puppetmasterd/
end
- # Return the configuration version.
- def version(client = nil, clientip = nil)
- if client and node = Puppet::Node.search(client)
- update_node_check(node)
- return interpreter.configuration_version(node)
+ # Return the configuration version. Here we're returning the
+ # latest of the node, fact, or parse date. These are the
+ # three things that go into compiling a client configuration,
+ # so changes in any of them result in changes.
+ # LAK:FIXME Note that this only works when all three sources
+ # use timestamps; once one of them moves to using real versions,
+ # the comparison stops working.
+ def version(key)
+ if node = Puppet::Node.search(key)
+ return [Puppet::Node.version(key).to_f, Puppet::Node::Facts.version(key).to_f, interpreter.configuration_version(node).to_f].sort[-1]
else
- # Just return something that will always result in a recompile, because
- # this is local.
- return (Time.now + 1000).to_i
+ # This is the standard for "got nothing for ya".
+ 0
end
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 5f7baa3da..efa8819bb 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -92,6 +92,7 @@ class Puppet::Indirector::Indirection
def find(key, *args)
if cache? and cache.has_most_recent?(key, terminus.version(key))
+ Puppet.info "Using cached %s %s" % [self.name, key]
return cache.find(key, *args)
end
if result = terminus.find(key, *args)
@@ -117,10 +118,15 @@ class Puppet::Indirector::Indirection
instance.version ||= Time.now.utc
dest = cache? ? cache : terminus
return if dest.has_most_recent?(instance.name, instance.version)
+ Puppet.info "Caching %s %s" % [self.name, instance.name] if cache?
cache.save(instance, *args) if cache?
terminus.save(instance, *args)
end
+ def version(*args)
+ terminus.version(*args)
+ end
+
private
# Create a new terminus instance.
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index da8dc3a9a..9adf9aea3 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -388,8 +388,12 @@ class Puppet::Node::Configuration < Puppet::PGraph
# dumped by default, nor does yaml-dumping # the edge-labels work at this point (I don't
# know why).
# Neither of these matters right now, but I suppose it could at some point.
+ # We also have to have the vertex_dict dumped after the resource table, because yaml can't
+ # seem to handle the output of yaml-dumping the vertex_dict.
def to_yaml_properties
- instance_variables.reject { |v| %w{@edgelist_class @edge_labels}.include?(v) }
+ props = instance_variables.reject { |v| %w{@edgelist_class @edge_labels @vertex_dict}.include?(v) }
+ props << "@vertex_dict"
+ props
end
private