Skip to content

Commit

Permalink
Merge SPANK errors into Slurm errors
Browse files Browse the repository at this point in the history
Bug 11361
  • Loading branch information
naterini authored and wickberg committed Jul 27, 2021
1 parent 2557ae6 commit 00283d0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
14 changes: 14 additions & 0 deletions slurm/slurm_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern "C" {

/* general return codes */
#define SLURM_SUCCESS 0
#define ESPANK_SUCCESS 0
#define SLURM_ERROR -1

typedef enum {
Expand Down Expand Up @@ -215,6 +216,19 @@ typedef enum {
ESLURM_PARTITION_ASSOC = 2130,
ESLURM_IN_STANDBY_USE_BACKUP,

/* SPANK errors */
ESPANK_ERROR = 3000,
ESPANK_BAD_ARG,
ESPANK_NOT_TASK,
ESPANK_ENV_EXISTS,
ESPANK_ENV_NOEXIST,
ESPANK_NOSPACE,
ESPANK_NOT_REMOTE,
ESPANK_NOEXIST,
ESPANK_NOT_EXECD,
ESPANK_NOT_AVAIL,
ESPANK_NOT_LOCAL,

/* slurmd error codes */
ESLURMD_PIPE_ERROR_ON_TASK_SPAWN = 4000,
ESLURMD_KILL_TASK_FAILED,
Expand Down
23 changes: 6 additions & 17 deletions slurm/spank.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
* with Slurm; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\*****************************************************************************/
#include <slurm/slurm_errno.h>

#ifndef SPANK_H
#define SPANK_H

Expand Down Expand Up @@ -166,24 +168,11 @@ enum spank_item {

typedef enum spank_item spank_item_t;

/* SPANK error codes.
/*
* SPANK error codes match the Slurm internal error codes and the inheirted
* POSIX error codes.
*/
enum spank_err {
ESPANK_SUCCESS = 0, /* Success. */
ESPANK_ERROR = 1, /* Generic error. */
ESPANK_BAD_ARG = 2, /* Bad argument. */
ESPANK_NOT_TASK = 3, /* Not in task context. */
ESPANK_ENV_EXISTS = 4, /* Environment variable exists && !overwrite */
ESPANK_ENV_NOEXIST = 5, /* No such environment variable */
ESPANK_NOSPACE = 6, /* Buffer too small. */
ESPANK_NOT_REMOTE = 7, /* Function only may be called in remote context */
ESPANK_NOEXIST = 8, /* Id/pid doesn't exist on this node */
ESPANK_NOT_EXECD = 9, /* Lookup by pid requested, but no tasks running */
ESPANK_NOT_AVAIL = 10,/* SPANK item not available from this callback */
ESPANK_NOT_LOCAL = 11,/* Function only valid in local/alloc context */
};

typedef enum spank_err spank_err_t;
typedef slurm_err_t spank_err_t;

/*
* SPANK plugin context
Expand Down
29 changes: 1 addition & 28 deletions src/common/plugstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,34 +1865,7 @@ static spank_err_t _check_spank_item_validity (spank_t spank, spank_item_t item)

const char * spank_strerror (spank_err_t err)
{
switch (err) {
case ESPANK_SUCCESS:
return "Success";
case ESPANK_ERROR:
return "Generic error";
case ESPANK_BAD_ARG:
return "Bad argument";
case ESPANK_NOT_TASK:
return "Not in task context";
case ESPANK_ENV_EXISTS:
return "Environment variable exists";
case ESPANK_ENV_NOEXIST:
return "No such environment variable";
case ESPANK_NOSPACE:
return "Buffer too small";
case ESPANK_NOT_REMOTE:
return "Valid only in remote context";
case ESPANK_NOEXIST:
return "Id/PID does not exist on this node";
case ESPANK_NOT_EXECD:
return "Lookup by PID requested, but no tasks running";
case ESPANK_NOT_AVAIL:
return "Item not available from this callback";
case ESPANK_NOT_LOCAL:
return "Valid only in local or allocator context";
}

return "Unknown";
return slurm_strerror(err);
}

int spank_symbol_supported (const char *name)
Expand Down
24 changes: 24 additions & 0 deletions src/common/slurm_errno.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,30 @@ static slurm_errtab_t slurm_errtab[] = {
{ ESLURM_PARTITION_ASSOC,
"Multiple partition job request not supported when a partition is set in the association" },

/* SPANK errors */
{ ESPANK_ERROR,
"Generic error" },
{ ESPANK_BAD_ARG,
"Bad argument" },
{ ESPANK_NOT_TASK,
"Not in task context" },
{ ESPANK_ENV_EXISTS,
"Environment variable exists" },
{ ESPANK_ENV_NOEXIST,
"No such environment variable" },
{ ESPANK_NOSPACE,
"Buffer too small" },
{ ESPANK_NOT_REMOTE,
"Valid only in remote context" },
{ ESPANK_NOEXIST,
"Id/PID does not exist on this node" },
{ ESPANK_NOT_EXECD,
"Lookup by PID requested, but no tasks running" },
{ ESPANK_NOT_AVAIL,
"Item not available from this callback" },
{ ESPANK_NOT_LOCAL,
"Valid only in local or allocator context" },

/* slurmd error codes */
{ ESLURMD_PIPE_ERROR_ON_TASK_SPAWN,
"Pipe error on task spawn" },
Expand Down

0 comments on commit 00283d0

Please sign in to comment.