From 61b34906552ca4bd46f9a07dec419a44bac94652 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 19 Mar 2007 01:44:44 +0000 Subject: Fixing the fact caching so that facts are only downloaded and retrieved once, rather than once during fresh checking and once during config compile. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2304 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/network/client/master.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 506ed09e8..518110a63 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -128,7 +128,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end # Have the facts changed since we last compiled? - def facts_changed? + def facts_changed?(facts) oldfacts = Puppet::Util::Storage.cache(:configuration)[:facts] newfacts = self.class.facts if oldfacts == newfacts @@ -139,10 +139,10 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end # Check whether our configuration is up to date - def fresh? + def fresh?(facts) return false if Puppet[:ignorecache] return false unless self.compile_time - return false if self.facts_changed? + return false if self.facts_changed?(facts) # We're willing to give a 2 second drift if @driver.freshness - @compile_time.to_i < 1 @@ -167,8 +167,11 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # use the cached copy. def getconfig dostorage() + + facts = self.class.facts + if self.objects or FileTest.exists?(self.cachefile) - if self.fresh? + if self.fresh?(facts) Puppet.info "Config is up to date" begin @objects = YAML.load(self.retrievecache).to_type @@ -185,8 +188,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client getplugins() end - facts = self.class.facts - unless facts.length > 0 raise Puppet::Network::ClientError.new( "Could not retrieve any facts" -- cgit