longrun for continuous processes and oneshot for tasks that execute and terminate.
This guide is for cluster administrators who need to automate custom scripts on Compute and Login nodes within a SUNK cluster. Whether you install packages or keep services running, this method provides a straightforward way to manage processes.
Define scripts in values.yaml
Define scripts in the appropriate sections of the Slurm chart’s values.yaml file. Define Compute node scripts in the compute.s6 section, and Login node scripts in the login.s6 section. Each script needs a name, type, and the script itself. The following example shows a script definition within a Compute node:
packages: Thisoneshotscript installsnginxusing the package manager.nginx: Alongrunscript that starts thenginxprocess and keeps it running.
nginx script is assigned a timeoutUp of 30000 milliseconds, which means it has up to 30 seconds to start successfully.
Define and schedule different script types
The following sections explain how to choose the right script type for your task and how to avoid scheduling conflicts that can occur when scripts extend node startup time.Determine the appropriate script type
Decide whether the script is alongrun or a oneshot based on its purpose:
- Use
longrunfor scripts that should run continuously, like a web server. - Use
oneshotfor scripts that run once to perform a setup task, like installing software.
Avoid scheduling conflicts
If youroneshot job installs many packages or performs tasks that otherwise extend startup time, you must account for this by modifying the value of the orphanedPodDelay parameter in the syncer configuration section of the Slurm values.yaml chart.
The full path for this parameter is syncer.config.syncer.orphanedPodDelay. By default, the value of orphanedPodDelay is 120s, or 120 seconds.
If the time required for a oneshot job to run exceeds the value set in orphanedPodDelay, increase the value to avoid scheduling conflicts.
Set timeouts for scripts
Timeouts prevent scripts from hanging indefinitely and help keep nodes healthy. For finer control, you can set timeouts for your scripts. ThetimeoutUp parameter sets the time allowed for the script to start, and timeoutDown sets the time allowed for it to stop. These parameters are optional and set in milliseconds. By default, they’re set to 0, which means the script doesn’t time out.
- For
oneshotscripts, onlytimeoutUpis relevant as it’s the maximum completion time for the script. - For
longrunscripts, bothtimeoutUpandtimeoutDowncontrol how long the process has to start and stop.
Define behavior for failed scripts
When a user-defined script fails, the container can continue running silently, provide an error message, or stop. In SUNK, containers stop on script failure by default. You can control this behavior with theS6_BEHAVIOUR_IF_STAGE2_FAILS parameter in the appropriate env section of the values.yaml file.
- For Login nodes, change the value of the parameter in the
login.envsection of thevalues.yamlfile. - For Compute nodes, change the value of the parameter in the
compute.nodes.[TARGET-NODE].envsections of thevalues.yamlfile.
S6_BEHAVIOUR_IF_STAGE2_FAILS parameter can contain the following values:
For more information about the values for
S6_BEHAVIOUR_IF_STAGE2_FAILS, see the s6-overlay customization options.