Add support for [compute] parameters

This change introduces the new octavia::compute class, to manage
parameters in the [compute] section.

Change-Id: I139ed46b7acbb81d9c01c8708f91af9e5d2900a3
This commit is contained in:
Takashi Kajinami 2021-11-30 00:00:57 +09:00
parent 2fb4a5b1e0
commit cf24d758af
3 changed files with 89 additions and 0 deletions

40
manifests/compute.pp Normal file
View File

@ -0,0 +1,40 @@
# == Class: octavia::compute
#
# Setup and configure octavia.conf compute section.
#
# === Parameters:
#
# [*max_retries*]
# (Optional) The maximum attempts to retry an acction with the compute
# service.
# Defaults to $::os_service_default
#
# [*retry_interval*]
# (Optional) Seocnds to wait before retrying an action with the compute
# service.
# Defaults to $::os_service_default
#
# [*retry_backoff*]
# (Optional) The seconds to backoff retry attempts.
# Defaults to $::os_service_default
#
# [*retry_max*]
# (Optional) The maximum interval in seconds between retry attempts.
# Defaults to $::os_service_default
#
class octavia::compute (
$max_retries = $::os_service_default,
$retry_interval = $::os_service_default,
$retry_backoff = $::os_service_default,
$retry_max = $::os_service_default,
) {
include octavia::deps
octavia_config {
'compute/max_retries': value => $max_retries;
'compute/retry_interval': value => $retry_interval;
'compute/retry_backoff': value => $retry_backoff;
'compute/retry_max': value => $retry_max;
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``octavia::compute`` class has been added.

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'octavia::compute' do
shared_examples 'octavia::compute' do
context 'with default parameters' do
it {
should contain_octavia_config('compute/max_retries').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('compute/retry_interval').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('compute/retry_backoff').with_value('<SERVICE DEFAULT>')
should contain_octavia_config('compute/retry_max').with_value('<SERVICE DEFAULT>')
}
end
context 'with parameters set' do
let :params do
{
:max_retries => 15,
:retry_interval => 1,
:retry_backoff => 2,
:retry_max => 10,
}
end
it {
should contain_octavia_config('compute/max_retries').with_value(15)
should contain_octavia_config('compute/retry_interval').with_value(1)
should contain_octavia_config('compute/retry_backoff').with_value(2)
should contain_octavia_config('compute/retry_max').with_value(10)
}
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::compute'
end
end
end