From cf1dd1ea62020f62bb151ffc3d65bdfd8f22fc25 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 15 Nov 2019 13:59:34 +0900 Subject: [PATCH] Add support for swift-recon-cron job Add support to configure swift-recon-cron job, which is required to have object async pendings shown in recon API. Change-Id: Iae3705db38ebaddf92ee6e80c20c1011f8f66706 --- manifests/storage/cron/recon.pp | 69 +++++++++++++++++++ .../notes/recon-cron-6f90f5d626d70aa5.yaml | 4 ++ spec/classes/swift_storage_cron_recon_spec.rb | 59 ++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 manifests/storage/cron/recon.pp create mode 100644 releasenotes/notes/recon-cron-6f90f5d626d70aa5.yaml create mode 100644 spec/classes/swift_storage_cron_recon_spec.rb diff --git a/manifests/storage/cron/recon.pp b/manifests/storage/cron/recon.pp new file mode 100644 index 00000000..bda7c3d8 --- /dev/null +++ b/manifests/storage/cron/recon.pp @@ -0,0 +1,69 @@ +# +# Copyright (C) 2019 Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: swift::storage::cron::recon +# +# Configure cron job to reflect statistics related to async pendings into recon +# +# === Parameters +# +# [*minute*] +# (optional) Defaults to '*/5'. +# +# [*hour*] +# (optional) Defaults to '*'. +# +# [*monthday*] +# (optional) Defaults to '*'. +# +# [*month*] +# (optional) Defaults to '*'. +# +# [*weekday*] +# (optional) Defaults to '*'. +# +# [*configfile*] +# (optional) Path to object server config file. +# Defaults to '/etc/swift/object-server.conf'. +# +# [*user*] +# (optional) User with access to swift files. +# swift::storage::server::user will be used if this is undef. +# Defaults to 'swift'. +# + +class swift::storage::cron::recon( + $minute = '*/5', + $hour = '*', + $monthday = '*', + $month = '*', + $weekday = '*', + $configfile = '/etc/swift/object-server.conf', + $user = 'swift' +) { + include ::swift::deps + include ::swift::params + + cron { 'swift-recon-cron': + command => "swift-recon-cron ${configfile}", + environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', + user => $user, + minute => $minute, + hour => $hour, + monthday => $monthday, + month => $month, + weekday => $weekday, + } +} diff --git a/releasenotes/notes/recon-cron-6f90f5d626d70aa5.yaml b/releasenotes/notes/recon-cron-6f90f5d626d70aa5.yaml new file mode 100644 index 00000000..01cba642 --- /dev/null +++ b/releasenotes/notes/recon-cron-6f90f5d626d70aa5.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add ability to configure swift-recon-cron job. diff --git a/spec/classes/swift_storage_cron_recon_spec.rb b/spec/classes/swift_storage_cron_recon_spec.rb new file mode 100644 index 00000000..4b2217eb --- /dev/null +++ b/spec/classes/swift_storage_cron_recon_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' + +describe 'swift::storage::cron::recon' do + shared_examples 'swift::storage::cron::recon' do + + let :pre_condition do + "class { 'swift': swift_hash_path_suffix => 'foo' } + class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }" + end + + let :params do + {} + end + + context 'with no parameters specified' do + it { is_expected.to contain_cron('swift-recon-cron').with( + :command => 'swift-recon-cron /etc/swift/object-server.conf', + :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', + :user => 'swift', + :minute => '*/5', + :hour => '*', + :monthday => '*', + :month => '*', + :weekday => '*', + )} + end + + context 'with parameters specified' do + before :each do + params.merge!({ + :configfile => '/opt/swift/object-server.conf', + :user => 'foo', + :minute => '*/1' + }) + end + + it { is_expected.to contain_cron('swift-recon-cron').with( + :command => 'swift-recon-cron /opt/swift/object-server.conf', + :user => 'foo', + :minute => '*/1', + :hour => '*', + :monthday => '*', + :month => '*', + :weekday => '*', + )} + 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_configures 'swift::storage::cron::recon' + end + end +end