Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Unknown
-
Resolution: Unresolved
-
Affects Version/s: 10.12.0
-
Fix Version/s: 10.12.0
-
Component/s: Chef Server
-
Labels:None
-
Environment:
Amazon EC2 medium instance
Description
I got the following stack trace when I tried to run chef-solr.
/home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/lib/chef/solr/application/solr.rb:268:in `reopen': closed stream (IOError) from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/lib/chef/solr/application/solr.rb:268:in `close_and_reopen_log_file' from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/lib/chef/solr/application/solr.rb:258:in `block in run_application' from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/lib/chef/solr/application/solr.rb:249:in `chdir' from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/lib/chef/solr/application/solr.rb:249:in `run_application' from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-10.12.0/lib/chef/application.rb:70:in `run' from /home/chef/vendor/bundle/ruby/1.9.1/gems/chef-solr-10.12.0/bin/chef-solr:26:in `<top (required)>' from /home/chef/vendor/bundle/ruby/1.9.1/bin/chef-solr:23:in `load' from /home/chef/vendor/bundle/ruby/1.9.1/bin/chef-solr:23:in `<main>'
The error is raised when I run the following command. (I know it's non-standard and not reproducible, but bear with me.)
RBENV_ROOT=/usr/local/lib/rbenv sudo -E -u chef -- rbenv exec bundle exec chef-solr -c /usr/local/etc/chef/solr.rb -L /usr/local/var/log/chef/solr.log
The important part is that I ran chef-solr on a TTY and not as a daemon, which is reminiscent of a previous ticket. After some digging, I found that STDOUT was closed by this line of code (1), and the subsequent line triggers the error (2). This led me to these lines (#close triggers #method_missing) and finally these lines. Notice that all of the conditions are satisfied, and hence an STDOUT Logger is appended to the Logger list, which eventually brings us back to the stack trace from (1) followed by (2).
I've developed a quick and dirty solution here, which is to modify the STDOUT Logger's metaclass to have a no-op #close method. Another hack is to pipe the result of chef-solr invocation to a file, thus failing the conditional and not creating an STDOUT logger in the first place.
Thank you for taking the time to help make Chef better! We require a Contributor License Agreement (CLA) from contributors to help protect all Chef users. It is easy to complete one online. Instructions to do so are on our wiki, which is linked below. Once your account is updated, you will have access to 'resolve' tickets that indicates to the code review team that your contribution is ready for review.
http://wiki.opscode.com/display/chef/How+to+Contribute