From 73d7b77d37824ca7858c9d2cf3222ca2dd6aa9c7 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 10 2020 11:24:28 +0000 Subject: [PATCH 1/4] builder: configurable TTL for buildroots Fixes: https://pagure.io/koji/issue/2374 --- diff --git a/builder/kojid b/builder/kojid index 6d78ad2..d00b555 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6441,6 +6441,8 @@ def get_options(): quit('invalid section found in config file: %s' % x) defaults = {'sleeptime': 15, 'maxjobs': 10, + 'buildroot_basic_cleanup_delay': 120, + 'buildroot_final_cleanup_delay': 3600 * 2, 'literal_task_arches': '', 'minspace': 8192, 'admin_emails': None, diff --git a/builder/kojid.conf b/builder/kojid.conf index 8a43cf0..53013ef 100644 --- a/builder/kojid.conf +++ b/builder/kojid.conf @@ -5,6 +5,14 @@ ; The maximum number of jobs that kojid will handle at a time ; maxjobs=10 +; Time after successfully finished task's buildroot is deleted (2 minutes in seconds) +; Some logs and directories are left in place until buildroot_final_cleanup_delay +; buildroot_basic_cleanup_delay=120 + + +; Time after successfully finished task's buildroot is deleted completely (1 day in seconds) +; buildroot_basic_cleanup_delay=86400 + ; The minimum amount of free space (in MBs) required for each build root ; minspace=8192 diff --git a/docs/source/kojid_conf.rst b/docs/source/kojid_conf.rst index e208295..01160bd 100644 --- a/docs/source/kojid_conf.rst +++ b/docs/source/kojid_conf.rst @@ -25,6 +25,16 @@ General serves as a backup to the capacity check and prevents a tremendous number of low weight jobs from piling up. + buildroot_basic_cleanup_delay=120 + Time after which successfully finished task's buildroot is deleted (2 + minutes in seconds). Some logs and directories are left in place until + buildroot_final_cleanup_delay + + buildroot_final_cleanup_delay=86400 + Time after which buildroot (pre-cleand after + ``buildroot_basic_cleanup_delay``) is deleted completely. (1 day in + seconds) + max_retries=120 Set the maximum number of times that an individual hub call can be retried. diff --git a/koji/daemon.py b/koji/daemon.py index 4edf6d7..fea5970 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -737,7 +737,7 @@ class TaskManager(object): # can lead to a world of hurt. # We remove the rootdir contents but leave the rootdir unless it # is really old - if age > 3600 * 24: + if age > self.options.buildroot_final_cleanup_delay: # dir untouched for a day self.logger.info("Removing buildroot: %s" % desc) if ((topdir and safe_rmtree(topdir, unmount=True, strict=False) != 0) or @@ -749,7 +749,7 @@ class TaskManager(object): os.unlink(data['cfg']) except OSError as e: self.logger.warning("%s: can't remove config: %s" % (desc, e)) - elif age > 120 and rootdir: + elif age > self.options.buildroot_basic_cleanup_delay and rootdir: for d in (topdir, topdir_bootstrap): if not d: continue From 18d76f90b9dd6204b55d65ed2e36e8c9be0be10e Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 16 2020 08:13:24 +0000 Subject: [PATCH 2/4] typo --- diff --git a/builder/kojid.conf b/builder/kojid.conf index 53013ef..bc4b297 100644 --- a/builder/kojid.conf +++ b/builder/kojid.conf @@ -11,7 +11,7 @@ ; Time after successfully finished task's buildroot is deleted completely (1 day in seconds) -; buildroot_basic_cleanup_delay=86400 +; buildroot_final_cleanup_delay=86400 ; The minimum amount of free space (in MBs) required for each build root ; minspace=8192 From 8e52cf6700eceb3aac50dc402f6f0eb0e9e0f6da Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 16 2020 12:44:34 +0000 Subject: [PATCH 3/4] fix option parsing --- diff --git a/builder/kojid b/builder/kojid index d00b555..78b953f 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6502,7 +6502,8 @@ def get_options(): if name in ['sleeptime', 'maxjobs', 'minspace', 'retry_interval', 'max_retries', 'offline_retry_interval', 'failed_buildroot_lifetime', 'timeout', 'rpmbuild_timeout', 'oz_install_timeout', - 'task_avail_delay']: + 'task_avail_delay', 'buildroot_basic_cleanup_delay', + 'buildroot_final_cleanup_delay']: try: defaults[name] = int(value) except ValueError: From b6e8d34939ebc8f8c26be92dadb8e229d1b8f185 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Sep 17 2020 08:36:25 +0000 Subject: [PATCH 4/4] fix default value --- diff --git a/builder/kojid b/builder/kojid index 78b953f..685b9e2 100755 --- a/builder/kojid +++ b/builder/kojid @@ -6442,7 +6442,7 @@ def get_options(): defaults = {'sleeptime': 15, 'maxjobs': 10, 'buildroot_basic_cleanup_delay': 120, - 'buildroot_final_cleanup_delay': 3600 * 2, + 'buildroot_final_cleanup_delay': 86400, 'literal_task_arches': '', 'minspace': 8192, 'admin_emails': None,