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

Jesse Wolfe jes5199 at gmail.com
Tue May 10 08:05:25 UTC 2011


The following commit has been merged in the experimental branch:
commit 448a439f5abc3d51accececb678e9c5f547f7615
Merge: 06939c51a3f675137b53fac8a521132a4c9cfcbe e27d208db86ae0825afbc6fb34d39e7c047a1bf4
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Fri Feb 25 15:17:39 2011 -0800

    Merge remote branch 'brice/feature/process-instrumentation' into next

diff --combined lib/puppet/configurer.rb
index 72e387c,4320aa9..a39f9cd
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@@ -3,6 -3,7 +3,7 @@@ require 'sync
  require 'timeout'
  require 'puppet/network/http_pool'
  require 'puppet/util'
+ require 'puppet/util/instrumentation'
  
  class Puppet::Configurer
    class CommandHookError < RuntimeError; end
@@@ -12,6 -13,7 +13,7 @@@
  
    include Puppet::Configurer::FactHandler
    include Puppet::Configurer::PluginHandler
+   include Puppet::Util::Instrumentation
  
    # For benchmarking
    include Puppet::Util
@@@ -72,15 -74,25 +74,21 @@@
      @splayed = false
    end
  
 -  def initialize_report
 -    Puppet::Transaction::Report.new
 -  end
 -
    # Prepare for catalog retrieval.  Downloads everything necessary, etc.
 -  def prepare
 +  def prepare(options)
      dostorage
  
-     download_plugins unless options[:skip_plugin_download]
+     instrument("downloading plugins") do
 -      download_plugins
++      download_plugins unless options[:skip_plugin_download]
+     end
  
-     download_fact_plugins unless options[:skip_plugin_download]
+     instrument("downloading facts plugins") do
 -      download_fact_plugins
++      download_fact_plugins unless options[:skip_plugin_download]
+     end
  
-     execute_prerun_command
+     instrument("executing prerun command") do
+       execute_prerun_command
+     end
    end
  
    # Get the remote catalog, yo.  Returns nil if no catalog can be found.
@@@ -122,7 -134,7 +130,7 @@@
    # which accepts :tags and :ignoreschedules.
    def run(options = {})
      begin
 -      prepare
 +      prepare(options)
      rescue SystemExit,NoMemoryError
        raise
      rescue Exception => detail
@@@ -130,7 -142,7 +138,7 @@@
        Puppet.err "Failed to prepare catalog: #{detail}"
      end
  
 -    options[:report] ||= initialize_report
 +    options[:report] ||= Puppet::Transaction::Report.new("apply")
      report = options[:report]
      Puppet::Util::Log.newdestination(report)
  
@@@ -141,13 -153,13 +149,15 @@@
        return
      end
  
 +    report.configuration_version = catalog.version
 +
      transaction = nil
  
      begin
-       benchmark(:notice, "Finished catalog run") do
-         transaction = catalog.apply(options)
+       instrument("applying catalog") do
+         benchmark(:notice, "Finished catalog run") do
+           transaction = catalog.apply(options)
+         end
        end
        report
      rescue => detail
@@@ -166,30 -178,21 +176,33 @@@
      execute_postrun_command
  
      Puppet::Util::Log.close(report)
-     send_report(report, transaction)
+ 
+     instrument("sending report") do
+       send_report(report, transaction)
+     end
    end
  
 -  def send_report(report, trans = nil)
 -    trans.generate_report if trans
 +  def send_report(report, trans)
 +    report.finalize_report if trans
      puts report.summary if Puppet[:summarize]
 -    report.save if Puppet[:report]
 +    save_last_run_summary(report)
 +    if Puppet[:report]
 +      Puppet::Transaction::Report.indirection.save(report)
 +    end
    rescue => detail
      puts detail.backtrace if Puppet[:trace]
      Puppet.err "Could not send report: #{detail}"
    end
  
 +  def save_last_run_summary(report)
 +    Puppet::Util::FileLocking.writelock(Puppet[:lastrunfile], 0660) do |file|
 +      file.print YAML.dump(report.raw_summary)
 +    end
 +  rescue => detail
 +    puts detail.backtrace if Puppet[:trace]
 +    Puppet.err "Could not save last run local report: #{detail}"
 +  end
 +
    private
  
    def self.timeout
@@@ -222,7 -225,7 +235,7 @@@
    def retrieve_catalog_from_cache(fact_options)
      result = nil
      @duration = thinmark do
 -      result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true))
 +      result = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true))
      end
      Puppet.notice "Using cached catalog"
      result
@@@ -235,7 -238,7 +248,7 @@@
    def retrieve_new_catalog(fact_options)
      result = nil
      @duration = thinmark do
 -      result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_cache => true))
 +      result = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], fact_options.merge(:ignore_cache => true))
      end
      result
    rescue SystemExit,NoMemoryError
diff --combined lib/puppet/network/http/handler.rb
index 2b9e81b,855a9b7..aa33f82
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@@ -5,10 -5,12 +5,12 @@@ require 'puppet/network/http/api/v1
  require 'puppet/network/rest_authorization'
  require 'puppet/network/rights'
  require 'resolv'
+ require 'puppet/util/instrumentation'
  
  module Puppet::Network::HTTP::Handler
    include Puppet::Network::HTTP::API::V1
    include Puppet::Network::RestAuthorization
+   include Puppet::Util::Instrumentation
  
    attr_reader :server, :handler
  
@@@ -65,7 -67,9 +67,9 @@@
  
      check_authorization(indirection, method, key, params)
  
-     send("do_#{method}", indirection, key, params, request, response)
+     instrument("processing #{indirection} #{key}") do
+       send("do_#{method}", indirection, key, params, request, response)
+     end
    rescue SystemExit,NoMemoryError
      raise
    rescue Exception => e
@@@ -103,7 -107,7 +107,7 @@@
  
    # Execute our find.
    def do_find(indirection_name, key, params, request, response)
 -    unless result = model(indirection_name).find(key, params)
 +    unless result = model(indirection_name).indirection.find(key, params)
        Puppet.info("Could not find #{indirection_name} for '#{key}'")
        return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
      end
@@@ -114,28 -118,13 +118,28 @@@
      format = format_to_use(request)
      set_content_type(response, format)
  
 -    set_response(response, result.render(format))
 +    if result.respond_to?(:render)
 +      set_response(response, result.render(format))
 +    else
 +      set_response(response, result)
 +    end
 +  end
 +
 +  # Execute our head.
 +  def do_head(indirection_request, request, response)
 +    unless indirection_request.model.head(indirection_request.key, indirection_request.to_hash)
 +      Puppet.info("Could not find #{indirection_request.indirection_name} for '#{indirection_request.key}'")
 +      return do_exception(response, "Could not find #{indirection_request.indirection_name} #{indirection_request.key}", 404)
 +    end
 +
 +    # No need to set a response because no response is expected from a
 +    # HEAD request.  All we need to do is not die.
    end
  
    # Execute our search.
    def do_search(indirection_name, key, params, request, response)
      model  = self.model(indirection_name)
 -    result = model.search(key, params)
 +    result = model.indirection.search(key, params)
  
      if result.nil?
        return do_exception(response, "Could not find instances in #{indirection_name} with '#{key}'", 404)
@@@ -149,7 -138,7 +153,7 @@@
  
    # Execute our destroy.
    def do_destroy(indirection_name, key, params, request, response)
 -    result = model(indirection_name).destroy(key, params)
 +    result = model(indirection_name).indirection.destroy(key, params)
  
      return_yaml_response(response, result)
    end
@@@ -161,7 -150,7 +165,7 @@@
  
      format = request_format(request)
      obj = model(indirection_name).convert_from(format, data)
 -    result = obj.save(key)
 +    result = model(indirection_name).indirection.save(obj, key)
      return_yaml_response(response, result)
    end
  
diff --combined lib/puppet/parser/compiler.rb
index fdabd05,7da50c2..4301e8c
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@@ -4,6 -4,7 +4,7 @@@
  require 'puppet/node'
  require 'puppet/resource/catalog'
  require 'puppet/util/errors'
+ require 'puppet/util/instrumentation'
  
  require 'puppet/resource/type_collection_helper'
  
@@@ -13,9 -14,12 +14,12 @@@ class Puppet::Parser::Compile
    include Puppet::Util
    include Puppet::Util::Errors
    include Puppet::Resource::TypeCollectionHelper
+   extend Puppet::Util::Instrumentation
  
    def self.compile(node)
-     new(node).compile.to_resource
+     instrument("compiling #{node.name}") do
+       new(node).compile.to_resource
+     end
    rescue => detail
      puts detail.backtrace if Puppet[:trace]
      raise Puppet::Error, "#{detail} on node #{node.name}"
@@@ -139,23 -143,12 +143,23 @@@
    def evaluate_classes(classes, scope, lazy_evaluate = true)
      raise Puppet::DevError, "No source for scope passed to evaluate_classes" unless scope.source
      found = []
 +    param_classes = nil
 +    # if we are a param class, save the classes hash
 +    # and transform classes to be the keys
 +    if classes.class == Hash
 +      param_classes = classes
 +      classes = classes.keys
 +    end
      classes.each do |name|
        # If we can find the class, then make a resource that will evaluate it.
        if klass = scope.find_hostclass(name)
 -        found << name and next if scope.class_scope(klass)
  
 -        resource = klass.ensure_in_catalog(scope)
 +        if param_classes
 +          resource = klass.ensure_in_catalog(scope, param_classes[name] || {})
 +        else
 +          found << name and next if scope.class_scope(klass)
 +          resource = klass.ensure_in_catalog(scope)
 +        end
  
          # If they've disabled lazy evaluation (which the :include function does),
          # then evaluate our resource immediately.
@@@ -443,11 -436,7 +447,11 @@@
      @resources = []
  
      # Make sure any external node classes are in our class list
 -    @catalog.add_class(*@node.classes)
 +    if @node.classes.class == Hash
 +      @catalog.add_class(*@node.classes.keys)
 +    else
 +      @catalog.add_class(*@node.classes)
 +    end
    end
  
    # Set the node's parameters into the top-scope as variables.
diff --combined lib/puppet/transaction.rb
index eba601c,0a3bfc3..df4c8b2
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@@ -4,8 -4,12 +4,11 @@@
  require 'puppet'
  require 'puppet/util/tagging'
  require 'puppet/application'
+ require 'puppet/util/instrumentation'
  
  class Puppet::Transaction
+   include Puppet::Util::Instrumentation
+ 
 -  require 'puppet/transaction/change'
    require 'puppet/transaction/event'
    require 'puppet/transaction/event_manager'
    require 'puppet/transaction/resource_harness'
@@@ -138,8 -142,10 +141,10 @@@
            next
          end
          ret = nil
-         seconds = thinmark do
-           ret = eval_resource(resource)
+         instrument("evaluating #{resource}") do
+           seconds = thinmark do
+             ret = eval_resource(resource)
+           end
          end
  
          resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
@@@ -221,6 -227,12 +226,6 @@@
      end
    end
  
 -  # Generate a transaction report.
 -  def generate_report
 -    @report.calculate_metrics
 -    @report
 -  end
 -
    # Should we ignore tags?
    def ignore_tags?
      ! (@catalog.host_config? or Puppet[:name] == "puppet")
@@@ -231,7 -243,7 +236,7 @@@
    def initialize(catalog)
      @catalog = catalog
  
 -    @report = Report.new
 +    @report = Puppet::Transaction::Report.new("apply")
  
      @event_manager = Puppet::Transaction::EventManager.new(self)
  
@@@ -278,6 -290,26 +283,6 @@@
      catalog.relationship_graph
    end
  
 -  # Send off the transaction report.
 -  def send_report
 -    begin
 -      report = generate_report
 -    rescue => detail
 -      Puppet.err "Could not generate report: #{detail}"
 -      return
 -    end
 -
 -    puts report.summary if Puppet[:summarize]
 -
 -    if Puppet[:report]
 -      begin
 -        report.save
 -      rescue => detail
 -        Puppet.err "Reporting failed: #{detail}"
 -      end
 -    end
 -  end
 -
    def add_resource_status(status)
      report.add_resource_status status
    end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list