Support healthcheck middleware options

Trove introduced the healthcheck middleware during this cycle. This
introduces the new class to support the middleware options.

Depends-on: https://review.opendev.org/c/openstack/trove/+/910117
Change-Id: I5baf1e07078cb904d0c1ca17874c2639620e5e4f
This commit is contained in:
Takashi Kajinami 2024-02-28 11:12:11 +09:00
parent 8252b9f4a8
commit 06b384e84d
3 changed files with 119 additions and 0 deletions

54
manifests/healthcheck.pp Normal file
View File

@ -0,0 +1,54 @@
# == Class: trove::healthcheck
#
# Configure oslo_middleware options in healthcheck section
#
# == Params
#
# [*detailed*]
# (Optional) Show more detailed information as part of the response.
# Defaults to $facts['os_service_default']
#
# [*backends*]
# (Optional) Additional backends that can perform health checks and report
# that information back as part of a request.
# Defaults to $facts['os_service_default']
#
# [*allowed_source_ranges*]
# (Optional) A list of network addresses to limit source ip allowed to access
# healthcheck information.
# Defaults to $facts['os_service_default']
#
# [*ignore_proxied_requests*]
# (Optional) Ignore requests with proxy headers
# Defaults to $facts['os_service_default']
#
# [*disable_by_file_path*]
# (Optional) Check the presence of a file to determine if an application
# is running on a port.
# Defaults to $facts['os_service_default']
#
# [*disable_by_file_paths*]
# (Optional) Check the presence of a file to determine if an application
# is running on a port. Expects a "port:path" list of strings.
# Defaults to $facts['os_service_default']
#
class trove::healthcheck (
$detailed = $facts['os_service_default'],
$backends = $facts['os_service_default'],
$allowed_source_ranges = $facts['os_service_default'],
$ignore_proxied_requests = $facts['os_service_default'],
$disable_by_file_path = $facts['os_service_default'],
$disable_by_file_paths = $facts['os_service_default'],
) {
include trove::deps
oslo::healthcheck { 'trove_config':
detailed => $detailed,
backends => $backends,
allowed_source_ranges => $allowed_source_ranges,
ignore_proxied_requests => $ignore_proxied_requests,
disable_by_file_path => $disable_by_file_path,
disable_by_file_paths => $disable_by_file_paths,
}
}

View File

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

View File

@ -0,0 +1,61 @@
require 'spec_helper'
describe 'trove::healthcheck' do
shared_examples_for 'trove::healthcheck' do
context 'with default parameters' do
let :params do
{}
end
it 'configures default values' do
is_expected.to contain_oslo__healthcheck('trove_config').with(
:detailed => '<SERVICE DEFAULT>',
:backends => '<SERVICE DEFAULT>',
:allowed_source_ranges => '<SERVICE DEFAULT>',
:ignore_proxied_requests => '<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'],
:allowed_source_ranges => ['10.0.0.0/24', '10.0.1.0/24'],
:ignore_proxied_requests => false,
:disable_by_file_path => '/etc/trove/healthcheck/disabled',
:disable_by_file_paths => ['8779:/etc/trove/healthcheck/disabled'],
}
end
it 'configures specified values' do
is_expected.to contain_oslo__healthcheck('trove_config').with(
:detailed => true,
:backends => ['disable_by_file'],
:allowed_source_ranges => ['10.0.0.0/24', '10.0.1.0/24'],
:ignore_proxied_requests => false,
:disable_by_file_path => '/etc/trove/healthcheck/disabled',
:disable_by_file_paths => ['8779:/etc/trove/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 'trove::healthcheck'
end
end
end