Skip to content
Snippets Groups Projects
Commit 3947aedd authored by Moe Jette's avatar Moe Jette
Browse files

Add SPANK items available to get: SLURM_VERSION, SLURM_VERSION_MAJOR,

    SLURM_VERISON_MINOR and SLURM_VERSION_MICRO.
parent a93d9a32
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ documents those changes that are of interest to users and admins.
a job's memory memory at the same time that processors are allocated based
upon the --mem or --mem-per-cpu option rather than when job steps are
initiated.
-- Add SPANK items available to get: SLURM_VERSION, SLURM_VERSION_MAJOR,
SLURM_VERISON_MINOR and SLURM_VERSION_MICRO.
* Changes in SLURM 1.3.5
========================
......
/*****************************************************************************\
* spank.h - Stackable Plug-in Architecture for Node job Kontrol
*****************************************************************************
* Copyright (C) 2002-2006 The Regents of the University of California.
* Copyright (C) 2002-2007 The Regents of the University of California.
* Copyright (C) 2008 Lawrence Livermore National Security.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* LLNL-CODE-402394.
*
......@@ -127,7 +128,11 @@ enum spank_item {
S_JOB_PID_TO_LOCAL_ID, /* local task id from pid (pid_t, uint32_t *) */
S_JOB_LOCAL_TO_GLOBAL_ID,/* local id to global id (uint32_t, uint32_t *) */
S_JOB_GLOBAL_TO_LOCAL_ID,/* global id to local id (uint32_t, uint32_t *) */
S_JOB_SUPPLEMENTARY_GIDS /* Array of suppl. gids (gid_t **, int *) */
S_JOB_SUPPLEMENTARY_GIDS,/* Array of suppl. gids (gid_t **, int *) */
S_SLURM_VERSION, /* Current slurm version (char **) */
S_SLURM_VERSION_MAJOR, /* Current slurm version major release (char **) */
S_SLURM_VERSION_MINOR, /* Current slurm version minor release (char **) */
S_SLURM_VERSION_MICRO /* Current slurm version micro release (char **) */
};
typedef enum spank_item spank_item_t;
......@@ -216,8 +221,9 @@ int spank_remote (spank_t spank);
/* Get the value for the current job or task item specified,
* storing the result in the subsequent pointer argument(s).
* Refer to the spank_item_t comments for argument types.
* For S_JOB_ARGV and S_JOB_ENV items the result returned to
* the caller should not be freed or modified.
* For S_JOB_ARGV, S_JOB_ENV, and S_SLURM_VERSION* items
* the result returned to the caller should not be freed or
* modified.
*
* Returns ESPANK_SUCCESS on success, ESPANK_NOTASK if an S_TASK*
* item is requested from outside a task context, ESPANK_BAD_ARG
......
......@@ -1110,7 +1110,7 @@ global_to_local_id (slurmd_job_t *job, uint32_t gid, uint32_t *p2uint32)
/*
* Return 1 if spank_item_t is valid for S_TYPE_LOCAL
*/
static int valid_in_local_context (spank_item_t item)
static int _valid_in_local_context (spank_item_t item)
{
int rc = 0;
switch (item) {
......@@ -1130,6 +1130,24 @@ static int valid_in_local_context (spank_item_t item)
return (rc);
}
/*
* Return 1 if spank_item_t is just getting version (valid anywhere)
*/
static int _version_check (spank_item_t item)
{
int rc = 0;
switch (item) {
case S_SLURM_VERSION:
case S_SLURM_VERSION_MAJOR:
case S_SLURM_VERSION_MINOR:
case S_SLURM_VERSION_MICRO:
rc = 1;
break;
default:
rc = 0;
}
return (rc);
}
/*
* Global functions for SPANK plugins
......@@ -1172,6 +1190,7 @@ spank_err_t spank_get_item(spank_t spank, spank_item_t item, ...)
pid_t *p2pid;
pid_t pid;
char ***p2argv;
char **p2vers;
slurmd_task_info_t *task;
slurmd_job_t *slurmd_job = NULL;
struct spank_launcher_job_info *launcher_job = NULL;
......@@ -1181,17 +1200,20 @@ spank_err_t spank_get_item(spank_t spank, spank_item_t item, ...)
if ((spank == NULL) || (spank->magic != SPANK_MAGIC))
return (ESPANK_BAD_ARG);
if ( (spank->type != S_TYPE_REMOTE)
&& (!valid_in_local_context(item)))
return (ESPANK_NOT_REMOTE);
if (!_version_check(item)) {
/* Need job pointer to process other items */
if ( (spank->type != S_TYPE_REMOTE)
&& (!_valid_in_local_context(item)))
return (ESPANK_NOT_REMOTE);
if (spank->job == NULL)
return (ESPANK_BAD_ARG);
if (spank->job == NULL)
return (ESPANK_BAD_ARG);
if (spank->type == S_TYPE_LOCAL)
launcher_job = spank->job;
else
slurmd_job = spank->job;
if (spank->type == S_TYPE_LOCAL)
launcher_job = spank->job;
else
slurmd_job = spank->job;
}
va_start(vargs, item);
switch (item) {
......@@ -1343,6 +1365,22 @@ spank_err_t spank_get_item(spank_t spank, spank_item_t item, ...)
p2uint32 = va_arg(vargs, uint32_t *);
rc = global_to_local_id (slurmd_job, uint32, p2uint32);
break;
case S_SLURM_VERSION:
p2vers = va_arg(vargs, char **);
*p2vers = SLURM_VERSION;
break;
case S_SLURM_VERSION_MAJOR:
p2vers = va_arg(vargs, char **);
*p2vers = SLURM_MAJOR;
break;
case S_SLURM_VERSION_MINOR:
p2vers = va_arg(vargs, char **);
*p2vers = SLURM_MINOR;
break;
case S_SLURM_VERSION_MICRO:
p2vers = va_arg(vargs, char **);
*p2vers = SLURM_MICRO;
break;
default:
rc = ESPANK_BAD_ARG;
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment