diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-18 00:54:59 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-07-18 16:41:54 +1000 |
commit | d8937acb8c9b108e61330cbac703a17b2eaba9b3 (patch) | |
tree | 2e962357a87a10cd7eb76dadf752dd2b57e0c340 /lib | |
parent | a0fa09f6ee562dd1b61fe56dd4b914419d641986 (diff) | |
download | puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.tar.gz puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.tar.xz puppet-d8937acb8c9b108e61330cbac703a17b2eaba9b3.zip |
You can now select the encoding format when transferring the catalog,
with 'yaml' still being the default but 'marshal' being an option.
This is because testing has shown drastic performance differences
between the two, with up to 70% of compile time being spent
in YAML code. Use the 'catalog_format' setting to choose your format,
and the setting must be set on the client.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/defaults.rb | 5 | ||||
-rw-r--r-- | lib/puppet/network/client/master.rb | 15 | ||||
-rw-r--r-- | lib/puppet/network/handler/master.rb | 14 |
3 files changed, 22 insertions, 12 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 5f71bb8b7..87ccd62f6 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -416,7 +416,10 @@ module Puppet :ca_server => ["$server", "The server to use for certificate authority requests. It's a separate server because it cannot and does not need to horizontally scale."], - :ca_port => ["$masterport", "The port to use for the certificate authority."] + :ca_port => ["$masterport", "The port to use for the certificate authority."], + :catalog_format => ["yaml", "What format to use to dump the catalog. Only supports + 'marshal' and 'yaml'. Only matters on the client, since it asks the server + for a specific format."] ) self.setdefaults(:filebucket, diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 0de3a117b..2da6cf890 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -143,15 +143,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # If we can't retrieve the catalog, just return, which will either # fail, or use the in-memory catalog. - unless yaml_objects = get_actual_config(facts) + unless marshalled_objects = get_actual_config(facts) use_cached_config(true) return end begin - objects = YAML.load(yaml_objects) + case Puppet[:catalog_format] + when "marshal": objects = Marshal.load(marshalled_objects) + when "yaml": objects = YAML.load(marshalled_objects) + else + raise "Invalid catalog format '%s'" % Puppet[:catalog_format] + end rescue => detail - msg = "Configuration could not be translated from yaml" + msg = "Configuration could not be translated from %s" % Puppet[:catalog_format] msg += "; using cached catalog" if use_cached_config(true) Puppet.warning msg return @@ -175,7 +180,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end if ! @catalog.from_cache - self.cache(yaml_objects) + self.cache(marshalled_objects) end # Keep the state database up to date. @@ -442,7 +447,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client benchmark(:debug, "Retrieved catalog") do # error handling for this is done in the network client begin - textobjects = @driver.getconfig(textfacts, "yaml") + textobjects = @driver.getconfig(textfacts, Puppet[:catalog_format]) begin textobjects = CGI.unescape(textobjects) rescue => detail diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index a050b089b..9682c460e 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -64,7 +64,14 @@ class Puppet::Network::Handler catalog = Puppet::Node::Catalog.find(client) - return translate(catalog.extract) + case format + when "yaml": + return CGI.escape(catalog.extract.to_yaml(:UseBlock => true)) + when "marshal": + return CGI.escape(Marshal.dump(catalog.extract)) + else + raise "Invalid markup format '%s'" % format + end end # @@ -90,11 +97,6 @@ class Puppet::Network::Handler # Translate our configuration appropriately for sending back to a client. def translate(config) - if local? - config - else - CGI.escape(config.to_yaml(:UseBlock => true)) - end end end end |