From fd8badd39c04ca49ca4c49a6ce7cef26349d3960 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 6 Jul 2020 08:39:50 +0900 Subject: [PATCH] Deprecate keystone::cron::token_fush ... because ``keystone-manage token_flush`` was already removed from keystone[1]. [1] https://github.com/openstack/keystone/commit/48dcdb5ad3ea47e923da3ab4a1572159d7cac6df Change-Id: I8a7abed59468f93d48aa38a47ad4f72d994da79a --- examples/apache_with_paths.pp | 1 - manifests/cron/token_flush.pp | 57 ++++++---------- ...ate-cron-token_flush-b76a1db6715a818b.yaml | 5 ++ ...stone_federation_identity_provider_spec.rb | 4 -- .../keystone_federation_shibboleth_spec.rb | 4 -- spec/acceptance/keystone_wsgi_apache_spec.rb | 4 -- .../classes/keystone_cron_token_flush_spec.rb | 67 ------------------- 7 files changed, 25 insertions(+), 117 deletions(-) create mode 100644 releasenotes/notes/deprecate-cron-token_flush-b76a1db6715a818b.yaml delete mode 100644 spec/classes/keystone_cron_token_flush_spec.rb diff --git a/examples/apache_with_paths.pp b/examples/apache_with_paths.pp index 5e23ccf01..bc40d26d5 100644 --- a/examples/apache_with_paths.pp +++ b/examples/apache_with_paths.pp @@ -30,7 +30,6 @@ class { 'keystone': catalog_type => 'sql', enabled => true, } -class { 'keystone::cron::token_flush': } class { 'keystone::bootstrap': password => 'ChangeMe', public_url => "https://${::fqdn}:443/main", diff --git a/manifests/cron/token_flush.pp b/manifests/cron/token_flush.pp index a20572f1b..43af3f74c 100644 --- a/manifests/cron/token_flush.pp +++ b/manifests/cron/token_flush.pp @@ -17,78 +17,61 @@ # # == Class: keystone::cron::token_flush # +# DEPRECATED! # Installs a cron job to purge expired tokens. # # === Parameters # # [*ensure*] # (Optional) Valid values are present, absent. -# Defaults to 'present' +# Defaults to undef # # [*minute*] # (Optional) Minute. -# Defaults to '1' +# Defaults to undef # # [*hour*] # (Optional) Hour. -# Defaults to * +# Defaults to undef # # [*monthday*] # (Optional) Day of month. -# Defaults to '*' +# Defaults to undef # # [*month*] # (Optional) Month. -# Defaults to '*' +# Defaults to undef # # [*weekday*] # (Optional) Day of week. -# Defaults to '*' +# Defaults to undef # # [*maxdelay*] # (Optional) Max random delay in seconds. Should be a positive integer. # Induces a random delay before running the cronjob to avoid running all # cron jobs at the same time on all hosts this job is configured. -# Defaults to 0 +# Defaults to undef # # [*destination*] # (Optional) Path to file to which rows should be archived -# Defaults to '/var/log/keystone/keystone-tokenflush.log' +# Defaults to undef # # [*user*] # (Optional) Allow to run the crontab on behalf any user. -# Defaults to 'keystone' +# Defaults to undef # class keystone::cron::token_flush ( - $ensure = present, - $minute = 1, - $hour = '*', - $monthday = '*', - $month = '*', - $weekday = '*', - Integer $maxdelay = 0, - $destination = '/var/log/keystone/keystone-tokenflush.log', - $user = 'keystone', + $ensure = undef, + $minute = undef, + $hour = undef, + $monthday = undef, + $month = undef, + $weekday = undef, + $maxdelay = undef, + $destination = undef, + $user = undef, ) { - include keystone::deps + warning('The keystone::cron::token_flush class is deprecated and has no effect') - if $maxdelay == 0 { - $sleep = '' - } else { - $sleep = "sleep `expr \${RANDOM} \\% ${maxdelay}`; " - } - - cron { 'keystone-manage token_flush': - ensure => $ensure, - command => "${sleep}keystone-manage token_flush >>${destination} 2>&1", - environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', - user => $user, - minute => $minute, - hour => $hour, - monthday => $monthday, - month => $month, - weekday => $weekday, - require => Anchor['keystone::install::end'], - } } diff --git a/releasenotes/notes/deprecate-cron-token_flush-b76a1db6715a818b.yaml b/releasenotes/notes/deprecate-cron-token_flush-b76a1db6715a818b.yaml new file mode 100644 index 000000000..d120651c7 --- /dev/null +++ b/releasenotes/notes/deprecate-cron-token_flush-b76a1db6715a818b.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + The ``keystone::cron::token_flush`` class has been deprcated and has no + effect. diff --git a/spec/acceptance/keystone_federation_identity_provider_spec.rb b/spec/acceptance/keystone_federation_identity_provider_spec.rb index 018dc78a3..6d83c97bd 100644 --- a/spec/acceptance/keystone_federation_identity_provider_spec.rb +++ b/spec/acceptance/keystone_federation_identity_provider_spec.rb @@ -82,10 +82,6 @@ describe 'keystone server running with Apache/WSGI as Identity Provider' do it { is_expected.to be_listening } end - describe cron do - it { is_expected.to have_entry('1 * * * * keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1').with_user('keystone') } - end - shared_examples_for 'keystone user/tenant/service/role/endpoint resources using v3 API' do |auth_creds| it 'should find beaker user' do shell("openstack #{auth_creds} --os-auth-url http://127.0.0.1:5000/v3 --os-identity-api-version 3 user list") do |r| diff --git a/spec/acceptance/keystone_federation_shibboleth_spec.rb b/spec/acceptance/keystone_federation_shibboleth_spec.rb index e817de700..59b17b7e4 100644 --- a/spec/acceptance/keystone_federation_shibboleth_spec.rb +++ b/spec/acceptance/keystone_federation_shibboleth_spec.rb @@ -80,10 +80,6 @@ describe 'keystone server running with Apache/WSGI as Service Provider with Shib it { is_expected.to be_listening } end - describe cron do - it { is_expected.to have_entry('1 * * * * keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1').with_user('keystone') } - end - shared_examples_for 'keystone user/tenant/service/role/endpoint resources using v3 API' do |auth_creds| it 'should find beaker user' do shell("openstack #{auth_creds} --os-auth-url http://127.0.0.1:5000/v3 --os-identity-api-version 3 user list") do |r| diff --git a/spec/acceptance/keystone_wsgi_apache_spec.rb b/spec/acceptance/keystone_wsgi_apache_spec.rb index 16ce5c7e9..30753222d 100644 --- a/spec/acceptance/keystone_wsgi_apache_spec.rb +++ b/spec/acceptance/keystone_wsgi_apache_spec.rb @@ -76,10 +76,6 @@ describe 'keystone server running with Apache/WSGI with resources' do it { is_expected.to be_listening } end - describe cron do - it { is_expected.to have_entry('1 * * * * keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1').with_user('keystone') } - end - shared_examples_for 'keystone user/tenant/service/role/endpoint resources using v3 API' do |auth_creds| it 'should find beaker user' do shell("openstack #{auth_creds} --os-auth-url http://127.0.0.1:5000/v3 --os-identity-api-version 3 user list") do |r| diff --git a/spec/classes/keystone_cron_token_flush_spec.rb b/spec/classes/keystone_cron_token_flush_spec.rb deleted file mode 100644 index dbeadaad7..000000000 --- a/spec/classes/keystone_cron_token_flush_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' - -describe 'keystone::cron::token_flush' do - let :params do - {} - end - - shared_examples 'keystone::cron::token_flush' do - context 'with default parameters' do - it { is_expected.to contain_class('keystone::deps') } - - it { is_expected.to contain_cron('keystone-manage token_flush').with( - :ensure => 'present', - :command => 'keystone-manage token_flush >>/var/log/keystone/keystone-tokenflush.log 2>&1', - :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', - :user => 'keystone', - :minute => 1, - :hour => '*', - :monthday => '*', - :month => '*', - :weekday => '*', - :require => 'Anchor[keystone::install::end]', - )} - end - - context 'with overriden params' do - before do - params.merge!( :ensure => 'absent', - :minute => 13, - :hour => 23, - :monthday => 3, - :month => 4, - :weekday => 2, - :maxdelay => 600, - :destination => '/tmp/tokenflush.log', - :user => 'nobody' ) - end - - it { is_expected.to contain_class('keystone::deps') } - - it { is_expected.to contain_cron('keystone-manage token_flush').with( - :ensure => params[:ensure], - :command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; keystone-manage token_flush >>#{params[:destination]} 2>&1", - :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', - :user => params[:user], - :minute => params[:minute], - :hour => params[:hour], - :monthday => params[:monthday], - :month => params[:month], - :weekday => params[:weekday], - :require => 'Anchor[keystone::install::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 - - it_behaves_like 'keystone::cron::token_flush' - end - end -end