diff mbox series

[bug#54659,2/2] services: Add 'log-cleanup' service to '%base-services' for build logs.

Message ID 20220331212208.24385-2-ludo@gnu.org
State Accepted
Headers show
Series Periodically delete build logs | expand

Commit Message

Ludovic Courtès March 31, 2022, 9:22 p.m. UTC
* gnu/services/base.scm (%base-services): Add 'log-cleanup-service-type'
instance.
* doc/guix.texi (Log Rotation): Add example and mention '%base-services'.
---
 doc/guix.texi         | 13 ++++++++++++-
 gnu/services/base.scm |  6 ++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

Comments

Liliana Marie Prikler April 1, 2022, 6:05 a.m. UTC | #1
Am Donnerstag, dem 31.03.2022 um 23:22 +0200 schrieb Ludovic Courtès:
> * gnu/services/base.scm (%base-services): Add 'log-cleanup-service-
> type'
> instance.
> * doc/guix.texi (Log Rotation): Add example and mention '%base-
> services'.
> ---
>  doc/guix.texi         | 13 ++++++++++++-
>  gnu/services/base.scm |  6 ++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guix.texi b/doc/guix.texi
> index ad2763ec8a..eaaf829aa2 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -17645,7 +17645,18 @@ Some log files just need to be deleted
> periodically once they are old,
>  without any other criterion and without any archival step.  This is
> the
>  case of build logs stored by @command{guix-daemon} under
>  @file{/var/log/guix/drvs} (@pxref{Invoking guix-daemon}).  The
> -@code{log-cleanup} service addresses this use case.
> +@code{log-cleanup} service addresses this use case.  For example,
> +@code{%base-services} (@pxref{Base Services}) includes the
> following:
> +
> +@lisp
> +;; Periodically delete build logs more than 4 months old.
> +(service log-cleanup-service-type
> +         (log-cleanup-configuration
> +          (directory "/var/log/guix/drvs")
> +          (expiry (* 4 30 24 3600))))
> +@end lisp
> +
> +That ensures build logs do not accumulate endlessly.
>  
>  @defvr {Scheme Variable} log-cleanup-service-type
>  This is the type of the service to delete old logs.  Its value must
> be a
> diff --git a/gnu/services/base.scm b/gnu/services/base.scm
> index f278cb76de..ebaba524bc 100644
> --- a/gnu/services/base.scm
> +++ b/gnu/services/base.scm
> @@ -2817,6 +2817,12 @@ (define %base-services
>  
>          (service rottlog-service-type)
>  
> +        ;; Periodically delete build logs more than 4 months old.
> +        (service log-cleanup-service-type
> +                 (log-cleanup-configuration
> +                  (directory "/var/log/guix/drvs")
> +                  (expiry (* 4 30 24 3600))))
> +
This might be very nitpicky, but I think we should leave expiry
undefined so that the default of 6 months is applied.  This way, if
there's a future decision that all logs should probably kept e.g. for
only 3 months, there is just one place to edit rather than two.

Cheers
Ludovic Courtès April 1, 2022, 3:41 p.m. UTC | #2
Hi!

Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> skribis:

>> +        ;; Periodically delete build logs more than 4 months old.
>> +        (service log-cleanup-service-type
>> +                 (log-cleanup-configuration
>> +                  (directory "/var/log/guix/drvs")
>> +                  (expiry (* 4 30 24 3600))))
>> +
> This might be very nitpicky, but I think we should leave expiry
> undefined so that the default of 6 months is applied.  This way, if
> there's a future decision that all logs should probably kept e.g. for
> only 3 months, there is just one place to edit rather than two.

Yeah, dunno; I thought we’d rather be explicit, but maybe you’re right.

Ludo’.
Ludovic Courtès April 4, 2022, 9:17 p.m. UTC | #3
Hi,

Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> skribis:

> This might be very nitpicky, but I think we should leave expiry
> undefined so that the default of 6 months is applied.  This way, if
> there's a future decision that all logs should probably kept e.g. for
> only 3 months, there is just one place to edit rather than two.

In the end I followed your suggestion and pushed as
e692dc632cbb0e6d21ed6f09f4c7f52391802cfb.

Thanks!

Ludo’.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index ad2763ec8a..eaaf829aa2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -17645,7 +17645,18 @@  Some log files just need to be deleted periodically once they are old,
 without any other criterion and without any archival step.  This is the
 case of build logs stored by @command{guix-daemon} under
 @file{/var/log/guix/drvs} (@pxref{Invoking guix-daemon}).  The
-@code{log-cleanup} service addresses this use case.
+@code{log-cleanup} service addresses this use case.  For example,
+@code{%base-services} (@pxref{Base Services}) includes the following:
+
+@lisp
+;; Periodically delete build logs more than 4 months old.
+(service log-cleanup-service-type
+         (log-cleanup-configuration
+          (directory "/var/log/guix/drvs")
+          (expiry (* 4 30 24 3600))))
+@end lisp
+
+That ensures build logs do not accumulate endlessly.
 
 @defvr {Scheme Variable} log-cleanup-service-type
 This is the type of the service to delete old logs.  Its value must be a
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index f278cb76de..ebaba524bc 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2817,6 +2817,12 @@  (define %base-services
 
         (service rottlog-service-type)
 
+        ;; Periodically delete build logs more than 4 months old.
+        (service log-cleanup-service-type
+                 (log-cleanup-configuration
+                  (directory "/var/log/guix/drvs")
+                  (expiry (* 4 30 24 3600))))
+
         ;; The LVM2 rules are needed as soon as LVM2 or the device-mapper is
         ;; used, so enable them by default.  The FUSE and ALSA rules are
         ;; less critical, but handy.