Add support for workers option

This change introduces support for workers option of aodh services
(evaluator, listener, notifier) so that operators can define number
of processes used in each service.

Change-Id: Id64fc407d19aa546512078f67df3a727fd9f5525
This commit is contained in:
Takashi Kajinami
2020-12-30 20:48:46 +09:00
parent 99eb188512
commit ae9b91107d
7 changed files with 104 additions and 7 deletions

View File

@@ -13,6 +13,10 @@
# (optional) ensure state for package. # (optional) ensure state for package.
# Defaults to 'present' # Defaults to 'present'
# #
# [*workers*]
# (optional) Number of workers for evaluator service.
# Defaults to $::os_workers.
#
# [*coordination_url*] # [*coordination_url*]
# (optional) The url to use for distributed group membership coordination. # (optional) The url to use for distributed group membership coordination.
# Defaults to undef. # Defaults to undef.
@@ -25,6 +29,7 @@ class aodh::evaluator (
$manage_service = true, $manage_service = true,
$enabled = true, $enabled = true,
$package_ensure = 'present', $package_ensure = 'present',
$workers = $::os_workers,
$coordination_url = undef, $coordination_url = undef,
$evaluation_interval = $::os_service_default, $evaluation_interval = $::os_service_default,
) { ) {
@@ -32,9 +37,18 @@ class aodh::evaluator (
include aodh::deps include aodh::deps
include aodh::params include aodh::params
if $coordination_url == undef and !is_service_default($workers) and $workers > 1 {
warning('coordination_url should be set to use multiple workers')
$workers_real = $::os_service_default
} else {
$workers_real = $workers
}
aodh_config { aodh_config {
'DEFAULT/evaluation_interval' : value => $evaluation_interval; 'DEFAULT/evaluation_interval' : value => $evaluation_interval;
'evaluator/workers' : value => $workers_real;
} }
if $coordination_url { if $coordination_url {
aodh_config { aodh_config {
'coordination/backend_url' : value => $coordination_url; 'coordination/backend_url' : value => $coordination_url;

View File

@@ -13,15 +13,24 @@
# (optional) ensure state for package. # (optional) ensure state for package.
# Defaults to 'present' # Defaults to 'present'
# #
# [*workers*]
# (optional) Number of workers for evaluator service.
# Defaults to $::os_workers.
#
class aodh::listener ( class aodh::listener (
$manage_service = true, $manage_service = true,
$enabled = true, $enabled = true,
$package_ensure = 'present', $package_ensure = 'present',
$workers = $::os_workers,
) { ) {
include aodh::deps include aodh::deps
include aodh::params include aodh::params
aodh_config {
'listener/workers': value => $workers
}
ensure_resource( 'package', [$::aodh::params::listener_package_name], ensure_resource( 'package', [$::aodh::params::listener_package_name],
{ ensure => $package_ensure, { ensure => $package_ensure,
tag => ['openstack', 'aodh-package'] } tag => ['openstack', 'aodh-package'] }

View File

@@ -13,15 +13,24 @@
# (optional) ensure state for package. # (optional) ensure state for package.
# Defaults to 'present' # Defaults to 'present'
# #
# [*workers*]
# (optional) Number of workers for notifier service.
# Defaults to $::os_workers.
#
class aodh::notifier ( class aodh::notifier (
$manage_service = true, $manage_service = true,
$enabled = true, $enabled = true,
$package_ensure = 'present', $package_ensure = 'present',
$workers = $::os_workers,
) { ) {
include aodh::deps include aodh::deps
include aodh::params include aodh::params
aodh_config {
'notifier/workers': value => $workers;
}
ensure_resource( 'package', [$::aodh::params::notifier_package_name], ensure_resource( 'package', [$::aodh::params::notifier_package_name],
{ ensure => $package_ensure, { ensure => $package_ensure,
tag => ['openstack', 'aodh-package'] } tag => ['openstack', 'aodh-package'] }

View File

@@ -0,0 +1,9 @@
---
features:
- |
The new parameters have been added to support workers option in each aodh
services.
- ``aodh::evaluator::workers``
- ``aodh::listener::workers``
- ``aodh::notifier::workers``

View File

@@ -21,14 +21,35 @@ describe 'aodh::evaluator' do
is_expected.to contain_aodh_config('coordination/backend_url').with_value('redis://localhost:6379') is_expected.to contain_aodh_config('coordination/backend_url').with_value('redis://localhost:6379')
end end
it 'configures workers' do
is_expected.to contain_aodh_config('evaluator/workers').with_value(4)
end
it 'installs python-redis package' do it 'installs python-redis package' do
is_expected.to contain_package('python-redis').with( is_expected.to contain_package('python-redis').with(
:name => platform_params[:redis_package_name], :name => platform_params[:redis_package_name],
:tag => 'openstack' :tag => 'openstack'
) )
end end
end end
context 'with coordination and workers' do
before do
params.merge!({
:coordination_url => 'redis://localhost:6379',
:workers => 8,
})
end
it 'configures backend_url' do
is_expected.to contain_aodh_config('coordination/backend_url').with_value('redis://localhost:6379')
end
it 'configures workers' do
is_expected.to contain_aodh_config('evaluator/workers').with_value(8)
end
end
context 'with evaluation interval' do context 'with evaluation interval' do
before do before do
params.merge!({ :evaluation_interval => '10' }) params.merge!({ :evaluation_interval => '10' })
@@ -38,6 +59,14 @@ describe 'aodh::evaluator' do
end end
end end
context 'with workers' do
before do
params.merge!({ :workers => 8 })
end
it 'does not configure workers' do
is_expected.to contain_aodh_config('evaluator/workers').with_value('<SERVICE DEFAULT>')
end
end
context 'when enabled' do context 'when enabled' do
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
@@ -60,6 +89,10 @@ describe 'aodh::evaluator' do
) )
end end
it 'sets default values' do
is_expected.to contain_aodh_config('DEFAULT/evaluation_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('evaluator/workers').with_value('<SERVICE DEFAULT>')
end
end end
context 'when disabled' do context 'when disabled' do
@@ -98,10 +131,7 @@ describe 'aodh::evaluator' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts({ facts.merge!(OSDefaults.get_facts({ :os_workers => 4 }))
:fqdn => 'some.host.tld',
:concat_basedir => '/var/lib/puppet/concat'
}))
end end
let(:platform_params) do let(:platform_params) do

View File

@@ -8,6 +8,16 @@ describe 'aodh::listener' do
shared_examples_for 'aodh-listener' do shared_examples_for 'aodh-listener' do
context 'with workers' do
let :params do
{ :workers => 8 }
end
it 'configures workers' do
is_expected.to contain_aodh_config('listener/workers').with_value(8)
end
end
context 'when enabled' do context 'when enabled' do
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
@@ -29,6 +39,9 @@ describe 'aodh::listener' do
) )
end end
it 'sets default values' do
is_expected.to contain_aodh_config('listener/workers').with_value(4)
end
end end
context 'when disabled' do context 'when disabled' do
@@ -67,7 +80,7 @@ describe 'aodh::listener' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts({ :os_workers => 4 }))
end end
let(:platform_params) do let(:platform_params) do

View File

@@ -8,6 +8,16 @@ describe 'aodh::notifier' do
shared_examples_for 'aodh-notifier' do shared_examples_for 'aodh-notifier' do
context 'with workers' do
let :params do
{ :workers => 8 }
end
it 'configures workers' do
is_expected.to contain_aodh_config('notifier/workers').with_value(8)
end
end
context 'when enabled' do context 'when enabled' do
it { is_expected.to contain_class('aodh::params') } it { is_expected.to contain_class('aodh::params') }
@@ -29,6 +39,9 @@ describe 'aodh::notifier' do
) )
end end
it 'sets default values' do
is_expected.to contain_aodh_config('notifier/workers').with_value(4)
end
end end
context 'when disabled' do context 'when disabled' do
@@ -67,7 +80,7 @@ describe 'aodh::notifier' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts({ :os_workers => 4 }))
end end
let(:platform_params) do let(:platform_params) do