diff --git a/attributes/default.rb b/attributes/default.rb index 7932dde..cf1ef8e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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 diff --git a/recipes/registration.rb b/recipes/registration.rb index 99432a4..0e8e20f 100644 --- a/recipes/registration.rb +++ b/recipes/registration.rb @@ -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 diff --git a/recipes/server-apache.rb b/recipes/server-apache.rb index 9e0979b..63e3d16 100644 --- a/recipes/server-apache.rb +++ b/recipes/server-apache.rb @@ -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 diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb index e140e71..24bdcbb 100644 --- a/spec/registration_spec.rb +++ b/spec/registration_spec.rb @@ -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 diff --git a/spec/server-apache_spec.rb b/spec/server-apache_spec.rb index 1d7bc8c..d2907dd 100644 --- a/spec/server-apache_spec.rb +++ b/spec/server-apache_spec.rb @@ -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