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.

cherry-picked from Change-Id: Ief678b0f40685e91ced9bddde95b916f4587b330

Change-Id: I1c057fc4f5eb1dc59352938923f95f521ea2f403
This commit is contained in:
Jan Klare 2016-11-23 13:04:05 +01:00
parent 434763a5aa
commit d3b85b93e0
5 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -46,6 +46,22 @@ identity_tenants = node['openstack']['identity']['users'].values.map do |user_in
user_info['roles'].values.push(user_info['default_tenant'])
end
ruby_block 'wait for identity admin endpoint' do
block do
begin
Timeout.timeout(60) do
until Net::HTTP.get_response(URI(auth_uri)).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
identity_tenants.flatten.uniq.each do |tenant_name|
openstack_identity_register "Register '#{tenant_name}' Tenant" do
auth_uri auth_uri

View File

@ -334,17 +334,9 @@ wsgi_apps.each do |app, opt|
end
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

View File

@ -24,6 +24,10 @@ describe 'openstack-identity::registration' do
include_context 'identity_stubs'
describe 'tenant registration' do
it do
expect(chef_run).to run_ruby_block('wait for identity admin endpoint')
end
context 'default tenants' do
['admin'].each do |tenant_name|
it "registers the #{tenant_name} tenant" do

View File

@ -478,9 +478,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(
@ -488,17 +487,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