summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-04-16 14:54:40 -0500
committerJames Turnbull <james@lovedthanlost.net>2009-04-17 16:15:47 +1000
commit7398fa171fdd6dcaeb2d8fd1c07a23bbd78891d0 (patch)
treede0aa525b85c15645119a355b9c21be30d3c2d55 /lib
parent88ff9c6500e76fdda02e60262dd1571577c0b92b (diff)
downloadpuppet-7398fa171fdd6dcaeb2d8fd1c07a23bbd78891d0.tar.gz
puppet-7398fa171fdd6dcaeb2d8fd1c07a23bbd78891d0.tar.xz
puppet-7398fa171fdd6dcaeb2d8fd1c07a23bbd78891d0.zip
Partially fixing #2029 - failed caches doesn't throw an exception
If the main terminus fails you get an exception, but not if a cache terminus fails. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/indirection.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 7ac214cd0..2a54ecc24 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -185,14 +185,12 @@ class Puppet::Indirector::Indirection
request = request(:find, key, *args)
terminus = prepare(request)
- # See if our instance is in the cache and up to date.
- if cache? and ! request.ignore_cache? and cached = cache.find(request)
- if cached.expired?
- Puppet.info "Not using expired %s for %s from cache; expired at %s" % [self.name, request.key, cached.expiration]
- else
- Puppet.debug "Using cached %s for %s" % [self.name, request.key]
- return cached
+ begin
+ if result = find_in_cache(request)
+ return result
end
+ rescue => detail
+ Puppet.err "Cached %s for %s failed: %s" % [self.name, request.key, detail]
end
# Otherwise, return the result from the terminus, caching if appropriate.
@@ -209,6 +207,18 @@ class Puppet::Indirector::Indirection
return nil
end
+ def find_in_cache(request)
+ # See if our instance is in the cache and up to date.
+ return nil unless cache? and ! request.ignore_cache? and cached = cache.find(request)
+ if cached.expired?
+ Puppet.info "Not using expired %s for %s from cache; expired at %s" % [self.name, request.key, cached.expiration]
+ return nil
+ end
+
+ Puppet.debug "Using cached %s for %s" % [self.name, request.key]
+ return cached
+ end
+
# Remove something via the terminus.
def destroy(key, *args)
request = request(:destroy, key, *args)