Merge "Add support for healthcheck middleware options"

This commit is contained in:
Zuul 2021-03-26 04:57:26 +00:00 committed by Gerrit Code Review
commit b417b88a2a
5 changed files with 123 additions and 0 deletions

View File

@ -72,6 +72,10 @@
# (optional) The maximum number of items returned in a single response.
# Defaults to $::os_service_default
#
# [*healthcheck_enabled*]
# (optional) Enable the oslo middleware healthcheck endppint.
# Defaults to $::os_service_default
#
# DEPRECATED PARAMETERS
#
# [*ovn_nb_connection*]
@ -95,6 +99,7 @@ class octavia::api (
$default_provider_driver = $::os_service_default,
$provider_drivers = $::os_service_default,
$pagination_max_limit = $::os_service_default,
$healthcheck_enabled = $::os_service_default,
# DEPRECATED PARAMETERS
$ovn_nb_connection = undef
) inherits octavia::params {
@ -161,6 +166,7 @@ class octavia::api (
'api_settings/default_provider_driver': value => $default_provider_driver;
'api_settings/enabled_provider_drivers': value => $provider_drivers;
'api_settings/pagination_max_limit': value => $pagination_max_limit;
'api_settings/healthcheck_enabled': value => $healthcheck_enabled;
}
oslo::middleware { 'octavia_config':

41
manifests/healthcheck.pp Normal file
View File

@ -0,0 +1,41 @@
# == Define: octavia::healthcheck
#
# Configure oslo_middleware options in healthcheck section
#
# == Params
#
# [*detailed*]
# (Optional) Show more detailed information as part of the response.
# Defaults to $::os_service_default
#
# [*backends*]
# (Optional) Additional backends that can perform health checks and report
# that information back as part of a request.
# Defaults to $::os_service_default
#
# [*disable_by_file_path*]
# (Optional) Check the presense of a file to determine if an application
# is running on a port.
# Defaults to $::os_service_default
#
# [*disable_by_file_paths*]
# (Optional) Check the presense of a file to determine if an application
# is running on a port. Expects a "port:path" list of strings.
# Defaults to $::os_service_default
#
class octavia::healthcheck (
$detailed = $::os_service_default,
$backends = $::os_service_default,
$disable_by_file_path = $::os_service_default,
$disable_by_file_paths = $::os_service_default,
) {
include octavia::deps
oslo::healthcheck { 'octavia_config':
detailed => $detailed,
backends => $backends,
disable_by_file_path => $disable_by_file_path,
disable_by_file_paths => $disable_by_file_paths,
}
}

View File

@ -0,0 +1,8 @@
---
features:
- |
The new ``octavia::api::healthcheck_enabled`` parameter has been added.
- |
The new ``octavia::healthcheck`` class has been added. This class manages
parameters of healthcheck middlware in oslo.middleware.

View File

@ -14,6 +14,7 @@ describe 'octavia::api' do
:default_provider_driver => 'ovn',
:provider_drivers => { 'amphora' => 'Octavia Amphora Driver', 'ovn' => 'Octavia OVN driver' },
:pagination_max_limit => '1000',
:healthcheck_enabled => true,
}
end
@ -55,6 +56,7 @@ describe 'octavia::api' do
is_expected.to contain_octavia_config('api_settings/default_provider_driver').with_value('<SERVICE DEFAULT>')
is_expected.to contain_octavia_config('api_settings/enabled_provider_drivers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_octavia_config('api_settings/pagination_max_limit').with_value('<SERVICE DEFAULT>')
is_expected.to contain_octavia_config('api_settings/healthcheck_enabled').with_value('<SERVICE DEFAULT>')
is_expected.to contain_oslo__middleware('octavia_config').with(
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
)
@ -74,6 +76,7 @@ describe 'octavia::api' do
is_expected.to contain_octavia_config('api_settings/default_provider_driver').with_value( params[:default_provider_driver] )
is_expected.to contain_octavia_config('api_settings/enabled_provider_drivers').with_value( params[:provider_drivers] )
is_expected.to contain_octavia_config('api_settings/pagination_max_limit').with_value( params[:pagination_max_limit] )
is_expected.to contain_octavia_config('api_settings/healthcheck_enabled').with_value( params[:healthcheck_enabled] )
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
@ -129,6 +132,16 @@ describe 'octavia::api' do
end
end
context 'with healthcheck enabled' do
before do
params.merge!({
:healthcheck_enabled => true })
end
it 'configures healthcheck_enabled' do
is_expected.to contain_octavia_config('api_settings/healthcheck_enabled').with_value(true)
end
end
end
shared_examples 'octavia-api wsgi' do

View File

@ -0,0 +1,55 @@
require 'spec_helper'
describe 'octavia::healthcheck' do
shared_examples_for 'octavia::healthcheck' do
context 'with default parameters' do
let :params do
{}
end
it 'configures default values' do
is_expected.to contain_oslo__healthcheck('octavia_config').with(
:detailed => '<SERVICE DEFAULT>',
:backends => '<SERVICE DEFAULT>',
:disable_by_file_path => '<SERVICE DEFAULT>',
:disable_by_file_paths => '<SERVICE DEFAULT>',
)
end
end
context 'with specific parameters' do
let :params do
{
:detailed => true,
:backends => ['disable_by_file'],
:disable_by_file_path => '/etc/octavia/healthcheck/disabled',
:disable_by_file_paths => ['9876:/etc/octavia/healthcheck/disabled'],
}
end
it 'configures specified values' do
is_expected.to contain_oslo__healthcheck('octavia_config').with(
:detailed => true,
:backends => ['disable_by_file'],
:disable_by_file_path => '/etc/octavia/healthcheck/disabled',
:disable_by_file_paths => ['9876:/etc/octavia/healthcheck/disabled'],
)
end
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::healthcheck'
end
end
end