Chef

not_if and only_if cause exceptions in popen4

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 0.5.2
  • Fix Version/s: 0.5.4
  • Component/s: Chef Client
  • Labels:
    None

Description

[Fri, 30 Jan 2009 04:05:20 -0700] ERROR: execute[/bin/touch /tmp/thisfile] (/srv/chef/cache/cookbooks/test/recipes/default.rb line 1) had an error:
closed stream
/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `close'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `not_if'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:296:in `[]'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:296:in `popen4'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `not_if'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/runner.rb:77:in `converge'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/resource_collection.rb:58:in `each'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/resource_collection.rb:57:in `each'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/runner.rb:63:in `converge'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:343:in `converge'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:76:in `run'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:114/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:108:in `loop'/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:108/usr/bin/chef-client:19:in `load'/usr/bin/chef-client:19
/usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `close': closed stream (IOError)
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `not_if'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:296:in `[]'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:296:in `popen4'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/mixin/command.rb:78:in `not_if'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/runner.rb:77:in `converge'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/resource_collection.rb:58:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/resource_collection.rb:57:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/runner.rb:63:in `converge'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:343:in `converge'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/lib/chef/client.rb:76:in `run'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:114
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:108:in `loop'
from /usr/lib/ruby/gems/1.8/gems/chef-0.5.3/bin/chef-client:108
from /usr/bin/chef-client:19:in `load'
from /usr/bin/chef-client:19

contents of test/recipes/default.rb:

execute "/bin/touch /tmp/thisfile" do
not_if "/usr/bin/test -f /tmp/thisfile"
end

Comment out not_if and the recipe is applied successfully:

[Fri, 30 Jan 2009 04:08:12 -0700] INFO: Storing updated cookbooks/test/recipes/default.rb in the cache.
[Fri, 30 Jan 2009 04:08:14 -0700] INFO: Ran execute[/bin/touch /tmp/thisfile] successfully
[Fri, 30 Jan 2009 04:08:14 -0700] INFO: Chef Run complete in 11.177254 seconds

This happens with chef 0.5.2 and 0.5.3.

Activity

Hide
Adam Jacob added a comment - 05/Feb/09 5:49 PM

This issue is caused by us closing STDIN before we run the command within the control block for only_if and not_if. This is likely a two line patch.

Show
Adam Jacob added a comment - 05/Feb/09 5:49 PM This issue is caused by us closing STDIN before we run the command within the control block for only_if and not_if. This is likely a two line patch.
Hide
Adam Jacob added a comment - 05/Feb/09 7:58 PM

This has been fixed in Opscode/head - Josh, can you confirm fixed and close the ticket?

Show
Adam Jacob added a comment - 05/Feb/09 7:58 PM This has been fixed in Opscode/head - Josh, can you confirm fixed and close the ticket?
Hide
Joshua Timberman added a comment - 05/Feb/09 8:07 PM

[Fri, 30 Jan 2009 06:50:12 -0700] INFO: Ran execute[/bin/touch /tmp/thisfile] successfully

with

execute "/bin/touch /tmp/thisfile" do
only_if "/usr/bin/test ! -f /tmp/thisfile"
end

or

execute "/bin/touch /tmp/thisfile" do
not_if "/usr/bin/test -f /tmp/thisfile"
end

Show
Joshua Timberman added a comment - 05/Feb/09 8:07 PM [Fri, 30 Jan 2009 06:50:12 -0700] INFO: Ran execute[/bin/touch /tmp/thisfile] successfully with execute "/bin/touch /tmp/thisfile" do only_if "/usr/bin/test ! -f /tmp/thisfile" end or execute "/bin/touch /tmp/thisfile" do not_if "/usr/bin/test -f /tmp/thisfile" end

People

Vote (0)
Watch (0)

Dates

  • Created:
    05/Feb/09 5:25 PM
    Updated:
    05/Feb/09 8:07 PM
    Resolved:
    05/Feb/09 7:58 PM