Support dedicated mistral-notifier

mistral by default requires a dedicated notifier service.

Change-Id: I546e0b38c69c8e5514e2bfe22396cc78ecbcf18e
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-08-01 17:58:54 +09:00
parent 6ef3fe37ee
commit 2beb127791
4 changed files with 153 additions and 15 deletions

View File

@@ -4,12 +4,24 @@
#
# === Parameters
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to present
#
# [*enabled*]
# (optional) Should the service be enabled.
# Defaults to true.
#
# [*manage_service*]
# (optional) Whether the service should be managed by Puppet.
# Defaults to true.
#
# [*type*]
# (Optional) Type of notifier. Use local to run the notifier within
# the engine server. Use remote if the notifier is launched as a separate
# server to process events.
# (string value)
# Defaults to $facts['os_service_default'].
# Defaults to 'remote'.
#
# [*host*]
# (Optional) Name of the notifier node. This can be an opaque identifier.
@@ -30,15 +42,53 @@
# Defaults to $facts['os_service_default'].
#
class mistral::notifier(
$type = $facts['os_service_default'],
$host = $facts['os_service_default'],
$topic = $facts['os_service_default'],
$notify_publishers = $facts['os_service_default'],
$package_ensure = present,
Boolean $manage_service = true,
Boolean $enabled = true,
Enum['local', 'remote'] $type = 'remote',
$host = $facts['os_service_default'],
$topic = $facts['os_service_default'],
$notify_publishers = $facts['os_service_default'],
) {
include mistral::deps
include mistral::params
if $::mistral::params::notifier_package_name {
package { 'mistral-notifier':
ensure => $package_ensure,
name => $::mistral::params::notifier_package_name,
tag => ['openstack', 'mistral-package'],
}
}
if $manage_service {
$enabled_real = $type ? {
'remote' => $enabled,
default => false,
}
if $enabled_real {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
if $::mistral::params::notifier_service_name {
service { 'mistral-notifier':
ensure => $service_ensure,
name => $::mistral::params::notifier_service_name,
enable => $enabled_real,
hasstatus => true,
hasrestart => true,
tag => 'mistral-service',
}
Service['mistral-notifier'] -> Service<| title == 'mistral-engine' |>
} else {
warning('mistral-notifier service is not available')
}
}
mistral_config {
'notifier/type': value => $type;
'notifier/host': value => $host;

View File

@@ -22,6 +22,8 @@ class mistral::params {
$executor_service_name = 'openstack-mistral-executor'
$event_engine_package_name = 'openstack-mistral-event-engine'
$event_engine_service_name = 'openstack-mistral-event-engine'
$notifier_package_name = 'openstack-mistral-notifier'
$notifier_service_name = 'openstack-mistral-notifier'
$mistral_wsgi_script_path = '/var/www/cgi-bin/mistral'
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
}
@@ -35,6 +37,8 @@ class mistral::params {
$executor_service_name = 'mistral-executor'
$event_engine_package_name = 'mistral-event-engine'
$event_engine_service_name = 'mistral-event-engine'
$notifier_package_name = undef
$notifier_service_name = undef
$mistral_wsgi_script_path = '/usr/lib/cgi-bin/mistral'
$mistral_wsgi_script_source = '/usr/bin/mistral-wsgi-api'
}

View File

@@ -0,0 +1,5 @@
---
features:
- |
The ``mistral::notifier`` class now installs and configures
the dedicated ``mistral-notifier`` service.

View File

@@ -3,28 +3,95 @@ require 'spec_helper'
describe 'mistral::notifier' do
shared_examples_for 'mistral::notifier' do
it 'configure notifier default params' do
is_expected.to contain_mistral_config('notifier/type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
context 'with defaults' do
it 'configure notifier default params' do
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
end
it 'installs mistral-notifier package' do
if platform_params.has_key?(:notifier_package_name)
is_expected.to contain_package('mistral-notifier').with(
:ensure => 'present',
:name => platform_params[:notifier_package_name],
:tag => ['openstack', 'mistral-package']
)
end
end
it 'configures mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'running',
:name => platform_params[:notifier_service_name],
:enable => true,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with specific parameters' do
let :params do
{ :type => "remote",
:host => "localhost",
:topic => "mistral-event-stream",
:notify_publishers => "[{'type': 'noop'}]",
{ :type => 'local',
:host => 'localhost',
:topic => 'mistral-event-stream',
:notify_publishers => '[{\'type\': \'noop\'}]',
}
end
it 'configure notifier params' do
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
is_expected.to contain_mistral_config('notifier/type').with_value('local')
is_expected.to contain_mistral_config('notifier/host').with_value('localhost')
is_expected.to contain_mistral_config('notifier/topic').with_value('mistral-event-stream')
is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]")
end
it 'disables mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'stopped',
:name => platform_params[:notifier_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with service disabled' do
let :params do
{ :enabled => false }
end
it 'configures mistral-notifier service' do
if platform_params.has_key?(:notifier_service_name)
is_expected.to contain_service('mistral-notifier').with(
:ensure => 'stopped',
:name => platform_params[:notifier_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => 'mistral-service',
)
end
end
end
context 'with service unmanaged' do
let :params do
{ :manage_service => false }
end
it 'does not configure mistral-notifier service' do
is_expected.to_not contain_service('mistral-notifier')
end
end
end
@@ -36,6 +103,18 @@ describe 'mistral::notifier' do
facts.merge!(OSDefaults.get_facts())
end
let (:platform_params) do
case facts[:os]['family']
when 'Debian'
{}
when 'RedHat'
{
:notifier_package_name => 'openstack-mistral-notifier',
:notifier_service_name => 'openstack-mistral-notifier'
}
end
end
it_configures 'mistral::notifier'
end
end