Slurm Scheduler Plugin API

Overview

This document describe. Slurm scheduler plugins and the API that defines them. It is intended as a resource to programmers wishing to write their own Slurm scheduler plugins.

It is noteworthy that two different models are used for job scheduling. The backfill scheduler let. Slurm establishes the initial job priority and can periodically alter job priorities to change their order within the queue. Developers may use the model that best fits their needs. Note that a separate node selection plugin is available for controlling that aspect of scheduling.

Slurm scheduler plugins are Slurm plugins that implement the Slurm scheduler API described herein. They must conform to the Slurm Plugin API with the following specifications:

const char plugin_type[]
The major type must be "sched." The minor type can be any recognizable abbreviation for the type of scheduler. We recommend, for example:

  • builtin — A plugin that implements the API without providing any actual scheduling services. This is the default behavior and implements first-in-first-out scheduling.
  • backfill — Raise the priority of jobs if doing so results in their starting earlier without any delay in the expected initiation time of any higher priority job.

const char plugin_name[]
Some descriptive name for the plugin. There is no requirement with respect to its format.

const uint32_t plugin_version
If specified, identifies the version of Slurm used to build this plugin and any attempt to load the plugin from a different version of Slurm will result in an error. If not specified, then the plugin may be loaded by Slurm commands and daemons from any version, however this may result in difficult to diagnose failures due to changes in the arguments to plugin functions or changes in other Slurm functions used by the plugin.

API Functions

The following functions must appear. Functions which are not implemented should be stubbed.

int init (void)

Description:
Called when the plugin is loaded, before any other functions are called. Put global initialization here.

Returns:
SLURM_SUCCESS on success, or
SLURM_ERROR on failure.

void fini (void)

Description:
Called when the plugin is removed. Clear any allocated storage here.

Returns: None.

Note: These init and fini functions are not the same as those described in the dlopen (3) system library. The C run-time system co-opts those symbols for its own initialization. The system _init() is called before the Slurm init(), and the Slurm fini() is called before the system's _fini().

int slurm_sched_p_reconfig (void);

Description: Reread any configuration files.

Arguments: None

Returns: SLURM_SUCCESS if successful. On fail ure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

int slurm_sched_p_schedule (void);

Description: For passive schedulers, invoke a scheduling pass.

Arguments: None

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

int slurm_sched_p_newalloc(job_record_t *job_ptr);

Description: Note the successful allocation of resources to a job.

Arguments: Pointer to the slurmctld job structure. This can be used to get partition, allocated resources, time limit, etc.

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

int slurm_sched_p_freealloc(job_record_t *job_ptr);

Description: Note the successful release of resources for a job.

Arguments: Pointer to the slurmctld job structure. This can be used to get partition, allocated resources, time limit, etc.

Returns: SLURM_SUCCESS if successful. On failure, the plugin should return SLURM_ERROR and set the errno to an appropriate value to indicate the reason for failure.

uint32_t slurm_sched_p_initial_priority(uint32_t last_prio, job_record_t *job_ptr);

Description: Establish the initial priority of a new job.

Arguments:
last_prio (input) default priority of the previously submitted job. This can be used to provide First-In-First-Out scheduling by assigning the new job a priority lower than this value. This could also be used to establish an initial priority of zero for all jobs, representing a "held" state. The scheduler plugin can then decide where and when to initiate pending jobs by altering their priority and (optionally) list of required nodes.
job_ptr (input) Pointer to the slurmctld job structure. This can be used to get partition, resource requirements, time limit, etc.

Returns: The priority to be assigned to this job.

void slurm_sched_p_job_is_pending (void);

Description: Note that some job is pending execution.

Arguments: None

Returns: Nothing.

void slurm_sched_p_partition_change (void);

Description: Note that some partition state change happened such as time or size limits.

Arguments: None

Returns: Nothing.

char *slurm_sched_p_get_conf (void);

Description: Return scheduler specific configuration information to be reported for the scontrol show configuration command.

Arguments: None

Returns: A string containing configuration information. The return value is released using the xfree() function.

Last modified 23 October 2019