Commit fc3fd894 authored by Michael Hanselmann's avatar Michael Hanselmann

Add script to clean archived jobs after 21 days

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 93962b80
......@@ -27,6 +27,9 @@
/*.tar.bz2
/*.tar.gz
# daemons
/daemons/ganeti-cleaner
# devel
/devel/clean-cluster
/devel/upload
......
......@@ -45,6 +45,7 @@ MAINTAINERCLEANFILES = \
CLEANFILES = \
autotools/replace_vars.sed \
daemons/ganeti-cleaner \
devel/upload \
doc/rapi-resources.gen \
doc/examples/bash_completion \
......@@ -139,6 +140,9 @@ dist_sbin_SCRIPTS = \
scripts/gnt-node \
scripts/gnt-os
nodist_sbin_SCRIPTS = \
daemons/ganeti-cleaner
dist_tools_SCRIPTS = \
tools/burnin \
tools/cfgshell \
......@@ -151,6 +155,7 @@ EXTRA_DIST = \
DEVNOTES \
pylintrc \
autotools/docbook-wrapper \
daemons/ganeti-cleaner.in \
devel/upload.in \
$(docrst) \
$(docdot) \
......@@ -243,6 +248,11 @@ doc/examples/%: doc/examples/%.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
daemons/ganeti-cleaner: daemons/ganeti-cleaner.in stamp-directories \
$(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
chmod +x $@
doc/%.html: doc/%.rst
@test -n "$(RST2HTML)" || { echo 'rst2html' not found during configure; exit 1; }
$(RST2HTML) $< $@
......
#!/bin/bash
#
# Copyright (C) 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
set -e
DATA_DIR=@LOCALSTATEDIR@/lib/ganeti
QUEUE_ARCHIVE_DIR=$DATA_DIR/queue/archive
# Define how many days archived jobs should be left alone
REMOVE_AFTER=21
# Exit if machine is not part of a cluster
[[ -e $DATA_DIR/ssconf_master_node ]] || echo 0
# Exit if queue archive directory doesn't exist
[[ -d $QUEUE_ARCHIVE_DIR ]] || exit 0
# Remove old jobs
find $QUEUE_ARCHIVE_DIR -mindepth 2 -type f -mtime +$REMOVE_AFTER -print0 | \
xargs -r0 rm -f
exit 0
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
# restart failed instances
# Restart failed instances (every 5 minutes)
*/5 * * * * root [ -x @SBINDIR@/ganeti-watcher ] && @SBINDIR@/ganeti-watcher
# Clean job archive (at 01:45 AM)
45 1 * * * root [ -x @SBINDIR@/ganeti-cleaner ] && @SBINDIR@/ganeti-cleaner
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment