summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-07-25 13:06:02 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-07-25 13:06:02 -0700
commitc7361629dff08d506209f806f0d903a0e968da06 (patch)
tree445822533e15cd0e9e081440852ac4cef0f35458
parent69acbb026145f7c5042cbb32ea0fbcfe88865897 (diff)
parent89c021cac52a4bdecbe490772cb73cef9ef049c5 (diff)
downloadpuppet-c7361629dff08d506209f806f0d903a0e968da06.tar.gz
puppet-c7361629dff08d506209f806f0d903a0e968da06.tar.xz
puppet-c7361629dff08d506209f806f0d903a0e968da06.zip
Merge branch 'ticket/2.6.x/8418-inspect_respect_run_mode' into 2.6.x
* ticket/2.6.x/8418-inspect_respect_run_mode: (#8418) Fix inspect app to have the correct run_mode maint: Adding logging to include environment when source fails maint: Add debug logging when the master receives a report
-rw-r--r--lib/puppet/application/inspect.rb7
-rw-r--r--lib/puppet/indirector/report/processor.rb2
-rwxr-xr-xlib/puppet/type/file/source.rb2
-rwxr-xr-xspec/unit/application/inspect_spec.rb5
-rwxr-xr-xspec/unit/indirector/report/processor_spec.rb12
5 files changed, 20 insertions, 8 deletions
diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb
index ce32c661c..2260feed7 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -1,6 +1,4 @@
-require 'puppet'
require 'puppet/application'
-require 'puppet/file_bucket/dipper'
class Puppet::Application::Inspect < Puppet::Application
@@ -97,6 +95,11 @@ Licensed under the GNU General Public License version 2
Puppet::Resource::Catalog.terminus_class = :yaml
end
+ def preinit
+ require 'puppet'
+ require 'puppet/file_bucket/dipper'
+ end
+
def run_command
benchmark(:notice, "Finished inspection") do
retrieval_starttime = Time.now
diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb
index 88fe4b487..81b379eb8 100644
--- a/lib/puppet/indirector/report/processor.rb
+++ b/lib/puppet/indirector/report/processor.rb
@@ -20,9 +20,11 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code
# LAK:NOTE This isn't necessarily the best design, but it's backward
# compatible and that's good enough for now.
def process(report)
+ Puppet.debug "Recieved report to process from #{report.host}"
return if Puppet[:reports] == "none"
reports.each do |name|
+ Puppet.debug "Processing report from #{report.host} with processor #{name}"
if mod = Puppet::Reports.report(name)
# We have to use a dup because we're including a module in the
# report.
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 6ebec51fe..2fb65bbad 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -154,7 +154,7 @@ module Puppet
fail detail, "Could not retrieve file metadata for #{source}: #{detail}"
end
end
- fail "Could not retrieve information from source(s) #{value.join(", ")}" unless result
+ fail "Could not retrieve information from environment #{Puppet[:environment]} source(s) #{value.join(", ")}" unless result
result
end
diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb
index d334a87ee..637a95d42 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -13,6 +13,11 @@ describe Puppet::Application::Inspect do
before :each do
@inspect = Puppet::Application[:inspect]
+ @inspect.preinit
+ end
+
+ it "should operate in agent run_mode" do
+ @inspect.class.run_mode.name.should == :agent
end
describe "during setup" do
diff --git a/spec/unit/indirector/report/processor_spec.rb b/spec/unit/indirector/report/processor_spec.rb
index 5602a271f..ac3162886 100755
--- a/spec/unit/indirector/report/processor_spec.rb
+++ b/spec/unit/indirector/report/processor_spec.rb
@@ -25,9 +25,11 @@ describe Puppet::Transaction::Report::Processor, " when saving a report" do
it "should not process the report if reports are set to 'none'" do
Puppet::Reports.expects(:report).never
- Puppet.settings.expects(:value).with(:reports).returns("none")
+ Puppet[:reports] = 'none'
- request = stub 'request', :instance => mock("report")
+ request = Puppet::Indirector::Request.new(:indirection_name, :head, "key")
+ report = Puppet::Transaction::Report.new('apply')
+ request.instance = report
@reporter.save(request)
end
@@ -40,14 +42,14 @@ end
describe Puppet::Transaction::Report::Processor, " when processing a report" do
before do
- Puppet.settings.stubs(:value).with(:reports).returns("one")
+ Puppet[:reports] = "one"
Puppet.settings.stubs(:use)
@reporter = Puppet::Transaction::Report::Processor.new
@report_type = mock 'one'
@dup_report = mock 'dupe report'
@dup_report.stubs(:process)
- @report = mock 'report'
+ @report = Puppet::Transaction::Report.new('apply')
@report.expects(:dup).returns(@dup_report)
@request = stub 'request', :instance => @report
@@ -74,7 +76,7 @@ describe Puppet::Transaction::Report::Processor, " when processing a report" do
end
it "should not raise exceptions" do
- Puppet.settings.stubs(:value).with(:trace).returns(false)
+ Puppet[:trace] = false
@dup_report.expects(:process).raises(ArgumentError)
proc { @reporter.save(@request) }.should_not raise_error
end