Browse Source

Add support for healthcheck middleware options

Change-Id: I0f81fe350954fccc59e76b1371ce333f3651eefa
changes/02/772202/4
Takashi Kajinami 1 year ago
parent
commit
8aa918c31d
  1. 43
      manifests/healthcheck.pp
  2. 4
      releasenotes/notes/healthcheck-middleware-c254827e460e7443.yaml
  3. 61
      spec/defines/oslo_healthcheck_spec.rb

43
manifests/healthcheck.pp

@ -0,0 +1,43 @@
# == Define: oslo::healthcheck
#
# Configure oslo_middleware options in healthcheck section
#
# === Parameters:
#
# [*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
#
define oslo::healthcheck(
$detailed = $::os_service_default,
$backends = $::os_service_default,
$disable_by_file_path = $::os_service_default,
$disable_by_file_paths = $::os_service_default,
) {
$backends_real = join(any2array($backends), ',')
$disable_by_file_paths_real = join(any2array($disable_by_file_paths), ',')
$healthcheck_options = {
'healthcheck/detailed' => { value => $detailed },
'healthcheck/backends' => { value => $backends_real },
'healthcheck/disable_by_file_path' => { value => $disable_by_file_path },
'healthcheck/disable_by_file_paths' => { value => $disable_by_file_paths_real},
}
create_resources($name, $healthcheck_options)
}

4
releasenotes/notes/healthcheck-middleware-c254827e460e7443.yaml

@ -0,0 +1,4 @@
---
features:
- |
Support for options of healthcheck middleware has been added.

61
spec/defines/oslo_healthcheck_spec.rb

@ -0,0 +1,61 @@
require 'spec_helper'
describe 'oslo::healthcheck' do
let (:title) { 'keystone_config' }
shared_examples 'oslo::healthcheck' do
context 'with default parameters' do
let :params do
{}
end
it 'configure healthcheck default params' do
is_expected.to contain_keystone_config('healthcheck/detailed').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('healthcheck/backends').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('healthcheck/disable_by_file_path').with_value('<SERVICE DEFAULT>')
is_expected.to contain_keystone_config('healthcheck/disable_by_file_paths').with_value('<SERVICE DEFAULT>')
end
end
context 'with parameters overridden' do
let :params do
{
:detailed => true,
:backends => ['disable_by_file', 'disable_by_files_ports'],
:disable_by_file_path => '/etc/keystone/healthcheck/disabled',
:disable_by_file_paths => [
'5000:/etc/keystone/healthcheck/public-disabled',
'35357:/etc/keystone/healthcheck/admin-disabled'
],
}
end
it 'configure healthcheck params' do
is_expected.to contain_keystone_config('healthcheck/detailed').with_value('true')
is_expected.to contain_keystone_config('healthcheck/backends').with_value(
'disable_by_file,disable_by_files_ports'
)
is_expected.to contain_keystone_config('healthcheck/disable_by_file_path').with_value(
'/etc/keystone/healthcheck/disabled'
)
is_expected.to contain_keystone_config('healthcheck/disable_by_file_paths').with_value(
'5000:/etc/keystone/healthcheck/public-disabled,35357:/etc/keystone/healthcheck/admin-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
include_examples 'oslo::healthcheck'
end
end
end
Loading…
Cancel
Save