Wait for identity endpoint instead of sleeping
* added a small ruby block with a loop to check if the keystonen admin endpoint is up before trying to register projects, users etc. * will wait 60 seconds for admin endpoint to become ready and raise error specific exception otherwise if Timeout::Error was raised Change-Id: Ief678b0f40685e91ced9bddde95b916f4587b330
This commit is contained in:
parent
ade1b23af8
commit
9f8ba8fda6
|
@ -54,9 +54,6 @@ default['openstack']['identity']['catalog']['backend'] = 'sql'
|
|||
# identity service token backend for user and service tokens
|
||||
default['openstack']['identity']['token']['backend'] = 'sql'
|
||||
|
||||
# identity service startup delay, in seconds
|
||||
default['openstack']['identity']['start_delay'] = 10
|
||||
|
||||
# Specify a location to retrieve keystone-paste.ini from
|
||||
# which can either be a remote url using http:// or a
|
||||
# local path to a file using file:// which would generally
|
||||
|
|
|
@ -64,6 +64,22 @@ connection_params = {
|
|||
openstack_domain_name: admin_domain
|
||||
}
|
||||
|
||||
ruby_block 'wait for identity admin endpoint' do
|
||||
block do
|
||||
begin
|
||||
Timeout.timeout(60) do
|
||||
until Net::HTTP.get_response(URI(auth_url)).message == 'OK'
|
||||
Chef::Log.info 'waiting for identity admin endpoint to be up...'
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
rescue Timeout::Error
|
||||
raise 'Waited 60 seconds for identity admin endpoint to become ready'\
|
||||
' and will not wait any longer'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
openstack_domain admin_domain do
|
||||
connection_params connection_params
|
||||
end
|
||||
|
|
|
@ -335,17 +335,9 @@ apache_site 'keystone' do
|
|||
enable false
|
||||
end
|
||||
|
||||
# wait for apache2 to be fully reloaded and the keystone endpoint to become
|
||||
# available
|
||||
execute 'Keystone: sleep' do
|
||||
command "sleep #{node['openstack']['identity']['start_delay']}"
|
||||
action :nothing
|
||||
end
|
||||
|
||||
# Hack until Apache cookbook has lwrp's for proper use of notify
|
||||
# restart apache2 after keystone if completely configured
|
||||
execute 'Keystone apache restart' do
|
||||
command 'uname'
|
||||
notifies :restart, 'service[apache2]', :immediately
|
||||
notifies :run, 'execute[Keystone: sleep]', :immediately
|
||||
end
|
||||
|
|
|
@ -44,6 +44,11 @@ describe 'openstack-identity::registration' do
|
|||
--bootstrap-public-url #{public_url} \\
|
||||
--bootstrap-internal-url #{internal_url}")
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to run_ruby_block('wait for identity admin endpoint')
|
||||
end
|
||||
|
||||
it "registers #{domain_name} domain" do
|
||||
expect(chef_run).to create_openstack_domain(
|
||||
domain_name
|
||||
|
|
|
@ -473,9 +473,8 @@ describe 'openstack-identity::server-apache' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'restart apache and sleep' do
|
||||
describe 'restart apache' do
|
||||
let(:restart) { chef_run.execute('Keystone apache restart') }
|
||||
let(:sleep) { chef_run.execute('Keystone: sleep') }
|
||||
|
||||
it 'has restart resource' do
|
||||
expect(chef_run).to run_execute(restart.name).with(
|
||||
|
@ -483,17 +482,9 @@ describe 'openstack-identity::server-apache' do
|
|||
)
|
||||
end
|
||||
|
||||
it 'has sleep resource' do
|
||||
expect(sleep.command).to eq('sleep 10')
|
||||
end
|
||||
|
||||
it 'has notified apache to restart' do
|
||||
expect(restart).to notify('service[apache2]').to(:restart).immediately
|
||||
end
|
||||
|
||||
it 'has notified sleep to run' do
|
||||
expect(restart).to notify("execute[#{sleep.name}]").to(:run).immediately
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue