summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-06 19:11:54 -0600
committerLuke Kanies <luke@madstop.com>2009-02-06 19:11:54 -0600
commit916abc2e68a9b0a095c5783854a4b0a4819ddf2c (patch)
tree74a966dbdd93b0f4a78b63a2e042d8f6a557276d /lib
parent53357884111d3499746b292f99948d5eb3c83415 (diff)
downloadpuppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.tar.gz
puppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.tar.xz
puppet-916abc2e68a9b0a095c5783854a4b0a4819ddf2c.zip
Changing how the Configurer interacts with the cache
This changes the hooks provided via the Indirector Request for determining how the cache is used. These hooks are only used by the Configurer class. They're messy, but I can't come up with a better design, and they're at least sufficient. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/configurer.rb4
-rw-r--r--lib/puppet/indirector/indirection.rb4
-rw-r--r--lib/puppet/indirector/request.rb15
3 files changed, 18 insertions, 5 deletions
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 2549410cf..67c744d39 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -88,7 +88,7 @@ class Puppet::Configurer
result = nil
begin
duration = thinmark do
- result = catalog_class.find(name, :use_cache => false)
+ result = catalog_class.find(name, :ignore_cache => true)
end
rescue => detail
puts detail.backtrace if Puppet[:trace]
@@ -98,7 +98,7 @@ class Puppet::Configurer
unless result
begin
duration = thinmark do
- result = catalog_class.find(name, :use_cache => true)
+ result = catalog_class.find(name, :ignore_terminus => true)
end
rescue => detail
puts detail.backtrace if Puppet[:trace]
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 18b764757..5d8cfe9b5 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -186,7 +186,7 @@ class Puppet::Indirector::Indirection
terminus = prepare(request)
# See if our instance is in the cache and up to date.
- if cache? and request.use_cache? and cached = cache.find(request)
+ 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
@@ -196,7 +196,7 @@ class Puppet::Indirector::Indirection
end
# Otherwise, return the result from the terminus, caching if appropriate.
- if result = terminus.find(request)
+ if ! request.ignore_terminus? and result = terminus.find(request)
result.expiration ||= self.expiration
if cache? and request.use_cache?
Puppet.info "Caching %s for %s" % [self.name, request.key]
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index 4149d0db9..8227db174 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -4,7 +4,7 @@ require 'puppet/indirector'
# Indirection call, and as a a result also handles REST calls. It's somewhat
# analogous to an HTTP Request object, except tuned for our Indirector.
class Puppet::Indirector::Request
- attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated, :use_cache
+ attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated, :ignore_cache, :ignore_terminus
attr_accessor :server, :port, :uri, :protocol
@@ -14,6 +14,19 @@ class Puppet::Indirector::Request
! ! authenticated
end
+ # LAK:NOTE This is a messy interface to the cache, and it's only
+ # used by the Configurer class. I decided it was better to implement
+ # it now and refactor later, when we have a better design, than
+ # to spend another month coming up with a design now that might
+ # not be any better.
+ def ignore_cache?
+ ignore_cache
+ end
+
+ def ignore_terminus?
+ ignore_terminus
+ end
+
def initialize(indirection_name, method, key, options = {})
options ||= {}
raise ArgumentError, "Request options must be a hash, not %s" % options.class unless options.is_a?(Hash)