summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-18 16:56:20 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-18 16:56:20 +0000
commit5257837ecb85fd37553430fe5e5030d775dbb7bb (patch)
tree4b2ad2a9f6fa494aed994be0e5051a4ace87b2e7
parenta76afb7b9298854ebbc2307c1a41adf0b8fb51b9 (diff)
downloadpuppet-5257837ecb85fd37553430fe5e5030d775dbb7bb.tar.gz
puppet-5257837ecb85fd37553430fe5e5030d775dbb7bb.tar.xz
puppet-5257837ecb85fd37553430fe5e5030d775dbb7bb.zip
Fixing #491 -- the client correctly realizes when the cache file is missing and only considers the config to be in sync if that is not the case.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2288 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--CHANGELOG3
-rw-r--r--lib/puppet/network/client/master.rb18
-rwxr-xr-xtest/network/client/master.rb22
3 files changed, 32 insertions, 11 deletions
diff --git a/CHANGELOG b/CHANGELOG
index bb64b1de7..aed57f7d1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,7 @@
0.22.2 (grover)
+ The client configuration cache can be safely removed and the client
+ will correctly realize the client is not in sync.
+
Resources can now be freely deleted, thus fixing many problems introduced
when deletion of required resources was forbidden when purging was introduced.
Only resources being purged will not be deleted.
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index b244478c2..7553a62c7 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -102,9 +102,9 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
def clear
- #@objects = nil
@objects.remove(true)
Puppet::Type.allclear
+ @objects = nil
end
# Initialize and load storage
@@ -155,16 +155,16 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# use the cached copy.
def getconfig
dostorage()
- if self.fresh?
- Puppet.info "Config is up to date"
- unless defined? @objects
+ if self.objects or FileTest.exists?(self.cachefile)
+ if self.fresh?
+ Puppet.info "Config is up to date"
begin
@objects = YAML.load(self.retrievecache).to_type
rescue => detail
Puppet.warning "Could not load cached configuration: %s" % detail
end
+ return
end
- return
end
Puppet.debug("getting config")
@@ -194,13 +194,9 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
self.setclasses(objects.classes)
# Clear all existing objects, so we can recreate our stack.
- if defined? @objects
- Puppet::Type.allclear
-
- # Make sure all of the objects are really gone.
- @objects.remove(true)
+ if self.objects
+ clear()
end
- @objects = nil
# Now convert the objects to real Puppet objects
@objects = objects.to_type
diff --git a/test/network/client/master.rb b/test/network/client/master.rb
index 270c3e08c..593c331ce 100755
--- a/test/network/client/master.rb
+++ b/test/network/client/master.rb
@@ -545,6 +545,28 @@ end
assert(Puppet[:noop], "noop got disabled in run")
end
+
+ # #491 - make sure a missing config doesn't kill us
+ def test_missing_localconfig
+ master = mkclient
+ master.local = false
+ driver = master.send(:instance_variable_get, "@driver")
+ driver.local = false
+ # Retrieve the configuration
+ master.getconfig
+
+ # Now the config is up to date, so get rid of the @objects var and
+ # the cached config
+ master.clear
+ File.unlink(master.cachefile)
+
+ assert_nothing_raised("Missing cache file threw error") do
+ master.getconfig
+ end
+
+ assert(! @logs.detect { |l| l.message =~ /Could not load/},
+ "Tried to load cache when it is non-existent")
+ end
end
# $Id$