Comments (13)
Thanks for getting this into here @cixelsyd.
We've seen similar issues where using popen4
is creating some issues on windows. I think the right path here would be to switch using shell_out
instead of output_of_command
to execute the command.
The conversion should be pretty straightforward. If you'd like to make a shot at this let me know and I'll give you some pointers to get you started.
Thanks again for spending time and working with us on this.
from chef.
I'm excited to work with you on this. let me know how I can help!
Steven
mobile
On Jun 24, 2014, at 4:21 PM, Serdar Sutay [email protected] wrote:
Thanks for getting this into here @cixelsyd.
We've seen similar issues where using popen4 is creating some issues on windows. I think the right path here would be to switch using shell_out instead of output_of_command to execute the command.
The conversion should be pretty straightforward. If you'd like to make a shot at this let me know and I'll give you some pointers to get you started.
Thanks again for spending time and working with us on this.
—
Reply to this email directly or view it on GitHub.
from chef.
Awesome @cixelsyd. shell_out()
is the Chef's platform independenct command execution system which takes care of a lot of the nasty stuff. We need to replace the output_of_command
functions with shell_out
calls in the lib/chef/provider/subversion.rb
file.
You can see a really good example here: https://github.com/opscode/chef/blob/master/lib/chef/provider/git.rb#L123
LMK if you have any questions or help to move forward and thanks so much for spending your time on this 😄
from chef.
has this been fixed already? or is there any workaround for it? I have this same problem. Thanks in advance!
from chef.
As a workaround for this bug i did the following,
-
Create a file in libraries folder of a cookbook that is presenting the error or one that you always include in your runlists
-
Into that file, add the following code:
class Chef module Mixin module Command extend self def handle_command_failures(status, command_output, opts={}) unless opts[:ignore_failure] opts[:returns] ||= 0 unless Array([opts[:returns],42]).include?(status.exitstatus) # if the log level is not debug, through output of command when we fail output = "" if Chef::Log.level == :debug || opts[:output_on_failure] output << "\n---- Begin output of #{opts[:command]} ----\n" output << command_output.to_s output << "\n---- End output of #{opts[:command]} ----\n" end raise Chef::Exceptions::Exec, "#{opts[:command]} returned #{status.exitstatus}, expected #{opts[:returns]}#{output}" end end end module Windows def popen4(cmd, args={}, &b) # By default, we are waiting before we yield the block. args[:waitlast] ||= false #XXX :user, :group, :environment support? Open3.popen3(cmd) do |stdin,stdout,stderr,cid| if b if args[:waitlast] b[cid, stdin, stdout, stderr] # send EOF so that if the child process is reading from STDIN # it will actually finish up and exit stdin.close_write else o = StringIO.new e = StringIO.new stdin.close stdout.sync = true stderr.sync = true line = stdout.gets(nil) if line o.write(line) end line = stderr.gets(nil) if line e.write(line) end o.rewind e.rewind b[cid, stdin, o, e] end else [cid, stdin, stdout, stderr] end end `ls` if $?.nil? Chef::Log.debug ". : : : $? returned nil for command #{cmd} : : : ." $? end end end end end
the lines that do the trick are:
unless Array([opts[:returns],42]).include?(status.exitstatus)
and
`ls` if $?.nil?
Chef::Log.debug ". : : : $? returned nil for command #{cmd} : : : ."
(of course, you can erase the debug printing if you want to)
that way you don't need to fix something for every chef release if it's not fixed yet.
I hope it's useful for someone else.
from chef.
It'd be better to get a PR that just replaced the commands with mixlib-shellout
from chef.
Thanks @jgutierrezc. This work very well for me.
from chef.
Should have been fixed by 7b26c36 and prior commits
from chef.
(should be fixed in 12.1.0)
from chef.
This code:
subversion 'couchdb' do
repository 'http://svn.apache.org/repos/asf/couchdb/trunk'
revision 'HEAD'
action :sync
end
run with: chef-apply svn.rb -l debug
fails at line https://github.com/chef/chef/blob/master/lib/chef/provider/subversion.rb#L133:
status, svn_info, error_message = output_of_command(command, run_options)
because output_of_command
is still trying to access status.exitstatus
I'll put this on my work backlog to replace output_of_command
with shell_out!
, but I'm unlikely to whack this off soon.
EDIT: I forgot to mention: This is a Windows issue
from chef.
I just ran into this in exactly the way @pburkholder mentioned. Can this issue be reopened?
from chef.
The above PR fixes this for me.
from chef.
this looks like it got fixed
from chef.
Related Issues (20)
- Omnitruck artifact does not exist for Rocky Linux HOT 11
- Expose "--filter-waived-controls" option to chef client compliance phase
- Mount resource failing to execute after first run. HOT 1
- only_if / not_if command guard with lazy behavior
- Hostname resource does not set fqdn on MacOS/Darwin HOT 1
- bundle exec knife fail with attempt to use deprecated `untaint` method HOT 1
- `openssl_x509_certificate` handles CN in a way that violates the x509 spec
- sleep is not a built-in Windows command. This depends on Win2K3 resource kit. Suggest timeout be used instead. HOT 3
- Chef fails with inspec 6.6 HOT 1
- Cannot build chef from source using `omnibus`
- Cannot build chef from source using `omnibus` HOT 1
- Sensitive properties of custom resources leaked via failed regex constraints
- windows_security_policy incorrectly reporting updates
- Net::HTTPServerException: 405 "Not Allowed" while saving node at the end of a chef-client run / node bootstrap HOT 2
- Lazy node attributes aren't "un-lazied" in some contexts
- Release schedule documentation is out of date HOT 2
- [Chef 18] chef_client_config breaks with `rights` in the current code base HOT 2
- Start a service after enabling it HOT 3
- Cloud helper functions return incorrect results after nodes are moved between clouds (Azure -> AWS)
- 18.4.2 windows_service property "description": NoMethodError HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chef.