Remove race condition at ceilometer::db initialisation

On the first run, the ceilometer::db class was failing due to the fact
that the MongoDB service was not actually listening yet when it came
to it. It return with an ERRNO 111 - ECONNREFUSED.

This patch adds a dependency to ceilometer::db, this dependency ensure
that the MongoDB service is listening before giving the hand to ceilometer::db.

close #13
This commit is contained in:
Yanis Guenane 2014-01-19 10:29:30 -05:00
parent 5bad6ae02d
commit 1c2911efde
2 changed files with 17 additions and 2 deletions

View File

@ -27,10 +27,19 @@ class cloud::telemetry::server(
include 'cloud::telemetry'
# Install MongoDB database
$db_conn = regsubst($ceilometer_database_connection, 'mongodb:\/\/(\.*)', '\2')
exec {'check_mongodb' :
command => "/usr/bin/mongo ${db_conn}",
logoutput => false,
tries => 60,
try_sleep => 5,
require => Service['mongodb'],
}
# Install MongoDB database
class { 'ceilometer::db':
database_connection => $ceilometer_database_connection,
require => Class['mongodb']
require => Exec['check_mongodb'],
}
# Install Ceilometer-collector

View File

@ -61,6 +61,12 @@ describe 'cloud::telemetry::server' do
should contain_ceilometer_config('DEFAULT/use_syslog').with('value' => 'yes')
end
it 'check mongodb is started' do
should contain_exec('check_mongodb').with({
:command => '/usr/bin/mongo 10.0.0.2/ceilometer',
})
end
it 'configure ceilometer db' do
should contain_class('ceilometer::db').with(
:database_connection => 'mongodb://10.0.0.2/ceilometer'