sous-chefs / rundeck

Development repository for the rundeck cookbook
https://supermarket.chef.io/cookbooks/rundeck
Apache License 2.0
46 stars 68 forks source link

Rundeck service start & restart should wait for HTTP calls to succeed #143

Closed tryan225 closed 7 years ago

tryan225 commented 7 years ago

  1) RundeckApiClient correctly reads the rundeck server api version
     Failure/Error: described_class.connect('http://localhost', 'admin', 'adminpassword')
     Net::HTTPFatalError:
       503 "Service Unavailable"

     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:60:in `send_req'
     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:15:in `authenticate'
     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:30:in `connect'
     # /opt/verifier/suites/serverspec/localhost/rundeck_api_client_spec.rb:5:in `block (2 levels) in <top (required)>'
     # /opt/verifier/suites/serverspec/localhost/rundeck_api_client_spec.rb:27:in `block (2 levels) in <top (required)>'
  2) RundeckApiClient manages projects
     Failure/Error: described_class.connect('http://localhost', 'admin', 'adminpassword')
     Net::HTTPFatalError:
       503 "Service Unavailable"

     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:60:in `send_req'
     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:15:in `authenticate'
     # /opt/kitchen/cookbooks/rundeck/libraries/rundeck_api_client.rb:30:in `connect'
     # /opt/verifier/suites/serverspec/localhost/rundeck_api_client_spec.rb:5:in `block (2 levels) in <top (required)>'
     # /opt/verifier/suites/serverspec/localhost/rundeck_api_client_spec.rb:31:in `block (2 levels) in <top (required)>'
Finished in 1.64 seconds (files took 1.17 seconds to load)
88 examples, 2 failures```
atheiman commented 7 years ago

problem here is the init script doesnt actually check to ensure rundeck has restarted https://github.com/rundeck/rundeck/blob/master/packaging/root/etc/rc.d/init.d/rundeckd

need to log an issue to that repo to add that to the init script

i think we could do a workaround in this cookbook with something like

service 'rundeckd' do
  start_command "service rundeckd start && until curl '#{rundeck_url}'; do sleep 5; done"
  restart_command "service rundeckd restart && until curl '#{rundeck_url}'; do sleep 5; done"
  status_command "service rundeckd status && until curl '#{rundeck_url}'; do sleep 5; done"
end
atheiman commented 7 years ago

another option here for a workaround is something like

ruby_block 'wait for rundeck startup' do
  action :nothing
  block do
    require 'socket'
    require 'timeout'
    Timeout::timeout(1) { TCPSocket.new('127.0.0.1', 80).close }
  end
  retries node['rundeck']['service']['retries']
  retry_delay node['rundeck']['service']['retry_delay']
  subscribes :run, 'service[rundeckd]', :immediately
end

http://ruby-doc.org/stdlib-2.3.3/libdoc/timeout/rdoc/Timeout.html#method-c-timeout https://ruby-doc.org/stdlib-2.3.3/libdoc/socket/rdoc/TCPSocket.html#method-c-new

atheiman commented 7 years ago

This was fixed in #133

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.