From 74ce9e4d302caf96161f8b5e0f63f6c69a331737 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Oct 12 2015 19:41:43 +0000 Subject: prune old test composes when we push a release --- diff --git a/scripts/push-two-week-atomic.py b/scripts/push-two-week-atomic.py index 3ab914e..5705970 100755 --- a/scripts/push-two-week-atomic.py +++ b/scripts/push-two-week-atomic.py @@ -80,6 +80,9 @@ DATAGREPPER_CATEGORY = "autocloud" SIGUL_SIGNED_TXT_PATH = "/tmp/signed" +# Number of atomic testing composes to keep around +ATOMIC_COMPOSE_PERSIST_LIMIT = 20 + def get_latest_successful_autocloud_test_info( release, @@ -375,6 +378,31 @@ def fedmsg_publish(topic, msg): pass +def prune_old_testing_composes( + prune_limit=ATOMIC_COMPOSE_PERSIST_LIMIT, + prune_base_dir=ATOMIC_TESTING_BASEDIR): + """ + prune_old_testing_composes + + Clean up old testing composes from /pub/alt/ + """ + + prune_candidate_dirs = os.listdir(prune_base_dir) + + for testing_dir in prune_candidate_dirs[prune_limit:]: + try: + os.rmdir( + os.path.join(prune_base_dir, testing_dir) + ) + except OSError, e: + log.error( + "Error trying to remove directory: {0}\n{1}".format( + testing_dir, + e + ) + ) + + if __name__ == '__main__': # get args from command line @@ -458,6 +486,9 @@ if __name__ == '__main__': email_filelist.append(c_file) send_atomic_announce_email(set(email_filelist)) + log.info("Pruning old Atomic test composes") + prune_old_testing_composes() + log.info("Two Week Atomic Release Complete!") # vim: set expandtab sw=4 sts=4 ts=4