Skip to content

Commit

Permalink
Support for Slurm 21.08 (#227)
Browse files Browse the repository at this point in the history
* Expect slurm version 21.08

* Search slurm version in slurm_version.h

Starting from Slurm >= 21.08, slurm version is declared in this
dedicated header file.

* Port templates to Slurm 21.08

These templates have been generated using autopxd2, installed with:

  $ pip install autopxd2

Then, *.pxd files have been generated using these commands:

  $ cd /usr/include
  $ autopxd --include-dir . slurm/slurm_errno.h > \
    ~/pyslurm/jinja2/slurm_errno.h.pxd
  $ autopxd --include-dir . slurm/slurm.h > \
    ~/pyslurm/jinja2/slurm.h.pxd
  $ autopxd --include-dir . slurm/slurmdb.h > \
    ~/pyslurm/jinja2/slurmdb.h.pxd

Then, jinja2/slurm.h.pxd and jinja2/slurmdb.h.pxd have been manually
modified to:

- Remove libc.stdint import
- Remove duplicated slurm_errno symbols
- Include defines from dedicated subdir

Additionally:

- in jinja2/slurm.h.pxd:
  - symbols SLURM_ERROR, SLURM_SUCCESS and SLURM_VERSION have been
    restored,
  - slurm_addr_t control_addr and pthread_mutex_t lock are commented
    out, just like before, to avoid compilation error with these types
    (they are not used by pyslurm).
- in jinja2/slurmdb.h.pxd, all symbols duplicated in
  jinja2/slurm.h.pxd have been removed.

This finally produces this commit.

* Transpose e79981c in template

* Update slurmdb CLUSTER_FLAGS defs for 21.08

* Update slurm CPU_FREQ defs for 21.08

* Update NODE_STATE defs for slurm 21.08

* Update DEBUG_FLAG defs for slurm 21.08

* Update READY_* defs for slurm 21.08

* Generate pyslurm/slurm.pxd based on template

To generate this files, I used j2cli:

  $ pip install j2cli
  $ j2 jinja2/slurm.j2 > pyslurm/slurm.pxd

* Update python structures for slurm 21.08

There are some new parameters, some have vanished, some have been
renamed.

* Update *.pxi following latest defs changes

* Add new sibling arg to slurm_kill_job2()

Slurm 21.08 slurm_kill_job2() now expects a fourth char* sibling
argument.

* Bump __version__

* Typo fix in slurmdb job dict key

* Update slurm version in README

* Update NODE_STATE in examples

* Use docker image tag 21.08.0 for tests

* Update test_slurm_api_version expected value

* Use NULL slurmdb_connection_get persist_conn_flags

Use hard-coded NULL slurm.slurmdb_connection_get() persist_conn_flags
consistently. Persistent connections are not used in PySlurm. The
variable was declared to NULL and not used elsewhere, the pointer was
not preallocated in class slurmdb_jobs.

I propose NULL to be used consistently in both cases.

Co-authored-by: Nicholas Carriero <[email protected]>

* Initialize and dealloc slurmdb_clusters db_conn

Class slurmdb_clusters db_conn attribute is declared and used in get()
but it was not initialized with a proper connection. Also close and
free the allocation in __dealloc__().

Co-authored-by: Nicholas Carriero <[email protected]>

* Add missing slurm_init() and slurm_fini()

Starting from Slurm 20.11, slurm_init() must be called prior to any
other Slurm library API calls. For the moment, its load Slurm
configuration structure. For reference:

SchedMD/slurm@e35a6e3

On the other side, slurm_fini() cleanup the configuration data
structures in memory.

Co-authored-by: Nicholas Carriero <[email protected]>

* Call slurm_init() at pyslurm module load

This way, PySlurm consumers do not have to do it explicitely.

* Bump to docker-centos7-slurm:21.08.6

* fix: update tests to use pyenv

Co-authored-by: Nicholas Carriero <[email protected]>
Co-authored-by: Giovanni Torres <[email protected]>
  • Loading branch information
3 people authored Mar 1, 2022
1 parent fad9efa commit 8febf21
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 328 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This PySlurm branch has been tested with:

* Cython (latest stable)
* Python 3.6, 3.7, 3.8, and 3.9
* Slurm 20.11
* Slurm 21.08

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
slurm:
image: giovtorres/docker-centos7-slurm:20.11.8
image: giovtorres/docker-centos7-slurm:21.08.6
hostname: slurmctl
container_name: slurmctl
stdin_open: true
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
slurm:
image: giovtorres/docker-centos7-slurm:20.11.8
image: giovtorres/docker-centos7-slurm:21.08.0
hostname: slurmctl
container_name: slurmctl
stdin_open: true
Expand Down
4 changes: 2 additions & 2 deletions examples/node_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
NODE_STATE_DRAIN
NODE_STATE_COMPLETING
NODE_STATE_NO_RESPOND
NODE_STATE_POWER_SAVE
NODE_STATE_POWERED_DOWN
NODE_STATE_FAIL
NODE_STATE_POWER_UP
NODE_STATE_POWERING_UP
Some states are not valid on a Blue Gene
"""
Expand Down
31 changes: 18 additions & 13 deletions jinja2/defines/slurm_defines.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ uint32_t JOB_STAGE_OUT

uint8_t READY_JOB_ERROR
uint8_t READY_JOB_FATAL
uint8_t READY_NODE_STATE
uint8_t READY_JOB_STATE
uint8_t READY_PROLOG_STATE

uint8_t MAIL_JOB_BEGIN
uint8_t MAIL_JOB_END
Expand Down Expand Up @@ -103,11 +106,6 @@ uint32_t CPU_FREQ_PERFORMANCE
uint32_t CPU_FREQ_POWERSAVE
uint32_t CPU_FREQ_USERSPACE
uint32_t CPU_FREQ_GOV_MASK
uint32_t CPU_FREQ_PERFORMANCE_OLD
uint32_t CPU_FREQ_POWERSAVE_OLD
uint32_t CPU_FREQ_USERSPACE_OLD
uint32_t CPU_FREQ_ONDEMAND_OLD
uint32_t CPU_FREQ_CONSERVATIVE_OLD

uint8_t NODE_STATE_BASE
uint32_t NODE_STATE_FLAGS
Expand All @@ -119,13 +117,20 @@ uint16_t NODE_RESUME
uint16_t NODE_STATE_DRAIN
uint16_t NODE_STATE_COMPLETING
uint16_t NODE_STATE_NO_RESPOND
uint16_t NODE_STATE_POWER_SAVE
uint16_t NODE_STATE_POWERED_DOWN
uint16_t NODE_STATE_FAIL
uint16_t NODE_STATE_POWER_UP
uint16_t NODE_STATE_POWERING_UP
uint16_t NODE_STATE_MAINT
uint32_t NODE_STATE_REBOOT
uint32_t NODE_STATE_CANCEL_REBOOT
uint32_t NODE_STATE_REBOOT_REQUESTED
uint32_t NODE_STATE_REBOOT_CANCEL
uint32_t NODE_STATE_POWERING_DOWN
uint32_t NODE_STATE_DYNAMIC
uint32_t NODE_STATE_REBOOT_ISSUED
uint32_t NODE_STATE_PLANNED
uint32_t NODE_STATE_INVALID_REG
uint32_t NODE_STATE_POWER_DOWN
uint32_t NODE_STATE_POWER_UP
uint32_t NODE_STATE_POWER_DRAIN

uint8_t SHOW_ALL
uint8_t SHOW_DETAIL
Expand Down Expand Up @@ -293,9 +298,9 @@ uint8_t DEBUG_FLAG_SELECT_TYPE
uint8_t DEBUG_FLAG_STEPS
uint8_t DEBUG_FLAG_TRIGGERS
uint8_t DEBUG_FLAG_CPU_BIND
uint8_t DEBUG_FLAG_NET_RAW
uint8_t DEBUG_FLAG_NO_CONF_HASH
uint8_t DEBUG_FLAG_GRES
uint8_t DEBUG_FLAG_TRES_NODE
uint16_t DEBUG_FLAG_DATA
uint16_t DEBUG_FLAG_WORKQ
uint16_t DEBUG_FLAG_NET
Expand All @@ -304,14 +309,12 @@ uint16_t DEBUG_FLAG_BACKFILL
uint16_t DEBUG_FLAG_GANG
uint16_t DEBUG_FLAG_RESERVATION
uint16_t DEBUG_FLAG_FRONT_END
uint32_t DEBUG_FLAG_NO_REALTIME
uint32_t DEBUG_FLAG_SWITCH
uint32_t DEBUG_FLAG_ENERGY
uint32_t DEBUG_FLAG_EXT_SENSORS
uint32_t DEBUG_FLAG_LICENSE
uint32_t DEBUG_FLAG_PROFILE
uint32_t DEBUG_FLAG_INTERCONNECT
uint32_t DEBUG_FLAG_FILESYSTEM
uint32_t DEBUG_FLAG_JOB_CONT
uint32_t DEBUG_FLAG_TASK
uint32_t DEBUG_FLAG_PROTOCOL
Expand Down Expand Up @@ -339,9 +342,11 @@ uint64_t DEBUG_FLAG_NODE_FEATURES
uint64_t DEBUG_FLAG_FEDR
uint64_t DEBUG_FLAG_HETJOB
uint64_t DEBUG_FLAG_ACCRUE
uint64_t DEBUG_FLAG_POWER_SAVE
uint64_t DEBUG_FLAG_AGENT
uint64_t DEBUG_FLAG_DEPENDENCY
uint64_t DEBUG_FLAG_JAG
uint64_t DEBUG_FLAG_CGROUP
uint64_t DEBUG_FLAG_SCRIPT

uint8_t PREEMPT_MODE_OFF
uint8_t PREEMPT_MODE_SUSPEND
Expand Down
4 changes: 1 addition & 3 deletions jinja2/defines/slurmdb_defines.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ uint8_t CLUSTER_FLAG_A6
uint8_t CLUSTER_FLAG_A7
uint8_t CLUSTER_FLAG_MULTSD
uint16_t CLUSTER_FLAG_A9
uint16_t CLUSTER_FLAG_A10
uint16_t CLUSTER_FLAG_FE
uint16_t CLUSTER_FLAG_CRAY_N
uint16_t CLUSTER_FLAG_CRAY
uint16_t CLUSTER_FLAG_FED
uint16_t CLUSTER_FLAG_EXT
uint16_t CLUSTER_FLAG_CRAY

uint8_t SLURMDB_ASSOC_FLAG_NONE
uint8_t SLURMDB_ASSOC_FLAG_DELETED
Expand Down
Loading

0 comments on commit 8febf21

Please sign in to comment.