aboutsummaryrefslogtreecommitdiff
path: root/gn/services
diff options
context:
space:
mode:
authorEfraim Flashner2020-12-07 11:37:24 +0200
committerEfraim Flashner2020-12-07 12:56:22 +0200
commit54c43ad0cdde59887d7e42dc09bd2d05a4a7de2d (patch)
tree3c15b866bfbc54483e202eebe7af035ee2399b60 /gn/services
parentac6999acd5f15a5037f9a9ab55b6ab4e373c1877 (diff)
downloadguix-bioinformatics-54c43ad0cdde59887d7e42dc09bd2d05a4a7de2d.tar.gz
gn: modularize slurm service
Diffstat (limited to 'gn/services')
-rw-r--r--gn/services/science.scm136
1 files changed, 110 insertions, 26 deletions
diff --git a/gn/services/science.scm b/gn/services/science.scm
index f0f43d0..1a25382 100644
--- a/gn/services/science.scm
+++ b/gn/services/science.scm
@@ -170,32 +170,113 @@
;; that machine. Therefore it makes sense to have one config section with
;; "common" and "extended" options. With all the possible options and
;; versions we only cover the ones which affect the services.
+ ;; We keep the capitalization used in the config files to make discovery easier.
(package slurm-configuration-package
(default slurm))
(slurm-conf-file slurm-configuration-slurm-conf-file
(default "/etc/slurm/slurm.conf"))
- (slurmd-log-file slurm-configuration-slurmd-log-file
+ (SlurmdLogFile slurm-configuration-slurmd-log-file
(default #f)) ; #f for syslog
- (slurmd-pid-file slurm-configuration-slurmd-pid-file
+ (SlurmdPidFile slurm-configuration-slurmd-pidfile
(default "/var/run/slurmd.pid"))
- (slurmd-spooldir slurm-configuration-slurmd-spooldir
+ (SlurmdSpoolDir slurm-configuration-slurmd-spooldir
(default "/var/spool/slurmd"))
(run-slurmctld? slurm-configuration-run-slurmctld
(default #f))
- (slurmctld-log-file slurm-configuration-slurmctld-log-file
+ (SlurmctldLogFile slurm-configuration-slurmctld-log-file
(default #f)) ; #f for syslog
- (slurmctld-pid-file slurm-configuration-slurmctld-pid-file
+ (SlurmctldPidFile slurm-configuration-slurmctld-pidfile
(default "/var/run/slurmctld.pid"))
(run-slurmdbd? slurm-configuration-run-slurmdbd
(default #f))
(slurmdbd-conf-file slurm-configuration-slurmdbd-conf-file
(default "/etc/slurm/slurmdbd.conf"))
- (slurmdbd-pid-file slurm-configuration-slurmdbd-pid-file
- (default "/var/run/slurmdbd.pid")))
+ (slurmdbd-PidFile slurm-configuration-slurmdbd-pidfile
+ (default "/var/run/slurmdbd.pid"))
+ (ClusterName slurm-configuration-clustername
+ (default #f)) ; string
+ (SlurmUser slurm-configuration-slurmuser
+ (default #f)) ; string
+ (SlurmctldHost slurm-configuration-slurmctldhost
+ (default #f)) ; list of strings
+ (slurm-extra-content slurm-configuration-slurm-extra-content
+ (default ""))
+ (cgroup-extra-content slurm-configuration-cgroup-extra-content
+ (default ""))
+ (DbdHost slurm-configuration-dbdhost
+ (default #f)) ; string
+ (StorageType slurm-configuration-storagetype
+ (default #f)) ; string
+ (slurmdbd-extra-content slurm-configuration-slurmdbd-extra-content
+ (default "")))
+
+
+(define (%slurm.conf config)
+ "Return a slurm.conf configuration file corresponding to CONFIG."
+ (computed-file
+ "slurm_conf"
+ #~(begin
+ (use-modules (srfi srfi-26))
+ (call-with-output-file #$output
+ (lambda (port)
+ (display "# Generated by 'slurm-service'.\n" port)
+ (format port "ClusterName=~a\n"
+ #$(slurm-configuration-clustername config))
+ (for-each
+ (cut format port "SlurmCtldHost=~a\n" <>)
+ '#$(slurm-configuration-slurmctldhost config))
+ (format port "SlurmdSpoolDir=~a\n"
+ #$(slurm-configuration-slurmd-spooldir config))
+ (format port "SlurmdPidFile=~a\n"
+ #$(slurm-configuration-slurmd-pidfile config))
+ (if #$(slurm-configuration-slurmd-log-file config)
+ (format port "SlurmdLogFile=~a\n"
+ #$(slurm-configuration-slurmd-log-file config)))
+ (format port "SlurmctldPidFile=~a\n"
+ #$(slurm-configuration-slurmctld-pidfile config))
+ (if #$(slurm-configuration-slurmctld-log-file config)
+ (format port "SlurmctldLogFile=~a\n"
+ #$(slurm-configuration-slurmctld-log-file config)))
+ (format port "SlurmUser=~a\n"
+ #$(slurm-configuration-slurmuser config))
+ (format port "\n# Extra content here:\n~a\n"
+ #$(slurm-configuration-slurm-extra-content config))
+ #t)))))
+
+(define (%cgroup.conf config)
+ "Return a cgroup.conf configuration file corresponding to CONFIG."
+ (computed-file
+ "cgroup_conf"
+ #~(begin
+ (call-with-output-file #$output
+ (lambda (port)
+ (display "# Generated by 'slurm-service'.\n" port)
+ (format port "~a\n"
+ #$(slurm-configuration-cgroup-extra-content config)))))))
+
+(define (%slurmdbd.conf config)
+ "Return a slurm.conf configuration file corresponding to CONFIG."
+ (computed-file
+ "slurmdbd_conf"
+ #~(begin
+ (call-with-output-file #$output
+ (lambda (port)
+ (display "# Generated by 'slurm-service'.\n" port)
+ (format port "DbdHost=~a\n"
+ #$(slurm-configuration-dbdhost config))
+ (format port "StorageType=~a\n"
+ #$(slurm-configuration-storagetype config))
+ (format port "SlurmUser=~a\n"
+ #$(slurm-configuration-slurmuser config))
+ (format port "PidFile=~a\n"
+ #$(slurm-configuration-slurmdbd-pidfile config))
+ (format port "\n# Extra content here:\n~a\n"
+ #$(slurm-configuration-slurmdbd-extra-content config))
+ #t)))))
(define (slurm-activation config)
"Return the activation GEXP for CONFIG for the slurm service."
@@ -207,7 +288,7 @@
(logdir (dirname (or #$(slurm-configuration-slurmd-log-file config)
#$(slurm-configuration-slurmctld-log-file config)
"/var/log/slurmd.log")))
- (piddir (dirname #$(slurm-configuration-slurmd-pid-file config))))
+ (piddir (dirname #$(slurm-configuration-slurmd-pidfile config))))
(unless (file-exists? spooldir)
(mkdir-p spooldir))
(chown spooldir (passwd:uid %user) (passwd:gid %user))
@@ -219,11 +300,15 @@
(unless (file-exists? piddir)
(mkdir-p piddir)))
;; /etc/slurm/slurm.conf needs to exist.
- (file-exists? #$(slurm-configuration-slurm-conf-file config)))))
+ (file-exists? #$(slurm-configuration-slurm-conf-file config))
+ ;; slurmdbd activation
+ (when #$(slurm-configuration-run-slurmdbd config)
+ (file-exists?
+ #$(slurm-configuration-slurmdbd-conf-file config))))))
(define slurmd-shepherd-service
(match-lambda
- (($ <slurm-configuration> package slurm-conf-file slurmd-log-file slurmd-pid-file)
+ (($ <slurm-configuration> package slurm-conf-file _ slurmd-pidfile)
(list
(shepherd-service
(documentation "Slurmd server")
@@ -231,14 +316,13 @@
(requirement '(loopback munge))
(start #~(make-forkexec-constructor
(list #$(file-append package "/sbin/slurmd")
- ;"-L" #$slurmd-log-file
"-f" #$slurm-conf-file)
- #:pid-file #$slurmd-pid-file))
+ #:pid-file #$slurmd-pidfile))
(stop #~(make-kill-destructor)))))))
(define slurmctld-shepherd-service
(match-lambda
- (($ <slurm-configuration> package slurm-conf-file _ _ _ run-slurmctld? slurmctld-log-file slurmctld-pid-file)
+ (($ <slurm-configuration> package slurm-conf-file _ _ _ run-slurmctld? _ slurmctld-pidfile)
(list
(shepherd-service
(documentation "Slurmctld server")
@@ -246,22 +330,14 @@
(requirement '(loopback munge))
(start #~(make-forkexec-constructor
(list #$(file-append package "/sbin/slurmctld")
- ;"-L" #$slurmctld-log-file
"-f" #$slurm-conf-file)
- #:pid-file #$slurmctld-pid-file))
+ #:pid-file #$slurmctld-pidfile))
(stop #~(make-kill-destructor))
(auto-start? run-slurmctld?))))))
-(define (slurmdbd-activation config)
- "Test the Slurmdbd configration exists."
- (when (slurm-configuration-run-slurmdbd config)
- (file-exists?
- (slurm-configuration-slurmdbd-conf-file config)))
- #t)
-
(define slurmdbd-shepherd-service
(match-lambda
- (($ <slurm-configuration> package _ _ _ _ _ _ _ run-slurmdbd? slurmdbd-conf-file slurmdbd-pid-file)
+ (($ <slurm-configuration> package _ _ _ _ _ _ _ run-slurmdbd? _ slurmdbd-pidfile)
(list
(shepherd-service
(documentation "Slurmdbd server")
@@ -269,7 +345,7 @@
(requirement '(loopback munge))
(start #~(make-forkexec-constructor
(list #$(file-append package "/sbin/slurmdbd"))
- #:pid-file #$slurmdbd-pid-file))
+ #:pid-file #$slurmdbd-pidfile))
(stop #~(make-kill-destructor))
(auto-start? run-slurmdbd?))))))
@@ -282,6 +358,14 @@
(slurmdbd-shepherd-service config)
'())))
+(define (slurm-etc-service config)
+ (append
+ `(("slurm/slurm.conf" ,(%slurm.conf config))
+ ("slurm/cgroup.conf" ,(%cgroup.conf config)))
+ (if (slurm-configuration-run-slurmdbd config)
+ `(("slurm/slurmdbd.conf" ,(%slurmdbd.conf config)))
+ '())))
+
(define slurm-service-type
(service-type
(name 'slurm)
@@ -291,8 +375,8 @@
slurm-services-to-run)
(service-extension activation-service-type
slurm-activation)
- (service-extension activation-service-type
- slurmdbd-activation)
+ (service-extension etc-service-type
+ slurm-etc-service)
(service-extension account-service-type
(const %slurm-accounts))
(service-extension profile-service-type