[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Paul Berry paul at puppetlabs.com
Tue May 10 08:02:11 UTC 2011


The following commit has been merged in the experimental branch:
commit 9ed1235c295995b61373b11aa4ae0cc6bb320527
Merge: a10deae8913f12935726da6944cad627e3277c52 ccc944f21a259f0216b0bfd4873c98d89127a753
Author: Paul Berry <paul at puppetlabs.com>
Date:   Mon Nov 22 11:56:41 2010 -0800

    Merge remote branch 'masterzen/feature/master/4339' into next
    
    Manually resolved conflicts:
    	spec/unit/configurer_spec.rb

diff --combined lib/puppet/application/apply.rb
index f6299f9,97de5e1..32a6b65
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@@ -130,7 -130,7 +130,7 @@@ class Puppet::Application::Apply < Pupp
          report = configurer.initialize_report
          Puppet::Util::Log.newdestination(report)
        end
 -      transaction = catalog.apply
 +      transaction = catalog.apply(:report => report)
  
        configurer.execute_postrun_command
  
@@@ -139,6 -139,7 +139,7 @@@
          configurer.send_report(report, transaction)
        else
          transaction.generate_report
+         configurer.save_last_run_summary(transaction.report)
        end
  
        exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? transaction.report.exit_status : 0 )
@@@ -164,6 -165,9 +165,9 @@@
        exit(1)
      end
  
+     # we want the last report to be persisted locally
+     Puppet::Transaction::Report.cache_class = :yaml
+ 
      if options[:debug]
        Puppet::Util::Log.level = :debug
      elsif options[:verbose]
diff --combined lib/puppet/defaults.rb
index 45152f2,f4ae886..8bf1cd8
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@@ -116,7 -116,7 +116,7 @@@ module Puppe
      :catalog_terminus => ["compiler", "Where to get node catalogs.  This is useful to change if, for instance,
        you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store."],
      :facts_terminus => {
 -      :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', 
 +      :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter',
        :desc => "The node facts terminus.",
        :hook => proc do |value|
          require 'puppet/node/facts'
@@@ -599,9 -599,17 +599,17 @@@
      :inventory_port => ["$masterport",
        "The port to communicate with the inventory_server."
      ],
 -    :report => [false,
 +    :report => [true,
        "Whether to send reports after every transaction."
      ],
+     :lastrunfile =>  { :default => "$statedir/last_run_summary.yaml",
+       :mode => 0660,
+       :desc => "Where puppet agent stores the last run report summary in yaml format."
+     },
+     :lastrunreport =>  { :default => "$statedir/last_run_report.yaml",
+       :mode => 0660,
+       :desc => "Where puppet agent stores the last run report in yaml format."
+     },
      :graph => [false, "Whether to create dot graph files for the different
        configuration graphs.  These dot files can be interpreted by tools
        like OmniGraffle or dot (which is part of ImageMagick)."],
@@@ -656,7 -664,7 +664,7 @@@
      setdefaults(
      :tagmail,
      :tagmap => ["$confdir/tagmail.conf", "The mapping between reporting tags and email addresses."],
 -    :sendmail => [%x{which sendmail 2>/dev/null}.chomp, "Where to find the sendmail binary with which to send email."],
 +    :sendmail => [which('sendmail') || '', "Where to find the sendmail binary with which to send email."],
  
      :reportfrom => ["report@" + [Facter["hostname"].value, Facter["domain"].value].join("."), "The 'from' email address for the reports."],
      :smtpserver => ["none", "The server through which to send email reports."]
@@@ -682,10 -690,11 +690,10 @@@
        used when networked databases are used."],
      :dbpassword => [ "puppet", "The database password for caching. Only
        used when networked databases are used."],
 +    :dbconnections => [ '', "The number of database connections for networked
 +      databases.  Will be ignored unless the value is a positive integer."],
      :dbsocket => [ "", "The database socket location. Only used when networked
        databases are used.  Will be ignored if the value is an empty string."],
 -    :dbconnections => [ 0, "The number of database connections. Only used when
 -      networked databases are used.  Will be ignored if the value is an empty
 -      string or is less than 1."],
      :railslog => {:default => "$logdir/rails.log",
        :mode => 0600,
        :owner => "service",
diff --combined lib/puppet/util/metric.rb
index 8f55e7b,d61fb3d..7fdc695
--- a/lib/puppet/util/metric.rb
+++ b/lib/puppet/util/metric.rb
@@@ -64,7 -64,7 +64,7 @@@ class Puppet::Util::Metri
    end
  
    def graph(range = nil)
 -    unless Puppet.features.rrd?
 +    unless Puppet.features.rrd? || Puppet.features.rrd_legacy?
        Puppet.warning "RRD library is missing; cannot graph metrics"
        return
      end
@@@ -122,7 -122,7 +122,7 @@@
    def initialize(name,label = nil)
      @name = name.to_s
  
-     @label = label || labelize(name)
+     @label = label || self.class.labelize(name)
  
      @values = []
    end
@@@ -132,7 -132,7 +132,7 @@@
    end
  
    def newvalue(name,value,label = nil)
-     label ||= labelize(name)
+     label ||= self.class.labelize(name)
      @values.push [name,label,value]
    end
  
@@@ -173,10 -173,8 +173,8 @@@
      @values.sort { |a, b| a[1] <=> b[1] }
    end
  
-   private
- 
    # Convert a name into a label.
-   def labelize(name)
+   def self.labelize(name)
      name.to_s.capitalize.gsub("_", " ")
    end
  end
diff --combined spec/unit/application/apply_spec.rb
index 22ac471,922995c..8b20aa9
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@@ -56,6 -56,7 +56,7 @@@ describe Puppet::Application::Apply d
        Puppet.stubs(:parse_config)
        Puppet::FileBucket::Dipper.stubs(:new)
        STDIN.stubs(:read)
+       Puppet::Transaction::Report.stubs(:cache_class=)
  
        @apply.options.stubs(:[]).with(any_parameters)
      end
@@@ -113,6 -114,11 +114,11 @@@
        lambda { @apply.setup }.should raise_error(SystemExit)
      end
  
+     it "should tell the report handler to cache locally as yaml" do
+       Puppet::Transaction::Report.expects(:cache_class=).with(:yaml)
+ 
+       @apply.setup
+     end
    end
  
    describe "when executing" do
@@@ -311,11 -317,22 +317,22 @@@
        end
  
        it "should apply the catalog" do
 -        @catalog.expects(:apply).returns(stub_everything 'transaction')
 +        @catalog.expects(:apply).returns(stub_everything('transaction'))
  
          @apply.main
        end
  
+       it "should save the last run summary" do
+         configurer = stub_everything 'configurer'
+         Puppet::Configurer.expects(:new).returns configurer
+         Puppet.stubs(:[]).with(:noop).returns(false)
+         report = stub 'report'
+         @transaction.stubs(:report).returns(report)
+ 
+         configurer.expects(:save_last_run_summary).with(report)
+         @apply.main
+       end
+ 
        describe "with detailed_exitcodes" do
          it "should exit with report's computed exit status" do
            Puppet.stubs(:[]).with(:noop).returns(false)
diff --combined spec/unit/configurer_spec.rb
index 2f8e615,5a2c494..24bf924
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@@ -89,6 -89,10 +89,7 @@@ describe Puppet::Configurer, "when exec
      @catalog = Puppet::Resource::Catalog.new
      @catalog.stubs(:apply)
      @agent.stubs(:retrieve_catalog).returns @catalog
+     @agent.stubs(:save_last_run_summary)
 -
 -    Puppet::Util::Log.stubs(:newdestination)
 -    Puppet::Util::Log.stubs(:close)
    end
  
    it "should prepare for the run" do
@@@ -98,14 -102,14 +99,14 @@@
    end
  
    it "should initialize a transaction report if one is not provided" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
  
      @agent.run
    end
  
    it "should pass the new report to the catalog" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.stubs(:initialize_report).returns report
      @catalog.expects(:apply).with{|options| options[:report] == report}
  
@@@ -113,7 -117,7 +114,7 @@@
    end
  
    it "should use the provided report if it was passed one" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).never
      @catalog.expects(:apply).with{|options| options[:report] == report}
  
@@@ -173,7 -177,7 +174,7 @@@
    end
  
    it "should send the report" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
      @agent.expects(:send_report).with { |r, trans| r == report }
  
@@@ -181,7 -185,7 +182,7 @@@
    end
  
    it "should send the transaction report with a reference to the transaction if a run was actually made" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
  
      trans = stub 'transaction'
@@@ -195,7 -199,7 +196,7 @@@
    it "should send the transaction report even if the catalog could not be retrieved" do
      @agent.expects(:retrieve_catalog).returns nil
  
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
      @agent.expects(:send_report)
  
@@@ -205,7 -209,7 +206,7 @@@
    it "should send the transaction report even if there is a failure" do
      @agent.expects(:retrieve_catalog).raises "whatever"
  
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
      @agent.expects(:send_report)
  
@@@ -213,16 -217,16 +214,16 @@@
    end
  
    it "should remove the report as a log destination when the run is finished" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
 -
 -    Puppet::Util::Log.expects(:close).with(report)
 +    report.expects(:<<).at_least_once
  
      @agent.run
 +    Puppet::Util::Log.destinations.should_not include(report)
    end
  
    it "should return the report as the result of the run" do
 -    report = stub 'report'
 +    report = Puppet::Transaction::Report.new
      @agent.expects(:initialize_report).returns report
  
      @agent.run.should equal(report)
@@@ -233,6 -237,7 +234,7 @@@ describe Puppet::Configurer, "when send
    before do
      Puppet.settings.stubs(:use).returns(true)
      @configurer = Puppet::Configurer.new
+     @configurer.stubs(:save_last_run_summary)
  
      @report = stub 'report'
      @trans = stub 'transaction'
@@@ -281,6 -286,20 +283,20 @@@
      @configurer.send_report(@report)
    end
  
+   it "should save the last run summary if reporting is enabled" do
+     Puppet.settings[:report] = true
+ 
+     @configurer.expects(:save_last_run_summary).with(@report)
+     @configurer.send_report(@report)
+   end
+ 
+   it "should not save the last run summary if reporting is disabled" do
+     Puppet.settings[:report] = false
+ 
+     @configurer.expects(:save_last_run_summary).never
+     @configurer.send_report(@report)
+   end
+ 
    it "should log but not fail if saving the report fails" do
      Puppet.settings[:report] = true
  
@@@ -291,6 -310,36 +307,36 @@@
    end
  end
  
+ describe Puppet::Configurer, "when saving the summary report file" do
+   before do
+     Puppet.settings.stubs(:use).returns(true)
+     @configurer = Puppet::Configurer.new
+ 
+     @report = stub 'report'
+     @trans = stub 'transaction'
+     @lastrunfd = stub 'lastrunfd'
+     Puppet::Util::FileLocking.stubs(:writelock).yields(@lastrunfd)
+   end
+ 
+   it "should write the raw summary to the lastrunfile setting value" do
+     Puppet::Util::FileLocking.expects(:writelock).with(Puppet[:lastrunfile], 0660)
+     @configurer.save_last_run_summary(@report)
+   end
+ 
+   it "should write the raw summary as yaml" do
+     @report.expects(:raw_summary).returns("summary")
+     @lastrunfd.expects(:print).with(YAML.dump("summary"))
+     @configurer.save_last_run_summary(@report)
+   end
+ 
+   it "should log but not fail if saving the last run summary fails" do
+     Puppet::Util::FileLocking.expects(:writelock).raises "exception"
+     Puppet.expects(:err)
+     lambda { @configurer.save_last_run_summary(@report) }.should_not raise_error
+   end
+ 
+ end
+ 
  describe Puppet::Configurer, "when retrieving a catalog" do
    before do
      Puppet.settings.stubs(:use).returns(true)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list