Creation of ceilometer::db::sync

In order to standardize the way dbsync are run across our modules,
we create a new class ceilometer::db::sync.
This class will be included if sync_db is enabled.

By making this transition the ceilometer::db::sync can be returned
by the ENC.

A use case would be in an highly available environment, with 3 galera
nodes, include ceilometer::db on every node with sync_db set to false
and have the ENC return ceilometer::db::sync just for one node.

Change-Id: I410f41fb4e61be848372820cdeb2110efc327161
changes/07/196607/8
Yanis Guenane 7 years ago
parent fe4eb1f5ef
commit 7b920066e1
  1. 1
      manifests/api.pp
  2. 2
      manifests/collector.pp
  3. 17
      manifests/db.pp
  4. 22
      manifests/db/sync.pp
  5. 1
      spec/classes/ceilometer_api_spec.rb
  6. 4
      spec/classes/ceilometer_collector_spec.rb
  7. 50
      spec/classes/ceilometer_db_spec.rb
  8. 44
      spec/classes/ceilometer_db_sync_spec.rb

@ -115,6 +115,7 @@ class ceilometer::api (
$service_ensure = 'stopped'
}
}
Package['ceilometer-common'] -> Service[$service_name]
if $service_name == $::ceilometer::params::api_service_name {

@ -53,8 +53,6 @@ class ceilometer::collector (
if $manage_service {
if $enabled {
$service_ensure = 'running'
Class['ceilometer::db'] -> Service['ceilometer-collector']
Exec['ceilometer-dbsync'] ~> Service['ceilometer-collector']
} else {
$service_ensure = 'stopped'
}

@ -50,12 +50,6 @@ class ceilometer::db (
}
}
if $sync_db {
$command = $::ceilometer::params::dbsync_command
} else {
$command = '/bin/true'
}
if $backend_package and !defined(Package[$backend_package]) {
package {'ceilometer-backend-package':
ensure => present,
@ -68,15 +62,8 @@ class ceilometer::db (
'database/connection': value => $database_connection, secret => true;
}
Ceilometer_config['database/connection'] ~> Exec['ceilometer-dbsync']
exec { 'ceilometer-dbsync':
command => $command,
path => '/usr/bin',
user => $::ceilometer::params::user,
refreshonly => true,
logoutput => on_failure,
subscribe => Ceilometer_config['database/connection']
if $sync_db {
include ::ceilometer::db::sync
}
}

@ -0,0 +1,22 @@
#
# Class to execute ceilometer dbsync
#
class ceilometer::db::sync {
include ::ceilometer::params
Package<| tag == 'ceilometer-package' |> ~> Exec['ceilometer-dbsync']
Exec['ceilometer-dbsync'] ~> Service <| tag == 'ceilometer-service' |>
Ceilometer_config<||> -> Exec['ceilometer-dbsync']
Ceilometer_config<| title == 'database/connection' |> ~> Exec['ceilometer-dbsync']
exec { 'ceilometer-dbsync':
command => $::ceilometer::params::dbsync_command,
path => '/usr/bin',
user => $::ceilometer::params::user,
refreshonly => true,
logoutput => on_failure,
}
}

@ -91,7 +91,6 @@ describe 'ceilometer::api' do
:hasstatus => true,
:hasrestart => true,
:require => 'Class[Ceilometer::Db]',
:subscribe => 'Exec[ceilometer-dbsync]',
:tag => 'ceilometer-service',
)
end

@ -69,10 +69,6 @@ describe 'ceilometer::collector' do
)
end
it 'configures relationships on database' do
is_expected.to contain_class('ceilometer::db').with_before(['Service[ceilometer-collector]'])
is_expected.to contain_exec('ceilometer-dbsync').with_notify(['Service[ceilometer-collector]'])
end
end
context 'when disabled' do

@ -25,14 +25,8 @@ describe 'ceilometer::db' do
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
it 'includes ceilometer::db::sync' do
is_expected.to contain_class('ceilometer::db::sync')
end
end
@ -59,14 +53,8 @@ describe 'ceilometer::db' do
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => '/bin/true',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
it 'does not include ceilometer::db::sync' do
is_expected.not_to contain_class('ceilometer::db::sync')
end
end
@ -92,14 +80,8 @@ describe 'ceilometer::db' do
:name => 'python-pymongo')
end
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
it 'includes ceilometer::db::sync' do
is_expected.to contain_class('ceilometer::db::sync')
end
end
@ -124,14 +106,8 @@ describe 'ceilometer::db' do
is_expected.to contain_ceilometer_config('database/connection').with_value( params[:database_connection] ).with_secret(true)
end
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => '/bin/true',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
it 'does not include ceilomter::db::sync' do
is_expected.not_to contain_class('ceilometer::db::sync')
end
end
@ -154,14 +130,8 @@ describe 'ceilometer::db' do
:name => 'python-pysqlite2')
end
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
it 'includes ceilometer::db::sync' do
is_expected.to contain_class('ceilometer::db::sync')
end
end

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'ceilometer::db::sync' do
shared_examples_for 'ceilometer-dbsync' do
it 'runs ceilometer-dbsync' do
is_expected.to contain_exec('ceilometer-dbsync').with(
:command => 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf',
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
)
end
end
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'ceilometer-dbsync'
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'ceilometer-dbsync'
end
end
Loading…
Cancel
Save