Environments used to be only some strings, but now we pass around environment instances which have references to the known resource types and other information. When saving the host information in the storeconfigs database, we were using this environment instance which was yamlized by AR and stored instead of using the environment name. This could result for storing a potentially large information in the environment column of the hosts table.
Signed-off-by: Brice Figureau <[email protected]> --- lib/puppet/indirector/catalog/active_record.rb | 2 +- spec/unit/indirector/catalog/active_record_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb index fabb08e..da9256e 100644 --- a/lib/puppet/indirector/catalog/active_record.rb +++ b/lib/puppet/indirector/catalog/active_record.rb @@ -32,7 +32,7 @@ class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord if node = Puppet::Node.find(catalog.name) host.ip = node.parameters["ipaddress"] - host.environment = node.environment + host.environment = node.environment.name.to_s end host.save diff --git a/spec/unit/indirector/catalog/active_record_spec.rb b/spec/unit/indirector/catalog/active_record_spec.rb index 4e9d049..baa5b9a 100755 --- a/spec/unit/indirector/catalog/active_record_spec.rb +++ b/spec/unit/indirector/catalog/active_record_spec.rb @@ -79,7 +79,9 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do @host = stub 'host', :name => "foo", :save => nil, :merge_resources => nil, :last_compile= => nil, :ip= => nil, :environment= => nil @host.stubs(:railsmark).yields - @node = stub_everything 'node', :parameters => {} + @env = stub 'env', :name => :myenv + + @node = stub_everything 'node', :parameters => {}, :environment => @env Puppet::Node.stubs(:find).returns(@node) Puppet::Rails::Host.stubs(:find_by_name).returns @host @@ -117,8 +119,6 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do end it "should set host environment if we could find a matching node" do - @node.stubs(:environment).returns("myenv") - @host.expects(:environment=).with 'myenv' @terminus.save(@request) -- 1.6.6.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
