From dd729322ab31b72194ab58f630fdc20a35527549 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 2 Jun 2022 13:27:07 +0900 Subject: [PATCH] Move common parameters from the health_manager class Some health_manager parameters are used not only by health-manager but also by worker. This change migrates the parameter used by these two services from the health_manager class to the controller class, so that we can deploy these two services separately. Change-Id: I33d7a11514508a459546c905afe2165fb9fa1ebf --- manifests/controller.pp | 41 ++++++++++++++---- manifests/health_manager.pp | 43 ++++++++++++++----- .../move-common-hm-opts-dbaaa1b575e6ae1c.yaml | 9 ++++ spec/classes/octavia_controller_spec.rb | 14 ++++-- 4 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/move-common-hm-opts-dbaaa1b575e6ae1c.yaml diff --git a/manifests/controller.pp b/manifests/controller.pp index c0c23cbe..5ef88ebc 100644 --- a/manifests/controller.pp +++ b/manifests/controller.pp @@ -86,12 +86,6 @@ # (optional) Time to wait for TCP packets for content inspection. # Defaults to $::os_service_default # -# [*controller_ip_port_list*] -# (optional) The list of controllers in a host:port comma separated -# list if multiple. This is added to the amphora config and is used -# when it connects back to the controllers to report its health. -# Defaults to $::os_service_default -# # [*connection_max_retries*] # (optional) Maximum number of retries when contacting amphora. # Defaults to $::os_service_default @@ -200,6 +194,20 @@ # (optional) Number of gratuitous ARP announcements to make on each refresh interval. # Defaults to $::os_service_default # +# [*controller_ip_port_list*] +# (optional) The list of controllers in a host:port comma separated +# list if multiple. This is added to the amphora config and is used +# when it connects back to the controllers to report its health. +# Defaults to $::os_service_default +# +# [*heartbeat_key*] +# (optional) Key to validate amphora messages. +# Defaults to undef +# +# [*heartbeat_interval*] +# (optional) Sleep time between sending heartbeats. +# Defaults to undef +# # DEPRECATED PARAMETERS # # [*port_detach_timeout*] @@ -226,7 +234,6 @@ class octavia::controller ( $timeout_member_connect = $::os_service_default, $timeout_member_data = $::os_service_default, $timeout_tcp_inspect = $::os_service_default, - $controller_ip_port_list = $::os_service_default, $connection_max_retries = $::os_service_default, $connection_retry_interval = $::os_service_default, $connection_logging = $::os_service_default, @@ -251,6 +258,11 @@ class octavia::controller ( $vrrp_success_count = $::os_service_default, $vrrp_garp_refresh_interval = $::os_service_default, $vrrp_garp_refresh_count = $::os_service_default, + $controller_ip_port_list = $::os_service_default, + # TODO(tkainam): Make this parameter required when we remove + # health_manager::heartbeat_key + $heartbeat_key = undef, + $heartbeat_interval = undef, # DEPRECATED PARAMETERS $port_detach_timeout = undef, ) inherits octavia::params { @@ -294,7 +306,6 @@ Use the octavia::networking class instead') 'haproxy_amphora/timeout_member_connect' : value => $timeout_member_connect; 'haproxy_amphora/timeout_member_data' : value => $timeout_member_data; 'haproxy_amphora/timeout_tcp_inspect' : value => $timeout_tcp_inspect; - 'health_manager/controller_ip_port_list' : value => join(any2array($controller_ip_port_list), ','); 'haproxy_amphora/connection_max_retries' : value => $connection_max_retries; 'haproxy_amphora/connection_retry_interval' : value => $connection_retry_interval; 'haproxy_amphora/connection_logging' : value => $connection_logging; @@ -319,5 +330,19 @@ Use the octavia::networking class instead') 'keepalived_vrrp/vrrp_success_count' : value => $vrrp_success_count; 'keepalived_vrrp/vrrp_garp_refresh_interval' : value => $vrrp_garp_refresh_interval; 'keepalived_vrrp/vrrp_garp_refresh_count' : value => $vrrp_garp_refresh_count; + 'health_manager/controller_ip_port_list' : value => join(any2array($controller_ip_port_list), ','); + } + + # TODO(tkajinam): Remove these if-condition when octavia::health_manager + # parameters are removed. + if $heartbeat_key != undef { + octavia_config{ + 'health_manager/heartbeat_key' : value => $heartbeat_key, secret => true; + } + } + if $heartbeat_interval != undef { + octavia_config{ + 'health_manager/heartbeat_interval' : value => $heartbeat_interval; + } } } diff --git a/manifests/health_manager.pp b/manifests/health_manager.pp index 1d9180dc..951164cb 100644 --- a/manifests/health_manager.pp +++ b/manifests/health_manager.pp @@ -2,9 +2,6 @@ # # == Parameters # -# [*heartbeat_key*] -# Key to validate amphora messages. -# # [*enabled*] # (optional) Should the service be enabled. # Defaults to true @@ -45,10 +42,6 @@ # (optional) Sleep time between health checks in seconds. # Defaults to $::os_service_default # -# [*heartbeat_interval*] -# (optional) Sleep time between sending heartbeats. -# Defaults to $::os_service_default -# # [*sock_rlimit*] # (optional) Sets the value of the heartbeat recv buffer # Defaults to $::os_service_default @@ -59,8 +52,15 @@ # (optional) The number of workers health_manager spawns # Defaults to undef # +# [*heartbeat_key*] +# (optional) Key to validate amphora messages. +# Defaults to undef +# +# [*heartbeat_interval*] +# (optional) Sleep time between sending heartbeats. +# Defaults to undef +# class octavia::health_manager ( - $heartbeat_key, $manage_service = true, $enabled = true, $package_ensure = 'present', @@ -71,13 +71,22 @@ class octavia::health_manager ( $failover_threads = $::os_service_default, $heartbeat_timeout = $::os_service_default, $health_check_interval = $::os_service_default, - $heartbeat_interval = $::os_service_default, $sock_rlimit = $::os_service_default, # DEPRECATED PARAMETERS $workers = undef, + $heartbeat_key = undef, + $heartbeat_interval = undef, ) inherits octavia::params { include octavia::deps + include octavia::controller + + if $heartbeat_key != undef { + warning('The heartbeat_key parameter is deprecated. Use the octavia::controller class parameter instead.') + } + if $heartbeat_key != undef { + warning('The heartbeat_interval parameter is deprecated. Use the octavia::controller class parameter instead.') + } validate_legacy(String, 'validate_string', $heartbeat_key) @@ -112,7 +121,6 @@ Use health_update_threads and stats_update_threads instead') $stats_update_threads_real = pick($workers, $stats_update_threads) octavia_config { - 'health_manager/heartbeat_key' : value => $heartbeat_key; 'health_manager/bind_ip' : value => $ip; 'health_manager/bind_port' : value => $port; 'health_manager/health_update_threads' : value => $health_update_threads_real; @@ -120,7 +128,20 @@ Use health_update_threads and stats_update_threads instead') 'health_manager/failover_threads' : value => $failover_threads; 'health_manager/heartbeat_timeout' : value => $heartbeat_timeout; 'health_manager/health_check_interval' : value => $health_check_interval; - 'health_manager/heartbeat_interval' : value => $heartbeat_interval; 'health_manager/sock_rlimit' : value => $sock_rlimit; } + + if $::octavia::controller::heartbeat_key == undef { + if $heartbeat_key == undef { + fail('The heartbeat_key parameter is required.') + } + octavia_config { + 'health_manager/heartbeat_key': value => $heartbeat_key, secret => true; + } + } + if $::octavia::controller::heartbeat_interval == undef { + octavia_config { + 'health_manager/heartbeat_interval': value => pick($heartbeat_interval, $::os_service_default); + } + } } diff --git a/releasenotes/notes/move-common-hm-opts-dbaaa1b575e6ae1c.yaml b/releasenotes/notes/move-common-hm-opts-dbaaa1b575e6ae1c.yaml new file mode 100644 index 00000000..4b879621 --- /dev/null +++ b/releasenotes/notes/move-common-hm-opts-dbaaa1b575e6ae1c.yaml @@ -0,0 +1,9 @@ +--- +deprecations: + - | + The following parameters of the ``octavia::health_manager`` class have been + deprecated. Use the same parameters of the ``octavia::controller`` class + instead. + + - ``heartbeat_interval`` + - ``heartbeat_key`` diff --git a/spec/classes/octavia_controller_spec.rb b/spec/classes/octavia_controller_spec.rb index f48e1bda..d5c91bd8 100644 --- a/spec/classes/octavia_controller_spec.rb +++ b/spec/classes/octavia_controller_spec.rb @@ -30,7 +30,6 @@ describe 'octavia::controller' do :timeout_client_data => 60, :timeout_member_connect => 5, :timeout_member_data => 60, - :controller_ip_port_list => ['1.2.3.4:5555', '4.3.2.1:5555'], :connection_max_retries => 240, :connection_retry_interval => 10, :active_connection_max_retries => 15, @@ -55,7 +54,10 @@ describe 'octavia::controller' do :vrrp_fail_count => 2, :vrrp_success_count => 2, :vrrp_garp_refresh_interval => 5, - :vrrp_garp_refresh_count => 2 + :vrrp_garp_refresh_count => 2, + :controller_ip_port_list => ['1.2.3.4:5555', '4.3.2.1:5555'], + :heartbeat_interval => 10, + :heartbeat_key => 'default_key', } end @@ -77,7 +79,6 @@ describe 'octavia::controller' do is_expected.to contain_octavia_config('haproxy_amphora/timeout_client_data').with_value(60) is_expected.to contain_octavia_config('haproxy_amphora/timeout_member_connect').with_value(5) is_expected.to contain_octavia_config('haproxy_amphora/timeout_member_data').with_value(60) - is_expected.to contain_octavia_config('health_manager/controller_ip_port_list').with_value('1.2.3.4:5555,4.3.2.1:5555') is_expected.to contain_octavia_config('haproxy_amphora/connection_max_retries').with_value(240) is_expected.to contain_octavia_config('haproxy_amphora/connection_retry_interval').with_value(10) is_expected.to contain_octavia_config('haproxy_amphora/connection_logging').with_value(false) @@ -103,6 +104,9 @@ describe 'octavia::controller' do is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_success_count').with_value(2) is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_garp_refresh_interval').with_value(5) is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_garp_refresh_count').with_value(2) + is_expected.to contain_octavia_config('health_manager/controller_ip_port_list').with_value('1.2.3.4:5555,4.3.2.1:5555') + is_expected.to contain_octavia_config('health_manager/heartbeat_interval').with_value(10) + is_expected.to contain_octavia_config('health_manager/heartbeat_key').with_value('default_key') end end @@ -125,7 +129,6 @@ describe 'octavia::controller' do is_expected.to contain_octavia_config('haproxy_amphora/timeout_member_connect').with_value('') is_expected.to contain_octavia_config('haproxy_amphora/timeout_member_data').with_value('') is_expected.to contain_octavia_config('haproxy_amphora/timeout_tcp_inspect').with_value('') - is_expected.to contain_octavia_config('health_manager/controller_ip_port_list').with_value('') is_expected.to contain_octavia_config('haproxy_amphora/connection_max_retries').with_value('') is_expected.to contain_octavia_config('haproxy_amphora/connection_retry_interval').with_value('') is_expected.to contain_octavia_config('haproxy_amphora/connection_logging').with_value('') @@ -151,6 +154,9 @@ describe 'octavia::controller' do is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_success_count').with_value('') is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_garp_refresh_interval').with_value('') is_expected.to contain_octavia_config('keepalived_vrrp/vrrp_garp_refresh_count').with_value('') + is_expected.to contain_octavia_config('health_manager/controller_ip_port_list').with_value('') + #is_expected.to contain_octavia_config('health_manager/heartbeat_interval').with_value('') + #is_expected.to contain_octavia_config('health_manager/heartbeat_key').with_value('') end context 'with ssh key access disabled' do