crontab to move deleted instance rows to another database table
Create a crontab which moves deleted instances rows to another database table that you don't have to backup. This is done to optimize database management at scale. Depending on the amount of deleted instances that you get on a daily basis you want to modify the $max_rows parameter. This feature is implemented as in nova CLI and addressed by this blueprint: https://blueprints.launchpad.net/nova/+spec/db-archiving Change-Id: Ia03fa6862aefcbcc7d7949b08d00bacf679cb548 Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
68
manifests/cron/archive_deleted_rows.pp
Normal file
68
manifests/cron/archive_deleted_rows.pp
Normal file
@@ -0,0 +1,68 @@
|
||||
#
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||
#
|
||||
# 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: nova::cron::archive_deleted_rows
|
||||
#
|
||||
# Move deleted instances to another table that you don't have to backup
|
||||
# unless you have data retention policies.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*minute*]
|
||||
# (optional) Defaults to '1'.
|
||||
#
|
||||
# [*hour*]
|
||||
# (optional) Defaults to '0'.
|
||||
#
|
||||
# [*monthday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*month*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*max_rows*]
|
||||
# (optional) Maximum number of deleted rows to archive.
|
||||
# Defaults to '100'.
|
||||
#
|
||||
# [*user*]
|
||||
# (optional) User with access to nova files.
|
||||
# Defaults to 'nova'.
|
||||
#
|
||||
class nova::cron::archive_deleted_rows (
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$max_rows = '100',
|
||||
$user = 'nova',
|
||||
) {
|
||||
|
||||
cron { 'nova-manage db archive_deleted_rows':
|
||||
command => "nova-manage db archive_deleted_rows --max_rows ${max_rows} >>/var/log/nova/nova-rowsflush.log 2>&1",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
user => $user,
|
||||
minute => $minute,
|
||||
hour => $hour,
|
||||
monthday => $monthday,
|
||||
month => $month,
|
||||
weekday => $weekday,
|
||||
}
|
||||
}
|
21
spec/classes/nova_cron_archive_deleted_rows_spec.rb
Normal file
21
spec/classes/nova_cron_archive_deleted_rows_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::cron::archive_deleted_rows' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it 'configures a cron' do
|
||||
should contain_cron('nova-manage db archive_deleted_rows').with(
|
||||
:command => 'nova-manage db archive_deleted_rows --max_rows 100 >>/var/log/nova/nova-rowsflush.log 2>&1',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
:user => 'nova',
|
||||
:minute => 1,
|
||||
:hour => 0,
|
||||
:monthday => '*',
|
||||
:month => '*',
|
||||
:weekday => '*'
|
||||
)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user