task_flow: Ensure backend package is installed

The octavia pcakge in Ubuntu/Debian does not install python3-redis
automatically and it should be additionally installed.

Also the octavia package in RDO is removing explicit dependency to
python3-redis[1].

[1] https://review.rdoproject.org/r/c/openstack/octavia-distgit/+/53067

Change-Id: Ie7ffa7e22848a3f888a1a553aa26f2e4171a191b
This commit is contained in:
Takashi Kajinami 2024-05-01 00:21:51 +09:00
parent b04df6b873
commit b1f605a342
4 changed files with 111 additions and 4 deletions

View File

@ -23,6 +23,8 @@ class octavia::params {
$driver_agent_package_name = 'openstack-octavia-driver-agent'
$octavia_wsgi_script_path = '/var/www/cgi-bin/octavia'
$octavia_wsgi_script_source = '/usr/bin/octavia-wsgi'
$python_redis_package_name = 'python3-redis'
$python_kazoo_package_name = 'python3-kazoo'
}
'Debian': {
$common_package_name = 'octavia-common'
@ -33,6 +35,8 @@ class octavia::params {
$driver_agent_package_name = 'octavia-driver-agent'
$octavia_wsgi_script_path = '/usr/lib/cgi-bin/octavia'
$octavia_wsgi_script_source = '/usr/bin/octavia-wsgi'
$python_redis_package_name = 'python3-redis'
$python_kazoo_package_name = 'python3-kazoo'
}
default: {
fail("Unsupported osfamily: ${facts['os']['family']}")

View File

@ -69,6 +69,14 @@
# (optional) Url used to connect to the persistence database.
# Defaults to $facts['os_service_default']
#
# [*manage_backend_package*]
# (Optional) Whether to install the backend package.
# Defaults to true.
#
# [*package_ensure*]
# (Optional) ensure state for package.
# Defaults to 'present'
#
class octavia::task_flow (
$engine = $facts['os_service_default'],
$max_workers = $facts['os_service_default'],
@ -86,9 +94,12 @@ class octavia::task_flow (
$jobboard_expiration_time = $facts['os_service_default'],
$jobboard_save_logbook = $facts['os_service_default'],
$persistence_connection = $facts['os_service_default'],
Boolean $manage_backend_package = true,
$package_ensure = 'present',
) {
include octavia::deps
include octavia::params
$jobboard_redis_backend_ssl_options_real = $jobboard_redis_backend_ssl_options ? {
Hash => join(join_keys_to_values($jobboard_redis_backend_ssl_options, ':'), ','),
@ -99,6 +110,39 @@ class octavia::task_flow (
default => join(any2array($jobboard_zookeeper_ssl_options), ','),
}
if $manage_backend_package {
$jobboard_backend_driver_real = is_service_default($jobboard_backend_driver) ? {
true => 'redis_taskflow_driver',
default => $jobboard_backend_driver,
}
case $jobboard_backend_driver_real {
'zookeeper_taskflow_driver': {
ensure_packages('python-kazoo', {
name => $::oslo::params::python_kazoo_package_name,
ensure => $package_ensure,
tag => ['openstack'],
})
Anchor['octavia::install::begin']
-> Package['python-kazoo']
-> Anchor['octavia::install::end']
}
'redis_taskflow_driver': {
ensure_packages('python-redis', {
name => $::oslo::params::python_redis_package_name,
ensure => $package_ensure,
tag => ['openstack'],
})
Anchor['octavia::install::begin']
-> Package['python-redis']
-> Anchor['octavia::install::end']
}
default: {
fail('unsupported taskflow backend')
}
}
}
octavia_config {
'task_flow/engine' : value => $engine;
'task_flow/max_workers' : value => $max_workers;

View File

@ -0,0 +1,7 @@
---
features:
- |
The ``octavia::task_flow`` class now ensures the backend package is
installed. Package management can be disabled by setting the new
``manage_backend_package`` parameter to ``false``. The package status
can be customized by the new ``package_ensure`` parameter.

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'octavia::task_flow' do
shared_examples 'octavia::task_flow' do
context 'with default parameters' do
it {
it 'configures the default values' do
should contain_octavia_config('task_flow/engine').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/max_workers').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/disable_revert').with_value('<SERVICE DEFAULT>')
@ -20,7 +20,12 @@ describe 'octavia::task_flow' do
should contain_octavia_config('task_flow/jobboard_expiration_time').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_save_logbook').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/persistence_connection').with_value('<SERVICE DEFAULT>')
}
end
it 'should not install backend packages' do
should_not contain_package('python-redis')
should_not contain_package('python-kazoo')
end
end
context 'with specified parameters' do
@ -45,7 +50,7 @@ describe 'octavia::task_flow' do
}
end
it {
it 'configures the given values' do
should contain_octavia_config('task_flow/engine').with_value('parallel')
should contain_octavia_config('task_flow/max_workers').with_value(5)
should contain_octavia_config('task_flow/disable_revert').with_value(false)
@ -62,7 +67,39 @@ describe 'octavia::task_flow' do
should contain_octavia_config('task_flow/jobboard_expiration_time').with_value(30)
should contain_octavia_config('task_flow/jobboard_save_logbook').with_value(false)
should contain_octavia_config('task_flow/persistence_connection').with_value('sqlite://')
}
end
it 'should install python-redis' do
should contain_package('python-redis').with(
:ensure => 'installed',
:name => platform_params[:python_redis_package_name],
:tag => ['openstack'],
)
end
it 'should not install python-kazoo' do
should_not contain_package('python-kazoo')
end
end
context 'with zookeeper driver' do
let :params do
{
:jobboard_backend_driver => 'zookeeper_taskflow_driver',
}
end
it 'should not install python-redis' do
should_not contain_package('python-redis')
end
it 'should install python-kazoo' do
should_not contain_package('python-kazoo').with(
:ensure => 'installed',
:name => platform_params[:python_kazoo_package_name],
:tag => ['openstack'],
)
end
end
context 'with ssl options set to dict' do
@ -94,6 +131,21 @@ describe 'octavia::task_flow' do
facts.merge(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:os]['family']
when 'Debian'
{
:python_redis_package_name => 'python3-redis',
:python_kazoo_package_name => 'python3-kazoo'
}
when 'RedHat'
{
:python_redis_package_name => 'python3-redis',
:python_kazoo_package_name => 'python3-kazoo'
}
end
end
it_behaves_like 'octavia::task_flow'
end
end