diff --git a/doc/html/man_index.shtml b/doc/html/man_index.shtml index 852dcfd4ac71331f24dfd423ee3b052a6df5b915..16fba5e3e18cd2a11db56ee260b9649d6e4dc076 100644 --- a/doc/html/man_index.shtml +++ b/doc/html/man_index.shtml @@ -39,6 +39,7 @@ Documentation for other versions of Slurm is distributed with the code</b></p> <tr><td><a href="job_container.conf.html">job_container.conf</a></td><td>Slurm configuration file for configuring the tmpfs job container plugin</td></tr> <tr><td><a href="knl.conf.html">knl.conf</a></td><td>Slurm configuration file for Intel Knights Landing management.</td></tr> <tr><td><a href="nonstop.conf.html">nonstop.conf</a></td><td>Slurm configuration file for failure management.</td></tr> +<tr><td><a href="oci.conf.html">oci.conf</a></td><td>Slurm configuration file for OCI Containers.</td></tr> <tr><td><a href="slurm.conf.html">slurm.conf</a></td><td>Slurm configuration file</td></tr> <tr><td><a href="slurmdbd.conf.html">slurmdbd.conf</a></td><td>Slurm Database Daemon (SlurmDBD) configuration file</td></tr> <tr><td><a href="topology.conf.html">topology.conf</a></td><td>Slurm configuration file for defining the network topology</td></tr> diff --git a/doc/man/man5/Makefile.am b/doc/man/man5/Makefile.am index d16e93e2a1563025d18d34a80e5625d7c2282c56..68372aee28d51d5ac407b7cdb0b32778869666e2 100644 --- a/doc/man/man5/Makefile.am +++ b/doc/man/man5/Makefile.am @@ -9,6 +9,7 @@ man5_MANS = \ job_container.conf.5 \ knl.conf.5 \ nonstop.conf.5 \ + oci.conf.5 \ slurm.conf.5 \ slurmdbd.conf.5 \ topology.conf.5 diff --git a/doc/man/man5/Makefile.in b/doc/man/man5/Makefile.in index 18e3a5e7837ea5485f296223b4ba60e647eb8088..a001047389de1aebc52aa5ea03354fe65982a800 100644 --- a/doc/man/man5/Makefile.in +++ b/doc/man/man5/Makefile.in @@ -457,6 +457,7 @@ man5_MANS = \ job_container.conf.5 \ knl.conf.5 \ nonstop.conf.5 \ + oci.conf.5 \ slurm.conf.5 \ slurmdbd.conf.5 \ topology.conf.5 diff --git a/doc/man/man5/oci.conf.5 b/doc/man/man5/oci.conf.5 new file mode 100644 index 0000000000000000000000000000000000000000..ae9dedbfcd8dd1c7dca5d306ba205dd11be08b50 --- /dev/null +++ b/doc/man/man5/oci.conf.5 @@ -0,0 +1,118 @@ +.TH "oci.conf" "5" "Slurm Configuration File" "July 2021" "Slurm Configuration File" + +.SH "NAME" +oci.conf \- Slurm configuration file for containers. + +.SH "DESCRIPTION" +Slurm supports calling OCI compliant runtimes. \fBoci.conf\fP is an ASCII +file which defines parameters used by OCI runtime interface. + +.LP +Parameter names are case insensitive. +Any text following a "#" in the configuration file is treated +as a comment through the end of that line. +Changes to the configuration file take effect upon restart of Slurm daemons. + +.LP +The following oci.conf parameters are defined to control the behavior +of the \fB--container\fR argument of \fBsalloc\fR, \fBsrun\fR, and \fBsbatch\fR + +.TP +\fBContainerPath\fR +Override path pattern for placement of the generated OCI Container bundle +directory. See the section \fBOCI Pattern\fR for details on pattern +replacement. +.sp +Default is unique directory generated in \fBSlurmdSpoolDir\fR. + +.TP +\fBRunTimeCreate\fR +Pattern for OCI runtime create operation. See the section \fBOCI Pattern\fR +for details on pattern replacement. +.sp +Default: (disabled) + +.TP +\fBRunTimeDelete\fR +Pattern for OCI runtime delete operation. See the section \fBOCI Pattern\fR +for details on pattern replacement. +.sp +Default: (disabled) + +.TP +\fBRunTimeKill\fR +Pattern for OCI runtime kill operation. See the section \fBOCI Pattern\fR +for details on pattern replacement. +.sp +Default: (disabled) + +.TP +\fBRunTimeQuery\fR +Pattern for OCI runtime query operation (also known as state). See the section +\fBOCI Pattern\fR for details on pattern replacement. +.sp +Default: (disabled) + +.TP +\fBOCIRunTimeRun\fR +Pattern for OCI runtime run operation. This is not provided in the OCI runtime +specification (<=v1.0) but is provided by multiple OCI runtimes to simplify +execution of containers. If provided, it will be used in the place of create +and start operations. It avoids the need to poll state of the container +resulting in less monitoring overhead. See the section \fBOCI Pattern\fR for +details on pattern replacement. +.sp +Default: (disabled) + +.TP +\fBRunTimeStart\fR +Pattern for OCI runtime statrt operation. See the section \fBOCI Pattern\fR +for details on pattern replacement. +.sp +Default: (disabled) + +.SH "NOTES" +.LP +OCI container support is disabled if oci.conf does not exist. If disabled, any +user passing \fB--container\fR will be doing so in a purely advisor manner. + +.SH "OCI Pattern" + +All of the OCI patterns will replace the following characters: +.sp +replacements: +.IP \(bu 10 +%% - replace as "%" +.IP \(bu +%b - replace as OCI Bundle Path +.IP \(bu +%j - replace as numeric job id +.IP \(bu +%n - replace as nodename +.IP \(bu +%s - replace as numeric step id +.IP \(bu +%t - replace as numeric step task id +.IP \(bu +%u - replace as user name + +.SH "COPYING" +Copyright (C) 2021 SchedMD LLC. + +.LP +This file is part of Slurm, a resource management program. +For details, see <https://slurm.schedmd.com/>. +.LP +Slurm is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your option) +any later version. +.LP +Slurm is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +.SH "SEE ALSO" +.LP +\fBslurm.conf\fR(5) diff --git a/src/slurmd/slurmstepd/Makefile.am b/src/slurmd/slurmstepd/Makefile.am index 143a04aee4f03501852ad37e3ab4fb0cdd0f4dd9..b598481ae813ecaa6492ef5785827cb7e6f66c53 100644 --- a/src/slurmd/slurmstepd/Makefile.am +++ b/src/slurmd/slurmstepd/Makefile.am @@ -34,6 +34,7 @@ slurmstepd_SOURCES = \ pdebug.c pdebug.h \ pam_ses.c pam_ses.h \ setproctitle.c setproctitle.h \ + read_oci_conf.h read_oci_conf.c \ req.c req.h \ multi_prog.c multi_prog.h \ step_terminate_monitor.c step_terminate_monitor.h \ diff --git a/src/slurmd/slurmstepd/Makefile.in b/src/slurmd/slurmstepd/Makefile.in index 434320233fa10e0fb5e870850ff2bf635ca0bf77..8ecb340375eb4a9677f8a87665e06ba84da04d02 100644 --- a/src/slurmd/slurmstepd/Makefile.in +++ b/src/slurmd/slurmstepd/Makefile.in @@ -153,9 +153,9 @@ PROGRAMS = $(sbin_PROGRAMS) am_slurmstepd_OBJECTS = container.$(OBJEXT) slurmstepd.$(OBJEXT) \ mgr.$(OBJEXT) task.$(OBJEXT) slurmstepd_job.$(OBJEXT) \ io.$(OBJEXT) ulimits.$(OBJEXT) pdebug.$(OBJEXT) \ - pam_ses.$(OBJEXT) setproctitle.$(OBJEXT) req.$(OBJEXT) \ - multi_prog.$(OBJEXT) step_terminate_monitor.$(OBJEXT) \ - x11_forwarding.$(OBJEXT) + pam_ses.$(OBJEXT) setproctitle.$(OBJEXT) \ + read_oci_conf.$(OBJEXT) req.$(OBJEXT) multi_prog.$(OBJEXT) \ + step_terminate_monitor.$(OBJEXT) x11_forwarding.$(OBJEXT) slurmstepd_OBJECTS = $(am_slurmstepd_OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -185,8 +185,9 @@ am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/container.Po ./$(DEPDIR)/io.Po \ ./$(DEPDIR)/mgr.Po ./$(DEPDIR)/multi_prog.Po \ ./$(DEPDIR)/pam_ses.Po ./$(DEPDIR)/pdebug.Po \ - ./$(DEPDIR)/req.Po ./$(DEPDIR)/setproctitle.Po \ - ./$(DEPDIR)/slurmstepd.Po ./$(DEPDIR)/slurmstepd_job.Po \ + ./$(DEPDIR)/read_oci_conf.Po ./$(DEPDIR)/req.Po \ + ./$(DEPDIR)/setproctitle.Po ./$(DEPDIR)/slurmstepd.Po \ + ./$(DEPDIR)/slurmstepd_job.Po \ ./$(DEPDIR)/step_terminate_monitor.Po ./$(DEPDIR)/task.Po \ ./$(DEPDIR)/ulimits.Po ./$(DEPDIR)/x11_forwarding.Po am__mv = mv -f @@ -512,6 +513,7 @@ slurmstepd_SOURCES = \ pdebug.c pdebug.h \ pam_ses.c pam_ses.h \ setproctitle.c setproctitle.h \ + read_oci_conf.h read_oci_conf.c \ req.c req.h \ multi_prog.c multi_prog.h \ step_terminate_monitor.c step_terminate_monitor.h \ @@ -617,6 +619,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_prog.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_ses.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdebug.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_oci_conf.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/req.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setproctitle.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slurmstepd.Po@am__quote@ # am--include-marker @@ -759,6 +762,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/multi_prog.Po -rm -f ./$(DEPDIR)/pam_ses.Po -rm -f ./$(DEPDIR)/pdebug.Po + -rm -f ./$(DEPDIR)/read_oci_conf.Po -rm -f ./$(DEPDIR)/req.Po -rm -f ./$(DEPDIR)/setproctitle.Po -rm -f ./$(DEPDIR)/slurmstepd.Po @@ -818,6 +822,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/multi_prog.Po -rm -f ./$(DEPDIR)/pam_ses.Po -rm -f ./$(DEPDIR)/pdebug.Po + -rm -f ./$(DEPDIR)/read_oci_conf.Po -rm -f ./$(DEPDIR)/req.Po -rm -f ./$(DEPDIR)/setproctitle.Po -rm -f ./$(DEPDIR)/slurmstepd.Po diff --git a/src/slurmd/slurmstepd/read_oci_conf.c b/src/slurmd/slurmstepd/read_oci_conf.c new file mode 100644 index 0000000000000000000000000000000000000000..76665b82d0e06df2670a125618c4c49825db11ac --- /dev/null +++ b/src/slurmd/slurmstepd/read_oci_conf.c @@ -0,0 +1,136 @@ +/*****************************************************************************\ + * read_oci_conf.c - parse oci.conf configuration file. + ***************************************************************************** + * Copyright (C) 2021 SchedMD LLC. + * Written by Nathan Rini <nate@schedmd.com> + * All rights reserved. + * + * This file is part of Slurm, a resource management program. + * For details, see <https://slurm.schedmd.com/>. + * Please also read the included file: DISCLAIMER. + * + * SLURM is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with SLURM; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#include <sys/stat.h> +#include <unistd.h> + +#include "slurm/slurm_errno.h" + +#include "src/common/log.h" +#include "src/common/parse_config.h" +#include "src/common/read_config.h" +#include "src/common/xmalloc.h" +#include "src/common/xstring.h" + +#include "read_oci_conf.h" + +#define OCI_CONF "oci.conf" + +static s_p_options_t options[] = { + {"ContainerPath", S_P_STRING}, + {"RunTimeCreate", S_P_STRING}, + {"RunTimeDelete", S_P_STRING}, + {"RunTimeKill", S_P_STRING}, + {"RunTimeQuery", S_P_STRING}, + {"RunTimeRun", S_P_STRING}, + {"RunTimeStart", S_P_STRING}, + {NULL} +}; + +extern int get_oci_conf(oci_conf_t **oci_ptr) +{ + s_p_hashtbl_t *tbl = NULL; + struct stat buf; + int rc = SLURM_SUCCESS; + oci_conf_t *oci = NULL; + char *conf_path = get_extra_conf_path(OCI_CONF); + + if ((stat(conf_path, &buf) == -1)) { + error("No %s file", OCI_CONF); + xfree(conf_path); + return ENOENT; + } + + oci = xmalloc(sizeof(*oci)); + + debug("Reading %s file %s", OCI_CONF, conf_path); + tbl = s_p_hashtbl_create(options); + if (s_p_parse_file(tbl, NULL, conf_path, false) == SLURM_ERROR) + fatal("Could not parse %s file: %s", OCI_CONF, conf_path); + + (void) s_p_get_string(&oci->container_path, "ContainerPath", tbl); + (void) s_p_get_string(&oci->runtime_create, "RunTimeCreate", tbl); + (void) s_p_get_string(&oci->runtime_delete, "RunTimeDelete", tbl); + (void) s_p_get_string(&oci->runtime_kill, "RunTimeKill", tbl); + (void) s_p_get_string(&oci->runtime_query, "RunTimeQuery", tbl); + (void) s_p_get_string(&oci->runtime_run, "RunTimeRun", tbl); + (void) s_p_get_string(&oci->runtime_start, "RunTimeStart", tbl); + + if (!oci->runtime_create && !oci->runtime_delete && + !oci->runtime_kill && !oci->runtime_query && + !oci->runtime_run && !oci->runtime_start) { + debug("OCI container disabled"); + } else if (oci->runtime_create && oci->runtime_delete && + oci->runtime_kill && oci->runtime_query && + !oci->runtime_run && oci->runtime_start) { + debug("OCI container activated with create/start"); + } else if (!oci->runtime_create && oci->runtime_delete && + oci->runtime_kill && oci->runtime_query && + oci->runtime_run && !oci->runtime_start) { + debug("OCI container activated with run"); + } else { + error("RunTimeRun and RunCreate/RunTimeStart are mutually exclusive. All other RunTime* configurations items must be populated."); + rc = SLURM_ERROR; + } + + s_p_hashtbl_destroy(tbl); + xfree(conf_path); + + if (!rc) { + free_oci_conf(*oci_ptr); + *oci_ptr = oci; + } else { + free_oci_conf(oci); + } + + return rc; +} + +extern void free_oci_conf(oci_conf_t *oci) +{ + if (!oci) + return; + + xfree(oci->container_path); + xfree(oci->runtime_create); + xfree(oci->runtime_delete); + xfree(oci->runtime_kill); + xfree(oci->runtime_query); + xfree(oci->runtime_run); + xfree(oci->runtime_start); + xfree(oci); +} diff --git a/src/slurmd/slurmstepd/read_oci_conf.h b/src/slurmd/slurmstepd/read_oci_conf.h new file mode 100644 index 0000000000000000000000000000000000000000..b2331c1ce108e3da33b63ec6789be5a5b340c247 --- /dev/null +++ b/src/slurmd/slurmstepd/read_oci_conf.h @@ -0,0 +1,62 @@ +/*****************************************************************************\ + * read_oci_conf.c - parse oci.conf configuration file. + ***************************************************************************** + * Copyright (C) 2021 SchedMD LLC. + * Written by Nathan Rini <nate@schedmd.com> + * All rights reserved. + * + * This file is part of Slurm, a resource management program. + * For details, see <https://slurm.schedmd.com/>. + * Please also read the included file: DISCLAIMER. + * + * SLURM is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with SLURM; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#ifndef _READ_OCI_CONF_H +#define _READ_OCI_CONF_H + +typedef struct { + char *container_path; /* path pattern to use for holding OCI container config */ + char *runtime_create; /* OCI runtime pattern to execute query for containers */ + char *runtime_delete; /* OCI runtime pattern to execute query for containers */ + char *runtime_kill; /* OCI runtime pattern to execute query for containers */ + char *runtime_query; /* OCI runtime pattern to execute query for containers */ + char *runtime_run; /* OCI runtime pattern to execute query for containers */ + char *runtime_start; /* OCI runtime pattern to execute query for containers */ +} oci_conf_t; + +extern int get_oci_conf(oci_conf_t **oci); + +extern void free_oci_conf(oci_conf_t *oci); + +#define FREE_NULL_OCI_CONF(_X) \ + do { \ + if (_X) \ + free_oci_conf(_X); \ + _X = NULL; \ + } while (0) + +#endif /*_READ_OCI_CONF_H */