From c3916c7fe294604f277e3ce602786a7a798217f6 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 27 Jun 2022 17:51:19 +0900 Subject: [PATCH] Manage driver-agent package/service in CentOS ... because the independent driver-agent package was added to RDO[1]. [1] https://review.rdoproject.org/r/c/openstack/octavia-distgit/+/32779 Change-Id: I6d9e16d4a7c85a90c1388583a4d14ff21224345a --- manifests/driver_agent.pp | 38 +++++++-------- manifests/params.pp | 5 +- .../driver-agent-redhat-a36354fb074bf05c.yaml | 6 +++ spec/classes/octavia_driver_agent_spec.rb | 48 ++++++++++--------- 4 files changed, 51 insertions(+), 46 deletions(-) create mode 100644 releasenotes/notes/driver-agent-redhat-a36354fb074bf05c.yaml diff --git a/manifests/driver_agent.pp b/manifests/driver_agent.pp index 6921b5e7..768de7d3 100644 --- a/manifests/driver_agent.pp +++ b/manifests/driver_agent.pp @@ -89,30 +89,26 @@ class octavia::driver_agent ( include octavia::deps include octavia::params - if $::octavia::params::driver_agent_package_name { - package { 'octavia-driver-agent': - ensure => $package_ensure, - name => $::octavia::params::driver_agent_package_name, - tag => ['openstack', 'octavia-package'], - } + package { 'octavia-driver-agent': + ensure => $package_ensure, + name => $::octavia::params::driver_agent_package_name, + tag => ['openstack', 'octavia-package'], } - if $::octavia::params::driver_agent_service_name { - if $manage_service { - if $enabled { - $service_ensure = 'running' - } else { - $service_ensure = 'stopped' - } + if $manage_service { + if $enabled { + $service_ensure = 'running' + } else { + $service_ensure = 'stopped' + } - service { 'octavia-driver-agent': - ensure => $service_ensure, - name => $::octavia::params::driver_agent_service_name, - enable => $enabled, - hasstatus => true, - hasrestart => true, - tag => ['octavia-service'] - } + service { 'octavia-driver-agent': + ensure => $service_ensure, + name => $::octavia::params::driver_agent_service_name, + enable => $enabled, + hasstatus => true, + hasrestart => true, + tag => ['octavia-service'] } } diff --git a/manifests/params.pp b/manifests/params.pp index f05db802..641499ee 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,6 +7,7 @@ class octavia::params { $worker_service_name = 'octavia-worker' $health_manager_service_name = 'octavia-health-manager' $housekeeping_service_name = 'octavia-housekeeping' + $driver_agent_service_name = 'octavia-driver-agent' $client_package_name = 'python3-octaviaclient' $ovn_provider_package_name = 'python3-ovn-octavia-provider' $user = 'octavia' @@ -19,10 +20,9 @@ class octavia::params { $worker_package_name = 'openstack-octavia-worker' $health_manager_package_name = 'openstack-octavia-health-manager' $housekeeping_package_name = 'openstack-octavia-housekeeping' - $driver_agent_package_name = false + $driver_agent_package_name = 'openstack-octavia-driver-agent' $octavia_wsgi_script_path = '/var/www/cgi-bin/octavia' $octavia_wsgi_script_source = '/usr/bin/octavia-wsgi' - $driver_agent_service_name = false } 'Debian': { $common_package_name = 'octavia-common' @@ -33,7 +33,6 @@ class octavia::params { $driver_agent_package_name = 'octavia-driver-agent' $octavia_wsgi_script_path = '/usr/lib/cgi-bin/octavia' $octavia_wsgi_script_source = '/usr/bin/octavia-wsgi' - $driver_agent_service_name = 'octavia-driver-agent' } default: { fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ diff --git a/releasenotes/notes/driver-agent-redhat-a36354fb074bf05c.yaml b/releasenotes/notes/driver-agent-redhat-a36354fb074bf05c.yaml new file mode 100644 index 00000000..36e17828 --- /dev/null +++ b/releasenotes/notes/driver-agent-redhat-a36354fb074bf05c.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The ``octavia::driver_agent`` class now supports managing the package and + the service required to run the ``octavia-driver-agent`` process in Cent OS + and RHEL. diff --git a/spec/classes/octavia_driver_agent_spec.rb b/spec/classes/octavia_driver_agent_spec.rb index 31fcece8..044478d5 100644 --- a/spec/classes/octavia_driver_agent_spec.rb +++ b/spec/classes/octavia_driver_agent_spec.rb @@ -9,6 +9,21 @@ describe 'octavia::driver_agent' do shared_examples_for 'octavia-driver-agent' do context 'with default parameters' do + it { is_expected.to contain_package('octavia-driver-agent').with( + :ensure => 'present', + :name => platform_params[:driver_agent_package_name], + :tag => ['openstack', 'octavia-package'], + ) } + + it { is_expected.to contain_service('octavia-driver-agent').with( + :ensure => 'running', + :name => platform_params[:driver_agent_service_name], + :enable => true, + :hasstatus => true, + :hasrestart => true, + :tag => ['octavia-service'] + ) } + 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('') } @@ -56,25 +71,6 @@ describe 'octavia::driver_agent' do end end - shared_examples_for 'octavia-driver-agent on Debian' do - context 'with default parameters' do - it { is_expected.to contain_package('octavia-driver-agent').with( - :ensure => 'present', - :name => 'octavia-driver-agent', - :tag => ['openstack', 'octavia-package'], - ) } - - it { is_expected.to contain_service('octavia-driver-agent').with( - :ensure => 'running', - :name => 'octavia-driver-agent', - :enable => true, - :hasstatus => true, - :hasrestart => true, - :tag => ['octavia-service'] - ) } - end - end - on_supported_os({ :supported_os => OSDefaults.get_supported_os }).each do |os,facts| @@ -83,10 +79,18 @@ describe 'octavia::driver_agent' do facts.merge!(OSDefaults.get_facts()) end - it_behaves_like 'octavia-driver-agent' - if facts[:osfamily] == 'Debian' - it_behaves_like 'octavia-driver-agent on Debian' + let(:platform_params) do + case facts[:osfamily] + when 'Debian' + { :driver_agent_package_name => 'octavia-driver-agent', + :driver_agent_service_name => 'octavia-driver-agent' } + when 'RedHat' + { :driver_agent_package_name => 'openstack-octavia-driver-agent', + :driver_agent_service_name => 'octavia-driver-agent' } + end end + + it_behaves_like 'octavia-driver-agent' end end