From b9f6f6bf62c700c6ba64c1d9520a26d30b835d15 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 28 Apr 2020 13:17:13 +1000 Subject: [PATCH] Allow disabling build-log-retention This allows setting build-log-retention to -1 to disable automatic collection of logs. This would facilitate managing these logs with an external tool like logrotate. Another case is where you have the builds failing very quickly -- say, one of the builds has destroyed the container and so builds fail to even exec dib correctly. In this case it's difficult to get to the root-cause of the problem because the first build's logs (the one that destroyed the container) have been repead just seconds after the failure. Change-Id: I259c78e6a0e30b4c0a8d2f4c12a6941a2d227c38 --- doc/source/configuration.rst | 2 +- nodepool/builder.py | 2 ++ releasenotes/notes/retention-disable-ac0c43d3912c1311.yaml | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/retention-disable-ac0c43d3912c1311.yaml diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index b611757d6..e0e29ee63 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -83,7 +83,7 @@ Options they exceed this value. This option specifies how many will be kept (usually you will see one more, as deletion happens before starting a new build). By default, the last 7 old build logs are - kept. + kept. Set this to ``-1`` to disable removal of logs. .. attr:: zookeeper-servers :type: list diff --git a/nodepool/builder.py b/nodepool/builder.py index e8561920e..80d044dc8 100644 --- a/nodepool/builder.py +++ b/nodepool/builder.py @@ -592,6 +592,8 @@ class BuildWorker(BaseWorker): return log_dir def _pruneBuildLogs(self, name): + if self._config.build_log_retention < 0: + return log_dir = self._getBuildLogRoot(name) keep = max(self._config.build_log_retention, 1) existing = sorted(os.listdir(log_dir)) diff --git a/releasenotes/notes/retention-disable-ac0c43d3912c1311.yaml b/releasenotes/notes/retention-disable-ac0c43d3912c1311.yaml new file mode 100644 index 000000000..61b95be55 --- /dev/null +++ b/releasenotes/notes/retention-disable-ac0c43d3912c1311.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Setting ``build-log-retention`` to ``-1`` will disable the removal of + old build logs.