No message was being displayed on the server if a file could not be
opened by the file server.

Signed-off-by: Jesse Wolfe <[email protected]>
---
 lib/puppet/file_serving/mount/file.rb |    5 ++++-
 lib/puppet/network/http/handler.rb    |    1 +
 spec/unit/file_serving/mount/file.rb  |    8 ++++++++
 spec/unit/network/http/handler.rb     |   10 ++++++++++
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/file_serving/mount/file.rb 
b/lib/puppet/file_serving/mount/file.rb
index bf7ddda..4309ef7 100644
--- a/lib/puppet/file_serving/mount/file.rb
+++ b/lib/puppet/file_serving/mount/file.rb
@@ -25,7 +25,10 @@ class Puppet::FileServing::Mount::File < 
Puppet::FileServing::Mount
 
         file = ::File.join(full_path, relative_path)
 
-        return nil unless FileTest.exist?(file)
+        if ! FileTest.exist?(file)
+            Puppet.info("File does not exist or is not accessible: #{file}")
+            return nil
+        end
 
         return file
     end
diff --git a/lib/puppet/network/http/handler.rb 
b/lib/puppet/network/http/handler.rb
index 817661d..65bb0f8 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -97,6 +97,7 @@ module Puppet::Network::HTTP::Handler
     # Execute our find.
     def do_find(indirection_request, request, response)
         unless result = 
indirection_request.model.find(indirection_request.key, 
indirection_request.to_hash)
+            Puppet.info("Could not find %s for '%s'" % 
[indirection_request.indirection_name, indirection_request.key])
             return do_exception(response, "Could not find %s %s" % 
[indirection_request.indirection_name, indirection_request.key], 404)
         end
 
diff --git a/spec/unit/file_serving/mount/file.rb 
b/spec/unit/file_serving/mount/file.rb
index 837fe8e..69660d6 100755
--- a/spec/unit/file_serving/mount/file.rb
+++ b/spec/unit/file_serving/mount/file.rb
@@ -107,6 +107,14 @@ describe Puppet::FileServing::Mount::File, "when 
determining the complete file p
         @mount.complete_path("/my/path", nil).should be_nil
     end
 
+    it "should write a log message if the file is absent" do
+        FileTest.stubs(:exist?).returns(false)
+
+        Puppet.expects(:info).with("File does not exist or is not accessible: 
/mount/my/path")
+
+        @mount.complete_path("/my/path", nil)
+    end
+
     it "should return the file path if the file is present" do
         FileTest.stubs(:exist?).with("/my/path").returns(true)
         @mount.complete_path("/my/path", nil).should == "/mount/my/path"
diff --git a/spec/unit/network/http/handler.rb 
b/spec/unit/network/http/handler.rb
index 1addb58..5598121 100755
--- a/spec/unit/network/http/handler.rb
+++ b/spec/unit/network/http/handler.rb
@@ -230,6 +230,16 @@ describe Puppet::Network::HTTP::Handler do
                 @handler.do_find(@irequest, @request, @response)
             end
 
+            it "should write a log message when no model instance can be 
found" do
+                @model_class.stubs(:name).returns "my name"
+                @model_class.stubs(:find).returns(nil)
+
+                Puppet.expects(:info).with("Could not find my_handler for 
'my_result'")
+
+                @handler.do_find(@irequest, @request, @response)
+            end
+
+
             it "should serialize the result in with the appropriate format" do
                 @model_instance = stub('model instance')
 
-- 
1.6.3.3

--

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.


Reply via email to