Merge "Restart httpd after config change" into stable/2023.1

This commit is contained in:
Zuul 2024-01-25 15:59:58 +00:00 committed by Gerrit Code Review
commit b686fc2280
6 changed files with 39 additions and 61 deletions

View File

@ -56,6 +56,6 @@ The class allows more flexible customization of the ${dashboard} dashboard.")
ensure_packages($dashboard_package_name, {
'ensure' => $ensure,
'tag' => ['horizon-dashboard-package']
'tag' => ['horizon-package']
})
}

View File

@ -25,15 +25,13 @@ class horizon::deps {
-> Package<| tag == 'horizon-package' |>
~> anchor { 'horizon::install::end': }
-> anchor { 'horizon::config::begin': }
-> Concat<| tag == 'django-config' |>
~> anchor { 'horizon::config::end': }
-> anchor { 'horizon::compress::begin': }
-> Exec<| tag == 'horizon-compress' |>
~> anchor { 'horizon::compress::begin': }
~> Exec<| tag == 'horizon-compress' |>
~> anchor { 'horizon::compress::end': }
-> anchor { 'horizon::dashboard::begin': }
-> Package<| tag == 'horizon-dashboard-package' |>
~> anchor { 'horizon::dashboard::end': }
-> anchor { 'horizon::service::begin': }
-> Service<| title == 'httpd' |>
~> anchor { 'horizon::service::begin': }
~> Service<| title == 'httpd' |>
~> anchor { 'horizon::service::end': }
# policy config should occur in the config block
@ -41,8 +39,10 @@ class horizon::deps {
-> Openstacklib::Policy<| tag == 'horizon' |>
~> Anchor['horizon::config::end']
# Regenerate django cache after package update
Anchor['horizon::install::end'] ~> Anchor['horizon::compress::begin']
# Installation or config changes will always restart services.
Anchor['horizon::install::end'] ~> Anchor['horizon::service::begin']
Anchor['horizon::config::end'] ~> Anchor['horizon::service::begin']
Anchor['horizon::dashboard::end'] ~> Anchor['horizon::service::begin']
}

View File

@ -810,7 +810,6 @@ class horizon(
owner => $::horizon::params::wsgi_user,
group => $::horizon::params::wsgi_group,
show_diff => false,
require => Anchor['horizon::config::begin'],
tag => ['django-config'],
}
@ -828,22 +827,20 @@ class horizon(
require => Anchor['horizon::config::begin'],
}
exec { 'refresh_horizon_django_cache':
command => "${::horizon::params::manage_py} collectstatic --noinput --clear",
refreshonly => true,
tag => ['horizon-compress'],
}
exec { 'refresh_horizon_django_compress':
command => "${::horizon::params::manage_py} compress --force",
refreshonly => true,
tag => ['horizon-compress'],
}
if $compress_offline {
Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_compress']
if $facts['os']['family'] == 'RedHat' {
Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_cache'] -> Exec['refresh_horizon_django_compress']
exec { 'refresh_horizon_django_cache':
command => "${::horizon::params::manage_py} collectstatic --noinput --clear",
refreshonly => true,
tag => ['horizon-compress'],
}
Exec['refresh_horizon_django_cache'] -> Exec['refresh_horizon_django_compress']
}
exec { 'refresh_horizon_django_compress':
command => "${::horizon::params::manage_py} compress --force",
refreshonly => true,
tag => ['horizon-compress'],
}
}

View File

@ -214,8 +214,7 @@ class horizon::wsgi::apache (
fail("Invalid redirect type '${redirect_type} provided.")
}
Package['horizon'] -> Package['httpd']
Concat[$::horizon::params::config_file] ~> Service['httpd']
Anchor['horizon::install::end'] -> Package['httpd']
$unix_user = $::horizon::params::wsgi_user
$unix_group = $::horizon::params::wsgi_group

View File

@ -23,23 +23,11 @@ describe 'horizon' do
:tag => ['openstack', 'horizon-package'],
)
}
it { is_expected.to contain_exec('refresh_horizon_django_cache').with({
:command => '/usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear',
:refreshonly => true,
})}
it { is_expected.to contain_exec('refresh_horizon_django_compress').with({
:command => '/usr/share/openstack-dashboard/manage.py compress --force',
:refreshonly => true,
:command => '/usr/share/openstack-dashboard/manage.py compress --force',
:refreshonly => true,
})}
it {
if facts[:os]['family'] == 'RedHat'
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]')
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]')
else
is_expected.to_not contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]')
is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]')
end
is_expected.to contain_concat(platforms_params[:config_file]).with(
:mode => '0640',
:owner => platforms_params[:wsgi_user],
@ -219,8 +207,8 @@ describe 'horizon' do
end
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with_ensure('directory') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]') }
it { is_expected.to_not contain_exec('refresh_horizon_django_cache') }
it { is_expected.to_not contain_exec('refresh_horizon_django_compress') }
it { is_expected.to contain_file(params[:file_upload_temp_dir]) }
end
@ -237,9 +225,6 @@ describe 'horizon' do
" 'LOCATION': [ '10.0.0.1:11211','10.0.0.2:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters, IPv6 cache_server_ip array and MemcachedCache' do
@ -256,9 +241,6 @@ describe 'horizon' do
" 'LOCATION': [ 'inet6:[fd12:3456:789a:1::1]:11211','inet6:[fd12:3456:789a:1::2]:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters, IPv6 cache_server_ip array and PyMemcacheCache' do
@ -275,9 +257,6 @@ describe 'horizon' do
" 'LOCATION': [ '[fd12:3456:789a:1::1]:11211','[fd12:3456:789a:1::2]:11211', ],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url (string)' do
@ -292,9 +271,6 @@ describe 'horizon' do
" 'LOCATION': 'redis://:password@10.0.0.1:6379/1',",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'with overridden parameters and cache_server_url (array)' do
@ -309,9 +285,6 @@ describe 'horizon' do
" 'LOCATION': ['192.0.2.1:11211','192.0.2.2:11211'],",
])
end
it { is_expected.to contain_exec('refresh_horizon_django_cache') }
it { is_expected.to contain_exec('refresh_horizon_django_compress') }
end
context 'installs python memcache library when cache_backend is set to memcache' do
@ -741,6 +714,12 @@ describe 'horizon' do
"WEBROOT = '/dashboard/'",
])
end
it 'refreshes django cache' do
is_expected.to contain_exec('refresh_horizon_django_cache').with({
:command => '/usr/share/openstack-dashboard/manage.py collectstatic --noinput --clear',
:refreshonly => true,
})
end
end
shared_examples_for 'horizon on Debian' do
@ -749,6 +728,9 @@ describe 'horizon' do
"WEBROOT = '/horizon/'",
])
end
it 'does not refreshe django cache' do
is_expected.to_not contain_exec('refresh_horizon_django_cache')
end
end
on_supported_os({

View File

@ -26,7 +26,7 @@ describe 'horizon::dashboard' do
context 'with default' do
it { should contain_package(platform_params[:heat_dashboard_package_name]).with(
:ensure => 'installed',
:tag => ['horizon-dashboard-package']
:tag => ['horizon-package']
)}
end
@ -39,7 +39,7 @@ describe 'horizon::dashboard' do
it { should contain_package(platform_params[:heat_dashboard_package_name]).with(
:ensure => 'absent',
:tag => ['horizon-dashboard-package']
:tag => ['horizon-package']
)}
end
end
@ -48,7 +48,7 @@ describe 'horizon::dashboard' do
context 'with default' do
it { should contain_package('python3-heat-dashboard').with(
:ensure => 'installed',
:tag => ['horizon-dashboard-package']
:tag => ['horizon-package']
)}
end
end
@ -57,7 +57,7 @@ describe 'horizon::dashboard' do
context 'with default' do
it { should contain_package('python3-heat-dashboard').with(
:ensure => 'installed',
:tag => ['horizon-dashboard-package']
:tag => ['horizon-package']
)}
end
end