Use oslo::coordination to manage coordination parameters

This change replaces current implementation to manage coordination
parameters by the base class in puppet-oslo. With this change
the required backend package is installed according to the backend
driver used.

Depends-on: https://review.opendev.org/791628
Change-Id: I7e3a98a8b477df0580159ccc0e615cf63bae0e47
This commit is contained in:
Takashi Kajinami 2021-07-06 13:25:29 +09:00
parent 66f45e38d2
commit 823d409fe8
5 changed files with 103 additions and 4 deletions

39
manifests/coordination.pp Normal file
View File

@ -0,0 +1,39 @@
# == Class: designate::coordination
#
# Setup and configure Designate coordination settings.
#
# === Parameters
#
# [*backend_url*]
# (Optional) Coordination backend URL.
# Defaults to $::os_service_default
#
# [*heartbeat_interval*]
# (Optional) Number of seconds between hearbeats for distributed
# coordintation.
# Defaults to $::os_service_default
#
# [*run_watchers_interval*]
# (Optional) Numeber of seconds between checks to see if group membership
# has changed.
# Defaults to $::os_service_default
#
class designate::coordination (
$backend_url = $::os_service_default,
$heartbeat_interval = $::os_service_default,
$run_watchers_interval = $::os_service_default,
) {
include designate::deps
$backend_url_real = pick($::designate::producer::backend_url, $backend_url)
oslo::coordination{ 'designate_config':
backend_url => $backend_url_real
}
designate_config {
'coordination/heartbeat_interval': value => $heartbeat_interval;
'coordination/run_watchers_interval': value => $run_watchers_interval;
}
}

View File

@ -32,9 +32,11 @@
# (optional) List of tasks to enable, the default enables all tasks.
# Defaults to $::os_service_default.
#
# DEPRECATED PARAMETERS
#
# [*backend_url*]
# (optional) URL to use for coordination, should be a tooz URL.
# Defaults to $::os_service_default.
# Defaults to undef
#
class designate::producer (
$package_ensure = 'present',
@ -44,14 +46,19 @@ class designate::producer (
$workers = $::os_workers,
$threads = $::os_service_default,
$enabled_tasks = $::os_service_default,
$backend_url = $::os_service_default,
# DEPRECATED PARAMETERS
$backend_url = undef
) inherits designate {
designate_config {
'service:producer/workers' : value => $workers;
'service:producer/threads' : value => $threads;
'service:producer/enabled_tasks' : value => $enabled_tasks;
'coordination/backend_url' : value => $backend_url;
}
if $backend_url != undef {
warning('designate::producer::backend_url is deprecated. Use designate::coordination instead')
include designate::coordination
}
designate::generic_service { 'producer':

View File

@ -0,0 +1,9 @@
---
features:
- |
The new ``designate::coordination`` class has been added.
deprecations:
- |
The ``designate::producer::backend_url`` parameter has been deprecated in
favor of the new ``designate::coordination`` class.

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'designate::coordination' do
shared_examples 'designate::coordination' do
context 'with default parameters' do
it {
is_expected.to contain_oslo__coordination('designate_config').with(
:backend_url => '<SERVICE DEFAULT>'
)
is_expected.to contain_designate_config('coordination/heartbeat_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('coordination/run_watchers_interval').with_value('<SERVICE DEFAULT>')
}
end
context 'with specified parameters' do
let :params do
{
:backend_url => 'etcd3+http://127.0.0.1:2379',
:heartbeat_interval => 5.0,
:run_watchers_interval => 10.0,
}
end
it {
is_expected.to contain_oslo__coordination('designate_config').with(
:backend_url => 'etcd3+http://127.0.0.1:2379'
)
is_expected.to contain_designate_config('coordination/heartbeat_interval').with_value(5.0)
is_expected.to contain_designate_config('coordination/run_watchers_interval').with_value(10.0)
}
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 'designate::coordination'
end
end
end

View File

@ -38,7 +38,6 @@ describe 'designate::producer' do
is_expected.to contain_designate_config("service:producer/workers").with(:value => 8)
is_expected.to contain_designate_config("service:producer/threads").with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_designate_config("service:producer/enabled_tasks").with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_designate_config("coordination/backend_url").with(:value => '<SERVICE DEFAULT>')
end
end