mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
services: ganeti: Produce Shepherd timers instead of mcron jobs.
* gnu/services/ganeti.scm (<ganeti-watcher-configuration>)[schedule]: Change default value to a cron string. (ganeti-timer): New procedure. (ganeti-watcher-jobs): Rename to… (ganeti-watcher-service): … this. Return Shepherd services. (ganeti-watcher-service-type)[extensions]: Adjust accordingly. (ganeti-cleaner-jobs): Rename to… (ganeti-cleaner-service): … this. Return Shepherd services. (ganeti-cleaner-service-type)[extensions]: Adjust accordingly. (ganeti-shepherd-services): Include the watcher and cleaner services. (ganeti-mcron-jobs): Remove. (ganeti-service-type)[extensions]: Adjust accordingly. * doc/guix.texi (Virtualization Services): Update ‘schedule’ documentation. Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Change-Id: Id209a3c50271203dc7190c4c6d0c0ffdf6c10875
This commit is contained in:
@@ -39883,8 +39883,11 @@ The service takes a @code{ganeti-watcher-configuration} object.
|
|||||||
@item @code{ganeti} (default: @code{ganeti})
|
@item @code{ganeti} (default: @code{ganeti})
|
||||||
The @code{ganeti} package to use for this service.
|
The @code{ganeti} package to use for this service.
|
||||||
|
|
||||||
@item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
|
@item @code{schedule} (default: @code{"*/5 * * * *"})
|
||||||
How often to run the script. The default is every five minutes.
|
When to run the script, expressed either as a string in traditional cron
|
||||||
|
syntax or as a gexp representing a Shepherd calendar event
|
||||||
|
(@pxref{Timers,,, shepherd, The GNU Shepherd Manual}). The default is
|
||||||
|
every five minutes.
|
||||||
|
|
||||||
@item @code{rapi-ip} (default: @code{#f})
|
@item @code{rapi-ip} (default: @code{#f})
|
||||||
This option needs to be specified only if the RAPI daemon is configured to use
|
This option needs to be specified only if the RAPI daemon is configured to use
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
|
;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
|
||||||
|
;;; Copyright © 2025 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
@@ -19,14 +20,11 @@
|
|||||||
(define-module (gnu services ganeti)
|
(define-module (gnu services ganeti)
|
||||||
#:use-module (gnu packages virtualization)
|
#:use-module (gnu packages virtualization)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services mcron)
|
|
||||||
#:use-module (gnu services shepherd)
|
#:use-module (gnu services shepherd)
|
||||||
#:use-module (guix gexp)
|
#:use-module (guix gexp)
|
||||||
#:use-module (guix records)
|
#:use-module (guix records)
|
||||||
|
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
|
|
||||||
#:export (ganeti-noded-configuration
|
#:export (ganeti-noded-configuration
|
||||||
ganeti-noded-configuration?
|
ganeti-noded-configuration?
|
||||||
ganeti-noded-configuration-ganeti
|
ganeti-noded-configuration-ganeti
|
||||||
@@ -644,9 +642,8 @@ information to OS install scripts or instances.")))
|
|||||||
(ganeti ganeti-watcher-configuration-ganeti ;file-like
|
(ganeti ganeti-watcher-configuration-ganeti ;file-like
|
||||||
(default ganeti))
|
(default ganeti))
|
||||||
(schedule ganeti-watcher-configuration-schedule ;list | string
|
(schedule ganeti-watcher-configuration-schedule ;list | string
|
||||||
(default '(next-second-from
|
;; Run every 5 minutes.
|
||||||
;; Run every five minutes.
|
(default "*/5 * * * *"))
|
||||||
(next-minute (range 0 60 5)))))
|
|
||||||
(rapi-ip ganeti-watcher-configuration-rapi-ip ;#f | string
|
(rapi-ip ganeti-watcher-configuration-rapi-ip ;#f | string
|
||||||
(default #f))
|
(default #f))
|
||||||
(job-age ganeti-watcher-configuration-job-age ;integer
|
(job-age ganeti-watcher-configuration-job-age ;integer
|
||||||
@@ -660,36 +657,47 @@ information to OS install scripts or instances.")))
|
|||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <ganeti-watcher-configuration> ganeti _ rapi-ip job-age verify-disks?
|
(($ <ganeti-watcher-configuration> ganeti _ rapi-ip job-age verify-disks?
|
||||||
debug?)
|
debug?)
|
||||||
#~(lambda ()
|
#~(#$(file-append ganeti "/sbin/ganeti-watcher")
|
||||||
(system* #$(file-append ganeti "/sbin/ganeti-watcher")
|
#$@(if rapi-ip
|
||||||
#$@(if rapi-ip
|
#~((string-append "--rapi-ip=" #$rapi-ip))
|
||||||
#~((string-append "--rapi-ip=" #$rapi-ip))
|
#~())
|
||||||
#~())
|
#$(string-append "--job-age=" (number->string job-age))
|
||||||
#$(string-append "--job-age=" (number->string job-age))
|
#$@(if verify-disks?
|
||||||
#$@(if verify-disks?
|
#~()
|
||||||
#~()
|
#~("--no-verify-disks"))
|
||||||
#~("--no-verify-disks"))
|
#$@(if debug?
|
||||||
#$@(if debug?
|
#~("--debug")
|
||||||
#~("--debug")
|
#~())))))
|
||||||
#~()))))))
|
|
||||||
|
|
||||||
(define (ganeti-watcher-jobs config)
|
(define (ganeti-timer name schedule command)
|
||||||
|
"Return a Shepherd timer providing NAME and running COMMAND, a list-valued
|
||||||
|
gexp."
|
||||||
|
(shepherd-service
|
||||||
|
(provision (list name))
|
||||||
|
(requirement '(user-processes))
|
||||||
|
(modules '((shepherd service timer)))
|
||||||
|
(start #~(make-timer-constructor
|
||||||
|
#$(if (string? schedule)
|
||||||
|
#~(cron-string->calendar-event #$schedule)
|
||||||
|
schedule)
|
||||||
|
(command '(#$@command))
|
||||||
|
#:wait-for-termination? #t))
|
||||||
|
(stop #~(make-timer-destructor))
|
||||||
|
(documentation "Periodically run a Ganeti maintenance job.")
|
||||||
|
(actions (list shepherd-trigger-action))))
|
||||||
|
|
||||||
|
(define (ganeti-watcher-service config)
|
||||||
(match config
|
(match config
|
||||||
(($ <ganeti-watcher-configuration> _ schedule)
|
(($ <ganeti-watcher-configuration> _ schedule)
|
||||||
(list
|
(list (ganeti-timer 'ganeti-watcher
|
||||||
#~(job #$@(match schedule
|
schedule
|
||||||
((? string?)
|
(ganeti-watcher-command config))))))
|
||||||
#~(#$schedule))
|
|
||||||
((? list?)
|
|
||||||
#~('#$schedule)))
|
|
||||||
#$(ganeti-watcher-command config)
|
|
||||||
"ganeti-watcher")))))
|
|
||||||
|
|
||||||
(define ganeti-watcher-service-type
|
(define ganeti-watcher-service-type
|
||||||
(service-type (name 'ganeti-watcher)
|
(service-type (name 'ganeti-watcher)
|
||||||
(extensions
|
(extensions
|
||||||
(list (service-extension mcron-service-type
|
(list (service-extension shepherd-root-service-type
|
||||||
ganeti-watcher-jobs)))
|
ganeti-watcher-service)))
|
||||||
(default-value (ganeti-watcher-configuration))
|
(default-value (ganeti-watcher-configuration))
|
||||||
(description
|
(description
|
||||||
"@command{ganeti-watcher} is a periodically run script that
|
"@command{ganeti-watcher} is a periodically run script that
|
||||||
@@ -714,34 +722,23 @@ is declared offline by known master candidates.")))
|
|||||||
;; Run the node cleaner at 02:45 every day.
|
;; Run the node cleaner at 02:45 every day.
|
||||||
(default "45 2 * * *")))
|
(default "45 2 * * *")))
|
||||||
|
|
||||||
(define ganeti-cleaner-jobs
|
(define ganeti-cleaner-service
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <ganeti-cleaner-configuration> ganeti master-schedule node-schedule)
|
(($ <ganeti-cleaner-configuration> ganeti master-schedule node-schedule)
|
||||||
(list
|
(list (ganeti-timer 'ganeti-master-cleaner
|
||||||
#~(job #$@(match master-schedule
|
master-schedule
|
||||||
((? string?)
|
#~(#$(file-append ganeti "/sbin/ganeti-cleaner")
|
||||||
#~(#$master-schedule))
|
"master"))
|
||||||
((? list?)
|
(ganeti-timer 'ganeti-node-cleaner
|
||||||
#~('#$master-schedule)))
|
node-schedule
|
||||||
(lambda ()
|
#~(#$(file-append ganeti "/sbin/ganeti-cleaner")
|
||||||
(system* #$(file-append ganeti "/sbin/ganeti-cleaner")
|
"node"))))))
|
||||||
"master"))
|
|
||||||
"ganeti master cleaner")
|
|
||||||
#~(job #$@(match node-schedule
|
|
||||||
((? string?)
|
|
||||||
#~(#$node-schedule))
|
|
||||||
((? list?)
|
|
||||||
#~('#$node-schedule)))
|
|
||||||
(lambda ()
|
|
||||||
(system* #$(file-append ganeti "/sbin/ganeti-cleaner")
|
|
||||||
"node"))
|
|
||||||
"ganeti node cleaner")))))
|
|
||||||
|
|
||||||
(define ganeti-cleaner-service-type
|
(define ganeti-cleaner-service-type
|
||||||
(service-type (name 'ganeti-cleaner)
|
(service-type (name 'ganeti-cleaner)
|
||||||
(extensions
|
(extensions
|
||||||
(list (service-extension mcron-service-type
|
(list (service-extension shepherd-root-service-type
|
||||||
ganeti-cleaner-jobs)))
|
ganeti-cleaner-service)))
|
||||||
(default-value (ganeti-cleaner-configuration))
|
(default-value (ganeti-cleaner-configuration))
|
||||||
(description
|
(description
|
||||||
"@command{ganeti-cleaner} is a script that removes old files
|
"@command{ganeti-cleaner} is a script that removes old files
|
||||||
@@ -804,7 +801,8 @@ than 21 days from @file{/var/lib/ganeti/queue/archive}.")))
|
|||||||
|
|
||||||
(define ganeti-shepherd-services
|
(define ganeti-shepherd-services
|
||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <ganeti-configuration> _ noded confd wconfd luxid rapi kvmd mond metad)
|
(($ <ganeti-configuration> _ noded confd wconfd luxid rapi kvmd mond metad
|
||||||
|
watcher cleaner)
|
||||||
(append (ganeti-noded-service noded)
|
(append (ganeti-noded-service noded)
|
||||||
(ganeti-confd-service confd)
|
(ganeti-confd-service confd)
|
||||||
(ganeti-wconfd-service wconfd)
|
(ganeti-wconfd-service wconfd)
|
||||||
@@ -812,13 +810,9 @@ than 21 days from @file{/var/lib/ganeti/queue/archive}.")))
|
|||||||
(ganeti-rapi-service rapi)
|
(ganeti-rapi-service rapi)
|
||||||
(ganeti-kvmd-service kvmd)
|
(ganeti-kvmd-service kvmd)
|
||||||
(ganeti-mond-service mond)
|
(ganeti-mond-service mond)
|
||||||
(ganeti-metad-service metad)))))
|
(ganeti-metad-service metad)
|
||||||
|
(ganeti-watcher-service watcher)
|
||||||
(define ganeti-mcron-jobs
|
(ganeti-cleaner-service cleaner)))))
|
||||||
(match-lambda
|
|
||||||
(($ <ganeti-configuration> _ _ _ _ _ _ _ _ _ watcher cleaner)
|
|
||||||
(append (ganeti-watcher-jobs watcher)
|
|
||||||
(ganeti-cleaner-jobs cleaner)))))
|
|
||||||
|
|
||||||
(define-record-type* <ganeti-os>
|
(define-record-type* <ganeti-os>
|
||||||
ganeti-os make-ganeti-os ganeti-os?
|
ganeti-os make-ganeti-os ganeti-os?
|
||||||
@@ -1122,9 +1116,7 @@ in /etc/ganeti/instance-$os for OS."
|
|||||||
(service-extension etc-service-type
|
(service-extension etc-service-type
|
||||||
ganeti-etc-service)
|
ganeti-etc-service)
|
||||||
(service-extension profile-service-type
|
(service-extension profile-service-type
|
||||||
(compose list ganeti-configuration-ganeti))
|
(compose list ganeti-configuration-ganeti))))
|
||||||
(service-extension mcron-service-type
|
|
||||||
ganeti-mcron-jobs)))
|
|
||||||
(default-value (ganeti-configuration (os %default-ganeti-os)))
|
(default-value (ganeti-configuration (os %default-ganeti-os)))
|
||||||
(description
|
(description
|
||||||
"Ganeti is a family of services that are designed to run
|
"Ganeti is a family of services that are designed to run
|
||||||
|
|||||||
Reference in New Issue
Block a user