From 3cda309287e20c186ff9023432e5f43a99653d6d Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Fri, 27 Nov 2015 23:44:04 +0100 Subject: [PATCH] openstack: cleanup leftovers every 30 minutes Resources are billed by the hour, it makes a difference to cleanup leftovers once every hour. Provide a crontab that runs teuthology-nuke --stale-openstack every 30 minutes. Signed-off-by: Loic Dachary --- teuthology/openstack/openstack-teuthology.cron | 2 ++ teuthology/openstack/setup-openstack.sh | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 teuthology/openstack/openstack-teuthology.cron diff --git a/teuthology/openstack/openstack-teuthology.cron b/teuthology/openstack/openstack-teuthology.cron new file mode 100644 index 0000000000..ee919bf7e9 --- /dev/null +++ b/teuthology/openstack/openstack-teuthology.cron @@ -0,0 +1,2 @@ +SHELL=/bin/bash +*/30 * * * * ( date ; source $HOME/openrc.sh ; time timeout 900 $HOME/teuthology/virtualenv/bin/teuthology-nuke --stale-openstack ) >> $HOME/cron.log 2>&1 diff --git a/teuthology/openstack/setup-openstack.sh b/teuthology/openstack/setup-openstack.sh index 7c24ed0d05..88bf61012a 100755 --- a/teuthology/openstack/setup-openstack.sh +++ b/teuthology/openstack/setup-openstack.sh @@ -275,6 +275,15 @@ function setup_bootscript() { echo "CREATED init script /etc/init.d/teuthology" } +function setup_crontab() { + local where=$(dirname $0) + crontab $where/openstack-teuthology.cron +} + +function remove_crontab() { + crontab -r +} + function get_or_create_keypair() { local keypair=$1 local key_file=$HOME/.ssh/id_rsa @@ -556,6 +565,7 @@ function main() { setup_authorized_keys || return 1 setup_bashrc || return 1 setup_bootscript $nworkers || return 1 + setup_crontab || return 1 fi if $do_setup_keypair ; then @@ -586,6 +596,7 @@ function main() { teardown_pulpito || return 1 teardown_ansible || return 1 remove_images || return 1 + remove_crontab || return 1 fi } -- 2.39.5