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: I5e0af169ccdb2f4c56318dbc0198f480ab4b15fa
This commit is contained in:
Takashi Kajinami 2021-05-21 16:02:00 +09:00
parent 32cbb8a241
commit 1155b41db0
5 changed files with 83 additions and 17 deletions

View File

@ -28,10 +28,6 @@
# (Optional) Use ipmi namespace for polling agent.
# Defaults to true.
#
# [*coordination_url*]
# (Optional) The url to use for distributed group membership coordination.
# Defaults to $::os_service_default.
#
# [*instance_discovery_method*]
# (Optional) method to discovery instances running on compute node
# Defaults to $::os_service_default
@ -58,6 +54,12 @@
# This is used only if manage_polling is true.
# Defaults to undef
#
# DEPRECATED PARAMETERS
#
# [*coordination_url*]
# (Optional) The url to use for distributed group membership coordination.
# Defaults to undef.
#
class ceilometer::agent::polling (
$manage_service = true,
$enabled = true,
@ -65,17 +67,23 @@ class ceilometer::agent::polling (
$central_namespace = true,
$compute_namespace = true,
$ipmi_namespace = true,
$coordination_url = $::os_service_default,
$instance_discovery_method = $::os_service_default,
$manage_polling = false,
$polling_interval = 600,
$polling_meters = $::ceilometer::params::polling_meters,
$polling_config = undef,
# DEPRECATED PARAMETERS
$coordination_url = undef,
) inherits ceilometer {
include ceilometer::deps
include ceilometer::params
if $coordination_url != undef {
warning('The coordination_url parameter has been deprecated. Use ceilometer::coordination instead')
include ceilometer::coordination
}
if $central_namespace {
$central_namespace_name = 'central'
} else {
@ -144,17 +152,6 @@ class ceilometer::agent::polling (
tag => 'ceilometer-service',
}
if $coordination_url == undef {
warning('Usage of undef for the coordination_url parameter has been deprecated. \
Use $::os_service_default instead')
$coordination_url_real = $::os_service_default
} else {
$coordination_url_real = $coordination_url
}
ceilometer_config {
'coordination/backend_url': value => $coordination_url_real
}
if $manage_polling {
if $polling_config {
validate_legacy(Hash, 'validate_hash', $polling_config)

22
manifests/coordination.pp Normal file
View File

@ -0,0 +1,22 @@
# == Class: ceilometer::coordination
#
# Setup and configure Ceilometer coordination settings.
#
# === Parameters
#
# [*backend_url*]
# (Optional) Coordination backend URL.
# Defaults to $::os_service_default
#
class ceilometer::coordination (
$backend_url = $::os_service_default,
) {
include ceilometer::deps
$backend_url_real = pick($::ceilometer::agent::polling::coordination_url, $backend_url)
oslo::coordination{ 'ceilometer_config':
backend_url => $backend_url_real
}
}

View File

@ -0,0 +1,9 @@
---
features:
- |
The new ``ceilometer::coordination`` class has been added.
deprecations:
- |
The ``ceilometer::agent::polling::coordination_url`` parameter has been
deprecated in favor of the new ``ceilometer::coordination`` class.

View File

@ -48,7 +48,6 @@ describe 'ceilometer::agent::polling' do
:tag => 'ceilometer-service',
)}
it { should contain_ceilometer_config('coordination/backend_url').with_value('<SERVICE DEFAULT>') }
it { should_not contain_file('polling') }
end

View File

@ -0,0 +1,39 @@
require 'spec_helper'
describe 'ceilometer::coordination' do
shared_examples 'ceilometer::coordination' do
context 'with default parameters' do
it {
is_expected.to contain_oslo__coordination('ceilometer_config').with(
:backend_url => '<SERVICE DEFAULT>'
)
}
end
context 'with specified parameters' do
let :params do
{
:backend_url => 'etcd3+http://127.0.0.1:2379',
}
end
it {
is_expected.to contain_oslo__coordination('ceilometer_config').with(
:backend_url => 'etcd3+http://127.0.0.1:2379'
)
}
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 'ceilometer::coordination'
end
end
end