More problems with remote_file


#1

Hi,

I seem to occasionally get some errors with remote_file when running
chef-solo. It is not consistently reproducible, but seems to occur
when I rerun a chef-solo command and the target file already exists.

This is the stack trace:

Mon, 08 Jun 2009 18:16:20 +0200] DEBUG: /helloworld-1.war 100% done
(7565054 of 7565054)
[Mon, 08 Jun 2009 18:16:20 +0200] ERROR: remote_file[test3] (/var/lib/
gems/1.8/gems/chef-0.6.2/lib/chef/recipe.rb line 187) had an error:
closed stream
/var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/provider/remote_file.rb:
76:in close'/var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/provider/ remote_file.rb:76:indo_remote_file’/var/lib/gems/1.8/gems/chef-0.6.2/
lib/chef/provider/remote_file.rb:34:in action_create'/var/lib/gems/ 1.8/gems/chef-0.6.2/lib/chef/runner.rb:87:insend’/var/lib/gems/1.8/
gems/chef-0.6.2/lib/chef/runner.rb:87:in converge'/var/lib/gems/1.8/ gems/chef-0.6.2/lib/chef/runner.rb:85:ineach’/var/lib/gems/1.8/gems/
chef-0.6.2/lib/chef/runner.rb:85:in converge'/var/lib/gems/1.8/gems/ chef-0.6.2/lib/chef/resource_collection.rb:58:ineach’/var/lib/gems/
1.8/gems/chef-0.6.2/lib/chef/resource_collection.rb:57:in each'/var/ lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:63:inconverge’/var/
lib/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:348:in converge'/var/ lib/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:96:inrun_solo’/var/
lib/gems/1.8/gems/chef-0.6.2/bin/chef-solo:118/sbin/chef-solo:19:in
load'/sbin/chef-solo:19 /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/provider/remote_file.rb: 76:inclose’: closed stream (IOError)
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/provider/
remote_file.rb:76:in do_remote_file' from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/provider/ remote_file.rb:34:inaction_create’
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:87:in send' from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:87:inconverge’
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:85:in each' from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:85:inconverge’
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/
resource_collection.rb:58:in each' from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/ resource_collection.rb:57:ineach’
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/runner.rb:63:in
converge' from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:348:inconverge’
from /var/lib/gems/1.8/gems/chef-0.6.2/lib/chef/client.rb:96:in
run_solo' from /var/lib/gems/1.8/gems/chef-0.6.2/bin/chef-solo:118 from /sbin/chef-solo:19:inload’
from /sbin/chef-solo:19

I’m not a ruby guy, but took a quick look at the code (chef 0.6.2) and
at a first glance it seems that the filehandle may be closed twice
(rest.rb:189) and in remote_file:76. But if this is true, why doesn’t
it always fail?

/Jeppe


#2

On Mon, Jun 8, 2009 at 7:16 PM, Jeppe Nejsum Madsenjeppe@ingolfs.dk wrote:

Hi,

I seem to occasionally get some errors with remote_file when running
chef-solo. It is not consistently reproducible, but seems to occur when I
rerun a chef-solo command and the target file already exists.

Hmm seems to be a platform thing. On an EC2 instance running Ubuntu
8.04, I cannot reproduce this. On an EC2 instance running 9.04 I can
consistently reproduce this…

/Jeppe


#3

On Tue, Jun 9, 2009 at 11:58 AM, Jeppe Nejsum Madsenjeppe@ingolfs.dk wrote:

On Mon, Jun 8, 2009 at 7:16 PM, Jeppe Nejsum Madsenjeppe@ingolfs.dk wrote:

Hi,

I seem to occasionally get some errors with remote_file when running
chef-solo. It is not consistently reproducible, but seems to occur when I
rerun a chef-solo command and the target file already exists.

Hmm seems to be a platform thing. On an EC2 instance running Ubuntu
8.04, I cannot reproduce this. On an EC2 instance running 9.04 I can
consistently reproduce this…

/Jeppe

And just to keep the dialogue with myself: I’m pretty sure it’s
caused by Ruby 1.8.7 which is default on Ubuntu 9.04. Downgrading to
1.8.6 solves the problem.

The strange part is that it only happens on some files. I’ve created a
very small test scenario which consistently fails on 9.04 after the
first successful run. After downgrading to Ruby 1.8.6, I can run this
scenario several times without failure:

  1. Create solo.rb
    cookbook_path "/etc/chef/recipes/cookbooks"
    log_level :debug
    file_store_path "/var/chef/files/"
    file_cache_path “/etc/chef/recipes”

  2. gem install --no-ri --no-rdoc --bindir /sbin ohai chef --source
    http://gems.opscode.com --source http://gems.rubyforge.org

  3. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

  4. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

The last step always fails for the last file when running on 9.04 with
Ruby 1.8.7 but works with Ruby 1.8.6

/Jeppe


#4

Jeppe, can you try this with 0.7.0?

Sent from my iPhone

On Jun 9, 2009, at 6:11 AM, Jeppe Nejsum Madsen jeppe@ingolfs.dk
wrote:

On Tue, Jun 9, 2009 at 11:58 AM, Jeppe Nejsum
Madsenjeppe@ingolfs.dk wrote:

On Mon, Jun 8, 2009 at 7:16 PM, Jeppe Nejsum
Madsenjeppe@ingolfs.dk wrote:

Hi,

I seem to occasionally get some errors with remote_file when running
chef-solo. It is not consistently reproducible, but seems to occur
when I
rerun a chef-solo command and the target file already exists.

Hmm seems to be a platform thing. On an EC2 instance running Ubuntu
8.04, I cannot reproduce this. On an EC2 instance running 9.04 I can
consistently reproduce this…

/Jeppe

And just to keep the dialogue with myself: I’m pretty sure it’s
caused by Ruby 1.8.7 which is default on Ubuntu 9.04. Downgrading to
1.8.6 solves the problem.

The strange part is that it only happens on some files. I’ve created a
very small test scenario which consistently fails on 9.04 after the
first successful run. After downgrading to Ruby 1.8.6, I can run this
scenario several times without failure:

  1. Create solo.rb
    cookbook_path "/etc/chef/recipes/cookbooks"
    log_level :debug
    file_store_path "/var/chef/files/"
    file_cache_path “/etc/chef/recipes”

  2. gem install --no-ri --no-rdoc --bindir /sbin ohai chef --source
    http://gems.opscode.com --source http://gems.rubyforge.org

  3. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

  4. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

The last step always fails for the last file when running on 9.04 with
Ruby 1.8.7 but works with Ruby 1.8.6

/Jeppe


#5

Seems to work. At least unable to reproduce with the steps below. Nice!

Was this a deliberate fix or just fixed by coincidence?

/Jeppe

On 10/06/2009, at 04.09, Adam Jacob wrote:

Jeppe, can you try this with 0.7.0?

Sent from my iPhone

On Jun 9, 2009, at 6:11 AM, Jeppe Nejsum Madsen jeppe@ingolfs.dk
wrote:

On Tue, Jun 9, 2009 at 11:58 AM, Jeppe Nejsum
Madsenjeppe@ingolfs.dk wrote:

On Mon, Jun 8, 2009 at 7:16 PM, Jeppe Nejsum
Madsenjeppe@ingolfs.dk wrote:

Hi,

I seem to occasionally get some errors with remote_file when
running
chef-solo. It is not consistently reproducible, but seems to
occur when I
rerun a chef-solo command and the target file already exists.

Hmm seems to be a platform thing. On an EC2 instance running Ubuntu
8.04, I cannot reproduce this. On an EC2 instance running 9.04 I can
consistently reproduce this…

/Jeppe

And just to keep the dialogue with myself: I’m pretty sure it’s
caused by Ruby 1.8.7 which is default on Ubuntu 9.04. Downgrading to
1.8.6 solves the problem.

The strange part is that it only happens on some files. I’ve
created a
very small test scenario which consistently fails on 9.04 after the
first successful run. After downgrading to Ruby 1.8.6, I can run this
scenario several times without failure:

  1. Create solo.rb
    cookbook_path "/etc/chef/recipes/cookbooks"
    log_level :debug
    file_store_path "/var/chef/files/"
    file_cache_path “/etc/chef/recipes”

  2. gem install --no-ri --no-rdoc --bindir /sbin ohai chef --source
    http://gems.opscode.com --source http://gems.rubyforge.org

  3. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json
    -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

  4. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json
    -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

The last step always fails for the last file when running on 9.04
with
Ruby 1.8.7 but works with Ruby 1.8.6

/Jeppe


#6

It was deliberate - I added a guard to ensure that, no matter how we
get the filehandle, it’s only closed if it’s open.

Adam

On Tue, Jun 9, 2009 at 11:55 PM, Jeppe Nejsum Madsenjeppe@ingolfs.dk wrote:

Seems to work. At least unable to reproduce with the steps below. Nice!

Was this a deliberate fix or just fixed by coincidence?

/Jeppe

On 10/06/2009, at 04.09, Adam Jacob wrote:

Jeppe, can you try this with 0.7.0?

Sent from my iPhone

On Jun 9, 2009, at 6:11 AM, Jeppe Nejsum Madsen jeppe@ingolfs.dk wrote:

On Tue, Jun 9, 2009 at 11:58 AM, Jeppe Nejsum Madsenjeppe@ingolfs.dk
wrote:

On Mon, Jun 8, 2009 at 7:16 PM, Jeppe Nejsum Madsenjeppe@ingolfs.dk
wrote:

Hi,

I seem to occasionally get some errors with remote_file when running
chef-solo. It is not consistently reproducible, but seems to occur when
I
rerun a chef-solo command and the target file already exists.

Hmm seems to be a platform thing. On an EC2 instance running Ubuntu
8.04, I cannot reproduce this. On an EC2 instance running 9.04 I can
consistently reproduce this…

/Jeppe

And just to keep the dialogue with myself: I’m pretty sure it’s
caused by Ruby 1.8.7 which is default on Ubuntu 9.04. Downgrading to
1.8.6 solves the problem.

The strange part is that it only happens on some files. I’ve created a
very small test scenario which consistently fails on 9.04 after the
first successful run. After downgrading to Ruby 1.8.6, I can run this
scenario several times without failure:

  1. Create solo.rb
    cookbook_path "/etc/chef/recipes/cookbooks"
    log_level :debug
    file_store_path "/var/chef/files/"
    file_cache_path “/etc/chef/recipes”

  2. gem install --no-ri --no-rdoc --bindir /sbin ohai chef --source
    http://gems.opscode.com --source http://gems.rubyforge.org

  3. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

  4. chef-solo -c solo.rb -j http://jnmtest.s3.amazonaws.com/dna.json -l
    debug -r http://jnmtest.s3.amazonaws.com/cookbooks.tgz

The last step always fails for the last file when running on 9.04 with
Ruby 1.8.7 but works with Ruby 1.8.6

/Jeppe


Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-4759 E: adam@opscode.com