diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-04 12:49:11 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-07-18 10:31:10 +1000 |
| commit | a06094ea0f3a38446859de55100ac7fdb0488a9d (patch) | |
| tree | f59e75605d9050d4632cede29a8cd086b407b570 /lib/puppet | |
| parent | b2a008e30ea57f0c94d605de855c45c0fdf0e5ce (diff) | |
| download | puppet-a06094ea0f3a38446859de55100ac7fdb0488a9d.tar.gz puppet-a06094ea0f3a38446859de55100ac7fdb0488a9d.tar.xz puppet-a06094ea0f3a38446859de55100ac7fdb0488a9d.zip | |
Feature #2378 - Implement "thin_storeconfigs"
Thin storeconfigs is a limited version of storeconfigs that is
more performant and still allows the exported/collected resources
system wich is the primary use of storeconfigs.
It works by storing to the database only the exported resources, tags
and host facts.
Since usually those exported resources are less than the number
of total resources for a node, it is expected to be faster than
regular storeconfigs (especially for the first run).
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/defaults.rb | 10 | ||||
| -rw-r--r-- | lib/puppet/rails/host.rb | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index b2de823a5..4fb8bfeba 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -180,7 +180,15 @@ module Puppet raise "Cannot disable asynchronous storeconfigs in a running process" end end - } + }, + :thin_storeconfigs => {:default => false, :desc => + "Boolean; wether storeconfigs store in the database only the facts and exported resources. + If true, then storeconfigs performance will be higher and still allow exported/collected + resources, but other usage external to Puppet might not work", + :hook => proc do |value| + Puppet.settings[:storeconfigs] = true if value + end + } ) hostname = Facter["hostname"].value diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb index 14ad5e6aa..d66fd2ed7 100644 --- a/lib/puppet/rails/host.rb +++ b/lib/puppet/rails/host.rb @@ -145,6 +145,9 @@ class Puppet::Rails::Host < ActiveRecord::Base # Set our resources. def merge_resources(list) + # keep only exported resources in thin_storeconfig mode + list = list.select { |r| r.exported? } if Puppet.settings[:thin_storeconfigs] + resources_by_id = nil debug_benchmark("Searched for resources") { resources_by_id = find_resources() @@ -160,7 +163,9 @@ class Puppet::Rails::Host < ActiveRecord::Base end def find_resources - resources.find(:all, :include => :source_file).inject({}) do | hash, resource | + condition = { :exported => true } if Puppet.settings[:thin_storeconfigs] + + resources.find(:all, :include => :source_file, :conditions => condition || {}).inject({}) do | hash, resource | hash[resource.id] = resource hash end |
