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:
@@ -27,10 +27,19 @@ class cloud::telemetry::server(
|
|||||||
|
|
||||||
include 'cloud::telemetry'
|
include 'cloud::telemetry'
|
||||||
|
|
||||||
|
$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
|
# Install MongoDB database
|
||||||
class { 'ceilometer::db':
|
class { 'ceilometer::db':
|
||||||
database_connection => $ceilometer_database_connection,
|
database_connection => $ceilometer_database_connection,
|
||||||
require => Class['mongodb']
|
require => Exec['check_mongodb'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install Ceilometer-collector
|
# Install Ceilometer-collector
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ describe 'cloud::telemetry::server' do
|
|||||||
should contain_ceilometer_config('DEFAULT/use_syslog').with('value' => 'yes')
|
should contain_ceilometer_config('DEFAULT/use_syslog').with('value' => 'yes')
|
||||||
end
|
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
|
it 'configure ceilometer db' do
|
||||||
should contain_class('ceilometer::db').with(
|
should contain_class('ceilometer::db').with(
|
||||||
:database_connection => 'mongodb://10.0.0.2/ceilometer'
|
:database_connection => 'mongodb://10.0.0.2/ceilometer'
|
||||||
|
|||||||
Reference in New Issue
Block a user