diff --git a/manifests/driver_agent.pp b/manifests/driver_agent.pp new file mode 100644 index 00000000..44e7a083 --- /dev/null +++ b/manifests/driver_agent.pp @@ -0,0 +1,92 @@ +# Configures the octavia driver agent +# +# == Parameters +# +# [*status_socket_path*] +# (optional) Path to the driver status unix domain socket file. +# Defaults to $::os_service_default +# +# [*stats_socket_path*] +# (optional) Path to the driver statistics unix domain socket file. +# Defaults to $::os_service_default +# +# [*get_socket_path*] +# (optional) Path to the driver get unix domain socket file. +# Defaults to $::os_service_default +# +# [*status_request_timeout*] +# (optional) Time, in seconds, to wait for a status update request. +# Defaults to $::os_service_default +# +# [*status_max_processes*] +# (optional) Maximum number of concurrent processes to use servicing status +# updates. +# Defaults to $::os_service_default +# +# [*stats_request_timeout*] +# (optional) Time, in seconds, to wait for a statistics update request. +# Defaults to $::os_service_default +# +# [*stats_max_processes*] +# (optional) Maximum number of concurrent processes to use servicing +# statistics updates. +# Defaults to $::os_service_default +# +# [*get_request_timeout*] +# (optional) Time, in seconds, to wait for a get request. +# Defaults to $::os_service_default +# +# [*get_max_processes*] +# (optional) Maximum number of concurrent processes to use servicing get +# requests. +# Defaults to $::os_service_default +# +# [*max_process_warning_percent*] +# (optional) Percentage of max_processes (both status and stats) in use to +# start logging warning messages about an overloaded driver-agent. +# Defaults to $::os_service_default +# +# [*provider_agent_shutdown_timeout*] +# (optional) The time, in seconds, to wait for provider agents to shutdown +# after the exit event has been set. +# Defaults to $::os_service_default +# +# [*enabled_provider_agents*] +# (optional) List of enabled provider agents. The driver-agent will launch +# these agents at startup. +# Defaults to $::os_service_default +# +class octavia::driver_agent ( + $status_socket_path = $::os_service_default, + $stats_socket_path = $::os_service_default, + $get_socket_path = $::os_service_default, + $status_request_timeout = $::os_service_default, + $status_max_processes = $::os_service_default, + $stats_request_timeout = $::os_service_default, + $stats_max_processes = $::os_service_default, + $get_request_timeout = $::os_service_default, + $get_max_processes = $::os_service_default, + $max_process_warning_percent = $::os_service_default, + $provider_agent_shutdown_timeout = $::os_service_default, + $enabled_provider_agents = $::os_service_default, +) inherits octavia::params { + + include ::octavia::deps + + # Octavia packaging does not currently provide a separate agent service or package. + + octavia_config { + 'driver_agent/status_socket_path': value => $status_socket_path; + 'driver_agent/stats_socket_path': value => $stats_socket_path; + 'driver_agent/get_socket_path': value => $get_socket_path; + 'driver_agent/status_request_timeout': value => $status_request_timeout; + 'driver_agent/status_max_processes': value => $status_max_processes; + 'driver_agent/stats_request_timeout': value => $stats_request_timeout; + 'driver_agent/stats_max_processes': value => $stats_max_processes; + 'driver_agent/get_request_timeout': value => $get_request_timeout; + 'driver_agent/get_max_processes': value => $get_max_processes; + 'driver_agent/max_process_warning_percent': value => $max_process_warning_percent; + 'driver_agent/provider_agent_shutdown_timeout': value => $provider_agent_shutdown_timeout; + 'driver_agent/enabled_provider_agents': value => $enabled_provider_agents; + } +} diff --git a/releasenotes/notes/add-driver-agent-71b506e3d81e92fe.yaml b/releasenotes/notes/add-driver-agent-71b506e3d81e92fe.yaml new file mode 100644 index 00000000..c451fc07 --- /dev/null +++ b/releasenotes/notes/add-driver-agent-71b506e3d81e92fe.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added octavia::driver_agent for configuring driver agent properties. diff --git a/spec/classes/octavia_driver_agent_spec.rb b/spec/classes/octavia_driver_agent_spec.rb new file mode 100644 index 00000000..df032350 --- /dev/null +++ b/spec/classes/octavia_driver_agent_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' + +describe 'octavia::driver_agent' do + + let :params do + { + } + end + + shared_examples_for 'octavia-driver-agent' do + + context 'with default parameters' do + it { is_expected.to contain_octavia_config('driver_agent/status_socket_path').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/stats_socket_path').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/get_socket_path').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/status_request_timeout').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/status_max_processes').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/stats_request_timeout').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/stats_max_processes').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/get_request_timeout').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/get_max_processes').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/max_process_warning_percent').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/provider_agent_shutdown_timeout').with_value('') } + it { is_expected.to contain_octavia_config('driver_agent/enabled_provider_agents').with_value('') } + end + + context 'with specific parameters' do + before do + params.merge!({ + :status_socket_path => '/var/run/octavia/foo.sck', + :stats_socket_path => '/var/run/octavia/bar.sck', + :get_socket_path => '/var/run/octavia/pikachu.sck', + :status_request_timeout => 60, + :status_max_processes => 10, + :stats_request_timeout => 60, + :stats_max_processes => 10, + :get_request_timeout => 60, + :get_max_processes => 10, + :max_process_warning_percent => 0.60, + :provider_agent_shutdown_timeout => 60, + :enabled_provider_agents => ['agent-a', 'agent-b'], + }) + end + + it { is_expected.to contain_octavia_config('driver_agent/status_socket_path').with_value('/var/run/octavia/foo.sck') } + it { is_expected.to contain_octavia_config('driver_agent/stats_socket_path').with_value('/var/run/octavia/bar.sck') } + it { is_expected.to contain_octavia_config('driver_agent/get_socket_path').with_value('/var/run/octavia/pikachu.sck') } + it { is_expected.to contain_octavia_config('driver_agent/status_request_timeout').with_value(60)} + it { is_expected.to contain_octavia_config('driver_agent/status_max_processes').with_value(10) } + it { is_expected.to contain_octavia_config('driver_agent/stats_request_timeout').with_value(60) } + it { is_expected.to contain_octavia_config('driver_agent/stats_max_processes').with_value(10) } + it { is_expected.to contain_octavia_config('driver_agent/get_request_timeout').with_value(60) } + it { is_expected.to contain_octavia_config('driver_agent/get_max_processes').with_value(10) } + it { is_expected.to contain_octavia_config('driver_agent/max_process_warning_percent').with_value(0.60) } + it { is_expected.to contain_octavia_config('driver_agent/provider_agent_shutdown_timeout').with_value(60) } + it { is_expected.to contain_octavia_config('driver_agent/enabled_provider_agents').with_value(['agent-a', 'agent-b']) } + 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-driver-agent' + end + end + +end