Re: [Puppet Users] Re: getting empty files from fileserver

5 views
Skip to first unread message

Brice Figureau

unread,
Aug 4, 2010, 9:47:19 AM8/4/10
to puppet...@googlegroups.com, puppe...@googlegroups.com
On Wed, 2010-08-04 at 23:34 +1000, Nicolas Brisac wrote:
> I'm getting the same error with a new custom fact in <module>/lib.
> The puppetmaster is running on Apache2 + Passenger (setup works fine
> in production with 0.24.8).
>
> With Puppet 2.6.0 (Debian package) the file is created empty.
> With Puppet 2.6.0 + patch from Brice, I get a 'Could not set file on
> ensure: Error 500' on the client side and the apache logs on the
> server shows:
>
> [Wed Aug 04 23:01:46 2010] [error] [client 192.168.200.199] Premature
> end of script headers: vzbackup.rb
> [ pid=28420 file=ext/apache2/Hooks.cpp:735 time=2010-08-04
> 23:01:46.242 ]:
> The backend application (process 28465) didn't send a valid HTTP
> response. It might have crashed during the middle of sending an HTTP
> response, so please check whether there are crashing problems in your
> application. This is the data that it sent: [Content-Type]
> *** Exception NoMethodError in
> PhusionPassenger::Rack::ApplicationSpawner (undefined method `each'
> for 1268:Fixnum) (process 28465):

OK, I just had a look to the passenger code and this is insane.
I think the problem is that we return the content-length as an int, but
passenger chokes if it gets anything except a string.

Can you try this (untested) patch:

diff --git a/lib/puppet/network/http/rack/rest.rb b/lib/puppet/network/http/rack/rest.rb
index e5f50c4..b7e1d97 100644
--- a/lib/puppet/network/http/rack/rest.rb
+++ b/lib/puppet/network/http/rack/rest.rb
@@ -41,7 +41,7 @@ class Puppet::Network::HTTP::RackREST < Puppet::Network::HTTP::RackHttpHandler
unless result.is_a?(File)
response.write result
else
- response["Content-Length"] = result.stat.size
+ response["Content-Length"] = result.stat.size.to_s
response.body = RackFile.new(result)
end
end

Let me know if that fixes the problem,
--
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!

Markus Roberts

unread,
Aug 4, 2010, 11:26:23 AM8/4/10
to puppe...@googlegroups.com, puppet...@googlegroups.com
Brice --

If that doesn't pan out could the problem be with our format_to_mime
(i.e. the content type, rather than the content length)? That seems
equally odd, but it would explain why there isn't widespread
discussion of the problem (which I would expect if passenger were
requiring content length to be an string)--if we're somehow returning
an integer for the Content-Type it would be a problem that only we
would see.

-- Markus

-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it.  ~George Bernard Shaw
------------------------------------------------------------

Brice Figureau

unread,
Aug 4, 2010, 11:47:41 AM8/4/10
to puppe...@googlegroups.com
On Wed, 2010-08-04 at 08:26 -0700, Markus Roberts wrote:
> Brice --
>
> If that doesn't pan out could the problem be with our format_to_mime
> (i.e. the content type, rather than the content length)?

This returns format.mime (format being the current renderer), which I
hope is a string or we'll have some troubles :-)

> That seems equally odd, but it would explain why there isn't widespread
> discussion of the problem (which I would expect if passenger were
> requiring content length to be an string)--if we're somehow returning
> an integer for the Content-Type it would be a problem that only we
> would see.

I suppose people don't use content-length with passenger (ie they user
chunk enconding), or they sanitize their headers to be strings.
And I think most if not all users don't set content-length themselves,
they just do: response.write(body), and rack does:
s = str.to_s
@length += Rack::Utils.bytesize(s)
@writer.call s

header["Content-Length"] = @length.to_s

(notice the to_s).

Except, we are streaming the file (with the rack's help) so we have to
set the content-length ourselves.

We indeed set content-length as an int (ie file.stat.size), and reading
passenger rack code:

headers.each do |key, values|
if values.is_a?(String)
values = values.split("\n")
end
values.each do |value|
output.write("#{key}: #{value}#{CRLF}")
end
end

Which is coherent with the error message. If we ask users the size of
the file it chokes on, I'm sure will find that it matches the fixnum we
find in the exception.

This just means I should setup a passenger setup (I was testing our rack
support with jruby/jetty-rackup and mongrel/rackup) as it differs from
other rack consumer :(

Markus Roberts

unread,
Aug 4, 2010, 12:03:34 PM8/4/10
to puppe...@googlegroups.com
Brice --

Agreed on almost everything with one niggling doubt.

> Which is coherent with the error message. If we ask users the size of
> the file it chokes on, I'm sure will find that it matches the fixnum we
> find in the exception.

You are probably correct but it looks as if the error message:

> This is the data that it sent: [Content-Type]
> *** Exception NoMethodError in
> PhusionPassenger::Rack::ApplicationSpawner (undefined method `each'
> for 1268:Fixnum) (process 28465):

...is referring to content type (which could just be the last thing it
processed successfully) and not to content length.

Still, if I had to bet I'd say that you're more likely to be correct.

Nicolas Brisac

unread,
Aug 4, 2010, 7:10:08 PM8/4/10
to puppe...@googlegroups.com
Yes I can confirm that:
This is the data that it sent: [Content-Type]
*** Exception NoMethodError in
PhusionPassenger::Rack::ApplicationSpawner (undefined method `each'
for 1268:Fixnum) (process 28465):

Which is coherent with the error message. If we ask users the size of
the file it chokes on, I'm sure will find that it matches the fixnum we
find in the exception.

-rw-r--r-- 1 root root 1268 Aug  4 19:08 /etc/puppet/services/s_ovzhost/lib/facter/vzbackup.rb
Reply all
Reply to author
Forward
0 new messages