Add parameters to configure amphorav2 driver

amphorav2 driver was introduced in stable/ussuri in Octavia, but some
parameters to configure the backend server to enable persistence were
still missing in puppet-octavia.

Change-Id: I8a9bf0b2c17cd35bc09fbb0270c4ef4ed4e491bd
This commit is contained in:
Gregory Thiemonge 2021-11-03 07:17:08 +01:00 committed by Takashi Kajinami
parent 3513ff3dab
commit 2b9f2a0813
11 changed files with 402 additions and 19 deletions

View File

@ -12,6 +12,10 @@
# (Optional) Name of the database. # (Optional) Name of the database.
# Defaults to 'octavia'. # Defaults to 'octavia'.
# #
# [*persistence_dbname*]
# (Optional) Name of the database dedicated to task_flow persistence.
# Defaults to 'undef'.
#
# [*user*] # [*user*]
# (Optional) User to connect to the database. # (Optional) User to connect to the database.
# Defaults to 'octavia'. # Defaults to 'octavia'.
@ -36,6 +40,7 @@
class octavia::db::mysql( class octavia::db::mysql(
$password, $password,
$dbname = 'octavia', $dbname = 'octavia',
$persistence_dbname = undef,
$user = 'octavia', $user = 'octavia',
$host = '127.0.0.1', $host = '127.0.0.1',
$charset = 'utf8', $charset = 'utf8',
@ -57,6 +62,19 @@ class octavia::db::mysql(
allowed_hosts => $allowed_hosts, allowed_hosts => $allowed_hosts,
} }
if $persistence_dbname {
::openstacklib::db::mysql { 'octavia_persistence':
user => $user,
password => $password,
dbname => $persistence_dbname,
host => $host,
charset => $charset,
collate => $collate,
allowed_hosts => $allowed_hosts,
create_user => false,
}
}
Anchor['octavia::db::begin'] Anchor['octavia::db::begin']
~> Class['octavia::db::mysql'] ~> Class['octavia::db::mysql']
~> Anchor['octavia::db::end'] ~> Anchor['octavia::db::end']

View File

@ -12,6 +12,10 @@
# (Optional) Name of the database. # (Optional) Name of the database.
# Defaults to 'octavia'. # Defaults to 'octavia'.
# #
# [*persistence_dbname*]
# (Optional) Name of the database dedicated to task_flow persistence.
# Defaults to 'undef'.
#
# [*user*] # [*user*]
# (Optional) User to connect to the database. # (Optional) User to connect to the database.
# Defaults to 'octavia'. # Defaults to 'octavia'.
@ -27,6 +31,7 @@
class octavia::db::postgresql( class octavia::db::postgresql(
$password, $password,
$dbname = 'octavia', $dbname = 'octavia',
$persistence_dbname = undef,
$user = 'octavia', $user = 'octavia',
$encoding = undef, $encoding = undef,
$privileges = 'ALL', $privileges = 'ALL',
@ -42,6 +47,16 @@ class octavia::db::postgresql(
privileges => $privileges, privileges => $privileges,
} }
if $persistence_dbname {
::openstacklib::db::postgresql { 'octavia_persistence':
password => $password,
dbname => $persistence_dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
}
Anchor['octavia::db::begin'] Anchor['octavia::db::begin']
~> Class['octavia::db::postgresql'] ~> Class['octavia::db::postgresql']
~> Anchor['octavia::db::end'] ~> Anchor['octavia::db::end']

View File

@ -5,7 +5,7 @@
# #
# [*extra_params*] # [*extra_params*]
# (Optional) String of extra command line parameters to append # (Optional) String of extra command line parameters to append
# to the octavia-dbsync command. # to the octavia-db-manage command.
# Defaults to undef # Defaults to undef
# #
# [*db_sync_timeout*] # [*db_sync_timeout*]

View File

@ -0,0 +1,40 @@
#
# Class to execute octavia-db-manage upgrade_persistence
#
# == Parameters
#
# [*extra_params*]
# (Optional) String of extra command line parameters to append
# to the octavia-db-manage command.
# Defaults to undef
#
# [*db_sync_timeout*]
# (Optional) Timeout for the execution of the db_sync
# Defaults to 300
#
class octavia::db::sync_persistence(
$extra_params = undef,
$db_sync_timeout = 300,
) {
include octavia::deps
exec { 'octavia-db-sync':
command => "octavia-db-manage upgrade_persistence ${extra_params}",
path => '/usr/bin',
user => 'octavia',
refreshonly => true,
try_sleep => 5,
tries => 10,
timeout => $db_sync_timeout,
logoutput => on_failure,
subscribe => [
Anchor['octavia::install::end'],
Anchor['octavia::config::end'],
Anchor['octavia::dbsync::begin']
],
notify => Anchor['octavia::dbsync::end'],
tag => 'openstack-db',
}
}

105
manifests/task_flow.pp Normal file
View File

@ -0,0 +1,105 @@
# == Class: octavia::task_flow
#
# Setup and configure octavia.conf task_flow section.
#
# === Parameters
#
# [*engine*]
# (optional) TaskFlow engine to use.
# Defaults to $::os_service_default
#
# [*max_workers*]
# (optional) The maximum number of workers.
# Defaults to $::os_service_default
#
# [*disable_revert*]
# (optional) If True, disable the controller worker taskflow flows from
# reverting.
# Defaults to $::os_service_default
#
# [*jobboard_enabled*]
# (optional) Enable the jobboard feature in taskflow.
# Defaults to $::os_service_default
#
# [*jobboard_backend_driver*]
# (optional) Jobboard backend driver that will monitor job state.
# Defaults to $::os_service_default
#
# [*jobboard_backend_hosts*]
# (optional) IP addresses of the redis backend for jobboard.
# Defaults to $::os_service_default
#
# [*jobboard_backend_port*]
# (optional) The port of jobboard backend server.
# Defaults to $::os_service_default
#
# [*jobboard_backend_password*]
# (optional) Password for the jobboard backend server.
# Defaults to $::os_service_default
#
# [*jobboard_backend_namespace*]
# (optional) The name used for the job id on the backend server.
# Defaults to $::os_service_default
#
# [*jobboard_redis_sentinel*]
# (optional) Sentinel name if it is used for Redis.
# Defaults to $::os_service_default
#
# [*jobboard_redis_backend_ssl_options*]
# (optional) Redis jobboard backend ssl configuration options
# Defaults to $::os_service_default
#
# [*jobboard_zookeeper_ssl_options*]
# (optional) Zookeeper jobboard backend ssl configuration options.
# Defaults to $::os_service_default
#
# [*jobboard_expiration_time*]
# (optional) Expiration time in seconds for jobboard tasks.
# Defaults to $::os_service_default
#
# [*jobboard_save_logbook*]
# (optional) Save logbook info.
# Defaults to $::os_service_default
#
# [*persistence_connection*]
# (optional) Url used to connect to the persistence database.
# Defaults to $::os_service_default
#
class octavia::task_flow (
$engine = $::os_service_default,
$max_workers = $::os_service_default,
$disable_revert = $::os_service_default,
$jobboard_enabled = $::os_service_default,
$jobboard_backend_driver = $::os_service_default,
$jobboard_backend_hosts = $::os_service_default,
$jobboard_backend_port = $::os_service_default,
$jobboard_backend_password = $::os_service_default,
$jobboard_backend_namespace = $::os_service_default,
$jobboard_redis_sentinel = $::os_service_default,
$jobboard_redis_backend_ssl_options = $::os_service_default,
$jobboard_zookeeper_ssl_options = $::os_service_default,
$jobboard_expiration_time = $::os_service_default,
$jobboard_save_logbook = $::os_service_default,
$persistence_connection = $::os_service_default,
) {
include octavia::deps
octavia_config {
'task_flow/engine' : value => $engine;
'task_flow/max_workers' : value => $max_workers;
'task_flow/disable_revert' : value => $disable_revert;
'task_flow/jobboard_enabled' : value => $jobboard_enabled;
'task_flow/jobboard_backend_driver' : value => $jobboard_backend_driver;
'task_flow/jobboard_backend_hosts' : value => join(any2array($jobboard_backend_hosts), ',');
'task_flow/jobboard_backend_port' : value => $jobboard_backend_port;
'task_flow/jobboard_backend_password' : value => $jobboard_backend_password, secret => true;
'task_flow/jobboard_backend_namespace' : value => $jobboard_backend_namespace;
'task_flow/jobboard_redis_sentinel' : value => $jobboard_redis_sentinel;
'task_flow/jobboard_redis_backend_ssl_options' : value => join(any2array($jobboard_redis_backend_ssl_options), ',');
'task_flow/jobboard_zookeeper_ssl_options' : value => join(any2array($jobboard_zookeeper_ssl_options), ',');
'task_flow/jobboard_expiration_time' : value => $jobboard_expiration_time;
'task_flow/jobboard_save_logbook' : value => $jobboard_save_logbook;
'task_flow/persistence_connection' : value => $persistence_connection;
}
}

View File

@ -0,0 +1,14 @@
---
features:
- |
The new ``octavia::task_flow`` class has been added. This class manages
parameters in the ``task_flow`` section, which are required to use
the amphora v2 driver.
- |
The ``octavia::db::mysql`` class and the ``octavia::db::postgresql`` class
now support creating a separate database for taskflow persistence.
- |
The ``octavia::db::sync_persistence`` class has been added. This class
invokes the command to initialize the taskflow persistence database.

View File

@ -24,6 +24,7 @@ describe 'octavia::db::mysql' do
:charset => 'utf8', :charset => 'utf8',
:collate => 'utf8_general_ci', :collate => 'utf8_general_ci',
)} )}
it { should_not contain_openstacklib__db__mysql('octavia_persistence') }
end end
context 'overriding allowed_hosts param to array' do context 'overriding allowed_hosts param to array' do
@ -57,6 +58,30 @@ describe 'octavia::db::mysql' do
:allowed_hosts => '192.168.1.1' :allowed_hosts => '192.168.1.1'
)} )}
end end
context 'with persistence database enabled' do
before do
params.merge!( :persistence_dbname => 'octavia_persistence' )
end
it { should contain_openstacklib__db__mysql('octavia').with(
:user => 'octavia',
:password => 'octaviapass',
:dbname => 'octavia',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
)}
it { should contain_openstacklib__db__mysql('octavia_persistence').with(
:user => 'octavia',
:password => 'octaviapass',
:dbname => 'octavia_persistence',
:host => '127.0.0.1',
:charset => 'utf8',
:collate => 'utf8_general_ci',
:create_user => false,
)}
end
end end
on_supported_os({ on_supported_os({

View File

@ -25,8 +25,31 @@ describe 'octavia::db::postgresql' do
:encoding => nil, :encoding => nil,
:privileges => 'ALL', :privileges => 'ALL',
)} )}
it { is_expected.to_not contain_openstacklib__db__postgresql('octavia_persistence') }
end end
context 'with persistence database enabled' do
let :params do
req_params.merge!(:persistence_dbname => 'octavia_persistence')
end
it { is_expected.to contain_class('octavia::deps') }
it { is_expected.to contain_openstacklib__db__postgresql('octavia').with(
:user => 'octavia',
:password => 'octaviapass',
:dbname => 'octavia',
:encoding => nil,
:privileges => 'ALL',
)}
it { is_expected.to contain_openstacklib__db__postgresql('octavia_persistence').with(
:user => 'octavia',
:password => 'octaviapass',
:dbname => 'octavia_persistence',
:encoding => nil,
:privileges => 'ALL',
)}
end
end end
on_supported_os({ on_supported_os({

View File

@ -0,0 +1,68 @@
require 'spec_helper'
describe 'octavia::db::sync_persistence' do
shared_examples_for 'octavia::db::sync_persistenace' do
it { is_expected.to contain_class('octavia::deps') }
it 'runs octavia-manage db upgrade' do
is_expected.to contain_exec('octavia-db-sync').with(
:command => 'octavia-db-manage upgrade_persistence ',
:user => 'octavia',
:path => '/usr/bin',
:refreshonly => 'true',
:try_sleep => 5,
:tries => 10,
:timeout => 300,
:logoutput => 'on_failure',
:subscribe => ['Anchor[octavia::install::end]',
'Anchor[octavia::config::end]',
'Anchor[octavia::dbsync::begin]'],
:notify => 'Anchor[octavia::dbsync::end]',
:tag => 'openstack-db',
)
end
describe "overriding params" do
let :params do
{
:extra_params => '--config-file /etc/octavia/octavia.conf',
:db_sync_timeout => 750,
}
end
it {
is_expected.to contain_exec('octavia-db-sync').with(
:command => 'octavia-db-manage upgrade_persistence --config-file /etc/octavia/octavia.conf',
:user => 'octavia',
:path => '/usr/bin',
:refreshonly => 'true',
:try_sleep => 5,
:tries => 10,
:timeout => 750,
:logoutput => 'on_failure',
:subscribe => ['Anchor[octavia::install::end]',
'Anchor[octavia::config::end]',
'Anchor[octavia::dbsync::begin]'],
:notify => 'Anchor[octavia::dbsync::end]',
:tag => 'openstack-db',
)
}
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_configures 'octavia::db::sync_persistenace'
end
end
end

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'octavia::db::sync' do describe 'octavia::db::sync' do
shared_examples_for 'octavia-dbsync' do shared_examples_for 'octavia::db::sync' do
it { is_expected.to contain_class('octavia::deps') } it { is_expected.to contain_class('octavia::deps') }
@ -58,13 +58,10 @@ describe 'octavia::db::sync' do
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge(OSDefaults.get_facts({ facts.merge(OSDefaults.get_facts())
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat'
}))
end end
it_configures 'octavia-dbsync' it_configures 'octavia::db::sync'
end end
end end

View File

@ -0,0 +1,78 @@
require 'spec_helper'
describe 'octavia::task_flow' do
shared_examples 'octavia::task_flow' do
context 'with default parameters' do
it {
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>')
should contain_octavia_config('task_flow/jobboard_backend_driver').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_enabled').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_backend_hosts').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_backend_port').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_backend_password').with_value('<SERVICE DEFAULT>').with_secret(true)
should contain_octavia_config('task_flow/jobboard_backend_namespace').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_redis_sentinel').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_redis_backend_ssl_options').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('task_flow/jobboard_zookeeper_ssl_options').with_value('<SERVICE DEFAULT>')
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
context 'with specified parameters' do
let :params do
{
:engine => 'parallel',
:max_workers => 5,
:disable_revert => false,
:jobboard_backend_driver => 'redis_taskflow_driver',
:jobboard_enabled => true,
:jobboard_backend_hosts => ['192.168.0.2', '192.168.0.3'],
:jobboard_backend_port => 6379,
:jobboard_backend_password => 'secret',
:jobboard_backend_namespace => 'octavia_jobboard',
:jobboard_redis_sentinel => 'sentinel',
:jobboard_redis_backend_ssl_options => ['ssl:false', 'ssl_keyfile:None'],
:jobboard_zookeeper_ssl_options => ['use_ssl:false', 'keyfile:None'],
:jobboard_expiration_time => 30,
:jobboard_save_logbook => false,
:persistence_connection => 'sqlite://',
}
end
it {
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)
should contain_octavia_config('task_flow/jobboard_backend_driver').with_value('redis_taskflow_driver')
should contain_octavia_config('task_flow/jobboard_enabled').with_value(true)
should contain_octavia_config('task_flow/jobboard_backend_hosts').with_value('192.168.0.2,192.168.0.3')
should contain_octavia_config('task_flow/jobboard_backend_port').with_value(6379)
should contain_octavia_config('task_flow/jobboard_backend_password').with_value('secret').with_secret(true)
should contain_octavia_config('task_flow/jobboard_backend_namespace').with_value('octavia_jobboard')
should contain_octavia_config('task_flow/jobboard_redis_sentinel').with_value('sentinel')
should contain_octavia_config('task_flow/jobboard_redis_backend_ssl_options').with_value('ssl:false,ssl_keyfile:None')
should contain_octavia_config('task_flow/jobboard_zookeeper_ssl_options').with_value('use_ssl:false,keyfile:None')
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
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 'octavia::task_flow'
end
end
end