Merge "Deprecate keystone::cron::token_fush"

This commit is contained in:
Zuul 2020-07-06 15:44:43 +00:00 committed by Gerrit Code Review
commit b0e2c76684
7 changed files with 25 additions and 117 deletions

View File

@ -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",

View File

@ -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'],
}
}

View File

@ -0,0 +1,5 @@
---
deprecations:
- |
The ``keystone::cron::token_flush`` class has been deprcated and has no
effect.

View File

@ -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|

View File

@ -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|

View File

@ -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|

View File

@ -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