Use oslo::coordination to manage coordination parameters
This change replaces current implementation about coordination parameters by oslo::coordination resource type, so that we can gather all logics related to coordination in a single place. Depends-on: https://review.opendev.org/791628 Change-Id: Id1a8ef196afe05d8e484c2a69ec92d6ebed7fbe2
This commit is contained in:
parent
4d944807f6
commit
16091c8dd6
46
manifests/coordination.pp
Normal file
46
manifests/coordination.pp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# == Class: aodh::coordination
|
||||||
|
#
|
||||||
|
# Setup and configure Aodh coordination settings.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*backend_url*]
|
||||||
|
# (Optional) Coordination backend URL.
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
#
|
||||||
|
# [*heartbeat*]
|
||||||
|
# (Optional) Number of seconds between hearbeats for distributed
|
||||||
|
# coordintation.
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
#
|
||||||
|
# [*retry_backoff*]
|
||||||
|
# (Optional) Retry backoff factor when retrying to connect with coordination
|
||||||
|
# backend.
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
#
|
||||||
|
# [*max_retry_interval*]
|
||||||
|
# (Optional) Maximum number of seconds between retry to join partitioning
|
||||||
|
# group
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
#
|
||||||
|
class aodh::coordination (
|
||||||
|
$backend_url = $::os_service_default,
|
||||||
|
$heartbeat = $::os_service_default,
|
||||||
|
$retry_backoff = $::os_service_default,
|
||||||
|
$max_retry_interval = $::os_service_default,
|
||||||
|
) {
|
||||||
|
|
||||||
|
include aodh::deps
|
||||||
|
|
||||||
|
$backend_url_real = pick($::aodh::evaluator::coordination_url, $backend_url)
|
||||||
|
|
||||||
|
oslo::coordination{ 'aodh_config':
|
||||||
|
backend_url => $backend_url_real
|
||||||
|
}
|
||||||
|
|
||||||
|
aodh_config {
|
||||||
|
'coordination/heartbeat': value => $heartbeat;
|
||||||
|
'coordination/retry_backoff': value => $retry_backoff;
|
||||||
|
'coordination/max_retry_interval': value => $max_retry_interval;
|
||||||
|
}
|
||||||
|
}
|
@ -17,52 +17,37 @@
|
|||||||
# (optional) Number of workers for evaluator service.
|
# (optional) Number of workers for evaluator service.
|
||||||
# Defaults to $::os_workers.
|
# Defaults to $::os_workers.
|
||||||
#
|
#
|
||||||
# [*coordination_url*]
|
|
||||||
# (optional) The url to use for distributed group membership coordination.
|
|
||||||
# Defaults to $::os_service_default.
|
|
||||||
#
|
|
||||||
# [*evaluation_interval*]
|
# [*evaluation_interval*]
|
||||||
# (optional) Period of evaluation cycle
|
# (optional) Period of evaluation cycle
|
||||||
# Defaults to $::os_service_default.
|
# Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
#
|
||||||
|
# [*coordination_url*]
|
||||||
|
# (optional) The url to use for distributed group membership coordination.
|
||||||
|
# Defaults to undef.
|
||||||
|
#
|
||||||
class aodh::evaluator (
|
class aodh::evaluator (
|
||||||
$manage_service = true,
|
$manage_service = true,
|
||||||
$enabled = true,
|
$enabled = true,
|
||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
$workers = $::os_workers,
|
$workers = $::os_workers,
|
||||||
$coordination_url = $::os_service_default,
|
|
||||||
$evaluation_interval = $::os_service_default,
|
$evaluation_interval = $::os_service_default,
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
$coordination_url = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include aodh::deps
|
include aodh::deps
|
||||||
include aodh::params
|
include aodh::params
|
||||||
|
|
||||||
if !$coordination_url {
|
if $coordination_url != undef {
|
||||||
warning('Use $::os_service_default for the coordination_url parameter. \
|
warning('The coordination_url parameter is deprecated. Use the aodh::coordination class instead')
|
||||||
The current behavior will be changed in a future release')
|
include aodh::coordination
|
||||||
$coordination_url_real = $::os_service_default
|
|
||||||
} else {
|
|
||||||
$coordination_url_real = $coordination_url
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_service_default($coordination_url_real) 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;
|
'evaluator/workers' : value => $workers;
|
||||||
'coordination/backend_url' : value => $coordination_url_real;
|
|
||||||
}
|
|
||||||
|
|
||||||
if !is_service_default($coordination_url_real) and ($coordination_url_real =~ /^redis/ ) {
|
|
||||||
ensure_packages('python-redis', {
|
|
||||||
name => $::aodh::params::redis_package_name,
|
|
||||||
tag => 'openstack',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_packages($::aodh::params::evaluator_package_name, {
|
ensure_packages($::aodh::params::evaluator_package_name, {
|
||||||
|
@ -22,7 +22,6 @@ class aodh::params {
|
|||||||
$listener_service_name = 'openstack-aodh-listener'
|
$listener_service_name = 'openstack-aodh-listener'
|
||||||
$aodh_wsgi_script_dir = '/var/www/cgi-bin/aodh'
|
$aodh_wsgi_script_dir = '/var/www/cgi-bin/aodh'
|
||||||
$aodh_wsgi_script_source = '/usr/bin/aodh-api'
|
$aodh_wsgi_script_source = '/usr/bin/aodh-api'
|
||||||
$redis_package_name = 'python3-redis'
|
|
||||||
}
|
}
|
||||||
'Debian': {
|
'Debian': {
|
||||||
$common_package_name = 'aodh-common'
|
$common_package_name = 'aodh-common'
|
||||||
@ -45,7 +44,6 @@ class aodh::params {
|
|||||||
$listener_service_name = 'aodh-listener'
|
$listener_service_name = 'aodh-listener'
|
||||||
$aodh_wsgi_script_dir = '/usr/lib/cgi-bin/aodh'
|
$aodh_wsgi_script_dir = '/usr/lib/cgi-bin/aodh'
|
||||||
$aodh_wsgi_script_source = '/usr/share/aodh/app.wsgi'
|
$aodh_wsgi_script_source = '/usr/share/aodh/app.wsgi'
|
||||||
$redis_package_name = 'python3-redis'
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \
|
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \
|
||||||
|
15
releasenotes/notes/coordination-aee30fff3b537d61.yaml
Normal file
15
releasenotes/notes/coordination-aee30fff3b537d61.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The new ``aodh::coordination`` class has been added.
|
||||||
|
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The ``aodh::evaluator`` class no longer adjust workers based on
|
||||||
|
the ``coordination_url`` parameter. Please set the corrdination backend
|
||||||
|
if multiple workers are used.
|
||||||
|
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
The ``aodh::evaluator::coordination_url`` parameter has been deprecated in
|
||||||
|
favor of the new ``aodh::coordination`` class.
|
48
spec/classes/aodh_coordination_spec.rb
Normal file
48
spec/classes/aodh_coordination_spec.rb
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'aodh::coordination' do
|
||||||
|
shared_examples 'aodh::coordination' do
|
||||||
|
context 'with default parameters' do
|
||||||
|
it {
|
||||||
|
is_expected.to contain_oslo__coordination('aodh_config').with(
|
||||||
|
:backend_url => '<SERVICE DEFAULT>'
|
||||||
|
)
|
||||||
|
is_expected.to contain_aodh_config('coordination/heartbeat').with_value('<SERVICE DEFAULT>')
|
||||||
|
is_expected.to contain_aodh_config('coordination/retry_backoff').with_value('<SERVICE DEFAULT>')
|
||||||
|
is_expected.to contain_aodh_config('coordination/max_retry_interval').with_value('<SERVICE DEFAULT>')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with specified parameters' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:backend_url => 'etcd3+http://127.0.0.1:2379',
|
||||||
|
:heartbeat => 1,
|
||||||
|
:retry_backoff => 1,
|
||||||
|
:max_retry_interval => 30,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
is_expected.to contain_oslo__coordination('aodh_config').with(
|
||||||
|
:backend_url => 'etcd3+http://127.0.0.1:2379'
|
||||||
|
)
|
||||||
|
is_expected.to contain_aodh_config('coordination/heartbeat').with_value(1)
|
||||||
|
is_expected.to contain_aodh_config('coordination/retry_backoff').with_value(1)
|
||||||
|
is_expected.to contain_aodh_config('coordination/max_retry_interval').with_value(30)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
on_supported_os({
|
||||||
|
:supported_os => OSDefaults.get_supported_os
|
||||||
|
}).each do |os,facts|
|
||||||
|
context "on #{os}" do
|
||||||
|
let (:facts) do
|
||||||
|
facts.merge(OSDefaults.get_facts())
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'aodh::coordination'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -2,47 +2,22 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'aodh::evaluator' do
|
describe 'aodh::evaluator' do
|
||||||
|
|
||||||
let :pre_condition do
|
|
||||||
"class { '::aodh': }"
|
|
||||||
end
|
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{ :enabled => true }
|
{ :enabled => true }
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'aodh-evaluator' do
|
shared_examples_for 'aodh-evaluator' do
|
||||||
|
|
||||||
context 'with coordination' do
|
context 'with defaults' do
|
||||||
before do
|
it 'configures defaults' do
|
||||||
params.merge!({ :coordination_url => 'redis://localhost:6379' })
|
|
||||||
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(4)
|
is_expected.to contain_aodh_config('evaluator/workers').with_value(4)
|
||||||
end
|
is_expected.to contain_aodh_config('DEFAULT/evaluation_interval').with_value('<SERVICE DEFAULT>')
|
||||||
|
|
||||||
it 'installs python-redis package' do
|
|
||||||
is_expected.to contain_package('python-redis').with(
|
|
||||||
:name => platform_params[:redis_package_name],
|
|
||||||
:tag => 'openstack'
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with coordination and workers' do
|
context 'with workers' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({ :workers => 8 })
|
||||||
: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
|
end
|
||||||
|
|
||||||
it 'configures workers' do
|
it 'configures workers' do
|
||||||
@ -59,12 +34,13 @@ describe 'aodh::evaluator' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with workers' do
|
context 'with deprecated coordination_url' do
|
||||||
before do
|
before do
|
||||||
params.merge!({ :workers => 8 })
|
params.merge!({ :coordination_url => 'redis://localhost:6379' })
|
||||||
end
|
end
|
||||||
it 'does not configure workers' do
|
it 'configures coordination and workers' do
|
||||||
is_expected.to contain_aodh_config('evaluator/workers').with_value('<SERVICE DEFAULT>')
|
is_expected.to contain_aodh_config('coordination/backend_url').with_value('redis://localhost:6379')
|
||||||
|
is_expected.to contain_aodh_config('evaluator/workers').with_value(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -91,8 +67,7 @@ describe 'aodh::evaluator' do
|
|||||||
|
|
||||||
it 'sets default values' do
|
it 'sets default values' do
|
||||||
is_expected.to contain_aodh_config('DEFAULT/evaluation_interval').with_value('<SERVICE DEFAULT>')
|
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>')
|
is_expected.to contain_aodh_config('evaluator/workers').with_value(4)
|
||||||
is_expected.to contain_aodh_config('coordination/backend_url').with_value('<SERVICE DEFAULT>')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -139,12 +114,10 @@ describe 'aodh::evaluator' do
|
|||||||
case facts[:osfamily]
|
case facts[:osfamily]
|
||||||
when 'Debian'
|
when 'Debian'
|
||||||
{ :evaluator_package_name => 'aodh-evaluator',
|
{ :evaluator_package_name => 'aodh-evaluator',
|
||||||
:evaluator_service_name => 'aodh-evaluator',
|
:evaluator_service_name => 'aodh-evaluator' }
|
||||||
:redis_package_name => 'python3-redis' }
|
|
||||||
when 'RedHat'
|
when 'RedHat'
|
||||||
{ :evaluator_package_name => 'openstack-aodh-evaluator',
|
{ :evaluator_package_name => 'openstack-aodh-evaluator',
|
||||||
:evaluator_service_name => 'openstack-aodh-evaluator',
|
:evaluator_service_name => 'openstack-aodh-evaluator' }
|
||||||
:redis_package_name => 'python3-redis' }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
it_configures 'aodh-evaluator'
|
it_configures 'aodh-evaluator'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user