Skip to content

Commit 5dfc1c3

Browse files
committed
Merge branch 'release-0.1.1'
2 parents 25bbdef + 62593b0 commit 5dfc1c3

File tree

9 files changed

+555
-99
lines changed

9 files changed

+555
-99
lines changed

CMakeLists.txt

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@
2222
# SOFTWARE.
2323
#
2424

25-
project(slurm-redis C)
25+
cmake_policy(VERSION 3.4.0)
2626
cmake_minimum_required(VERSION 3.4.0 FATAL_ERROR)
2727

28+
project(slurm-redis
29+
VERSION 0.1.1
30+
DESCRIPTION "Redis plugins for slurm"
31+
HOMEPAGE_URL "https://github.com/pkovacs/slurm-redis"
32+
LANGUAGES C)
33+
2834
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
2935
include(GNUInstallDirs)
3036
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -41,12 +47,9 @@ include(FindSymbols)
4147
include(FindLibraries)
4248
include(TestCompiler)
4349

44-
# -------------------
45-
# Set project version
46-
# -------------------
47-
set(SLURM_REDIS_VERSION_MAJOR 0)
48-
set(SLURM_REDIS_VERSION_MINOR 1)
49-
set(SLURM_REDIS_VERSION_PATCH 0)
50+
# ---------------
51+
# Set ABI version
52+
# ---------------
5053
set(SLURM_REDIS_ABI 0)
5154

5255
# -----------------
@@ -70,30 +73,32 @@ if(NOT CMAKE_BUILD_TYPE)
7073
set(CMAKE_BUILD_TYPE "Release")
7174
endif()
7275

73-
option(USE_ISO8601 "Use ISO8601 date/time format in redis" ON)
76+
if(NOT JCR_CACHE_SIZE)
77+
set(JCR_CACHE_SIZE "128")
78+
endif()
7479

75-
if(NOT ID_CACHE_SIZE)
76-
set(ID_CACHE_SIZE "128")
80+
if(NOT JCR_CACHE_TTL)
81+
set(JCR_CACHE_TTL "120")
7782
endif()
7883

79-
if(NOT ID_CACHE_TTL)
80-
set(ID_CACHE_TTL "120")
84+
if(NOT JCR_FETCH_COUNT)
85+
set(JCR_FETCH_COUNT "500")
8186
endif()
8287

83-
if(NOT FETCH_COUNT)
84-
set(FETCH_COUNT "500")
88+
if(NOT JCR_FETCH_LIMIT)
89+
set(JCR_FETCH_LIMIT "1000")
8590
endif()
8691

87-
if(NOT FETCH_LIMIT)
88-
set(FETCH_LIMIT "1000")
92+
if(NOT JCR_QUERY_TTL)
93+
set(JCR_QUERY_TTL "60")
8994
endif()
9095

91-
if(NOT QUERY_TTL)
92-
set(QUERY_TTL "60")
96+
if(NOT JCR_TTL)
97+
set(JCR_TTL "-1")
9398
endif()
9499

95-
if(NOT TTL)
96-
set(TTL "-1")
100+
if(NOT JCR_TMF)
101+
set(JCR_TMF "1")
97102
endif()
98103

99104
# --------------
@@ -123,18 +128,28 @@ add_subdirectory(common)
123128
add_subdirectory(redis)
124129
add_subdirectory(slurm)
125130

131+
# ----------------------
132+
# Generate a slurm patch
133+
# ----------------------
134+
configure_file(
135+
${CMAKE_SOURCE_DIR}/patch/x_ac_slurm_redis.m4.in
136+
${CMAKE_BINARY_DIR}/patch/x_ac_slurm_redis.m4
137+
)
138+
add_custom_target(patch ${CMAKE_SOURCE_DIR}/generate_patch
139+
${PROJECT_NAME}-${PROJECT_VERSION} ${CMAKE_INCLUDE_PATH}
140+
${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
141+
DEPENDS ${CMAKE_BINARY_DIR}/patch/x_ac_slurm_redis.m4
142+
)
143+
126144
# -----------------
127145
# Add CPack support
128146
# -----------------
129147
set(CPACK_GENERATOR "RPM")
130148
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
131-
set(CPACK_PACKAGE_VERSION_MAJOR ${SLURM_REDIS_VERSION_MAJOR})
132-
set(CPACK_PACKAGE_VERSION_MINOR ${SLURM_REDIS_VERSION_MINOR})
133-
set(CPACK_PACKAGE_VERSION_PATCH ${SLURM_REDIS_VERSION_PATCH})
134-
string(CONCAT CPACK_PACKAGE_VERSION
135-
"${SLURM_REDIS_VERSION_MAJOR}."
136-
"${SLURM_REDIS_VERSION_MINOR}."
137-
"${SLURM_REDIS_VERSION_PATCH}")
149+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
150+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
151+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
152+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
138153
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
139154
set(CPACK_PACKAGE_CHECKSUM "SHA1")
140155
set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")

NEWS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This file provides a summary of changes in the releases of slurm-redis
2+
3+
Changes in v0.1.1
4+
=================
5+
-- ensure only one redis ping occurs when already connected
6+
-- rename the compile-time options with a JCR_ prefix so as not to collide
7+
with any names in slurm's config.h
8+
-- add script generate_patch to produce slurm source-tree patch sets with
9+
a full set of configure options for slurm-redis
10+
-- add versioned patch sets to the release to provide the means to configure
11+
and install slurm_redis using slurm's autotools build system

README.md

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
- [Purpose and Design](#purpose-and-design)
44
- [Requirements](#requirements)
5-
- [Plugin Configuration](#plugin-configuration)
6-
- [Basic configuration](#basic-configuration)
5+
- [Build slurm-redis using provided slurm patch set](#build-slurm-redis-using-provided-slurm-patch-set)
6+
- [Build slurm-redis using native build system](#build-slurm-redis-using-native-build-system)
77
- [Advanced configuration](#advanced-configuration)
88
- [Slurm Configuration](#slurm-configuration)
99
- [Redis Configuration](#redis-configuration)
1010
- [Redis System Config](#redis-system-config)
1111
- [Usage](#usage)
1212
- [FAQ](#faq)
1313

14+
___
15+
1416
### Purpose and Design
1517

1618
I wanted a fast, lightweight job completion plugin for slurm that has good support for client-side filtering of job completion criteria. Redis fits this need very nicely because it is memory-based and very fast indeed. This jobcomp_redis plugin can produce permanent redis keys or, using redis key expiry, it can produce keys which live only for a duration that you configure. The jobcomp_redis plugin can be a good complement to accounting storage plugins, e.g. mysql/mariadb. For example, you could configure the jobcomp_redis plugin so that keys live only for a week, thus implementing a super-fast, memory-based cache of a rolling week's worth of jobs. If you save the keys permanently (the default), you can configure redis persistence to suit your needs, write scripts to manage your redis job data, etc.
@@ -20,22 +22,57 @@ In terms of design, the jobcomp_redis slurm plugin works with a partner plugin t
2022
When job data is requested from slurm, jobcomp_redis sends job criteria to redis and then issues the command `SLURMJC.MATCH` to ask redis to perform the job matching. In this way, we avoid pulling job candidates across the wire just to test if they match which can waste network bandwidth and slow us down. If matches are found, the slurm-side partner will issue `SLURMJC.FETCH` to receive the job data from redis.
2123

2224
Let me know if you find this plugin useful. More plugins to follow ...
25+
___
2326

2427
### Requirements
2528

26-
To configure, build and run this package from source you will need the following:
27-
- a working slurm installation with slurm libraries (including `libslurm.so` symlink) in your library search path
28-
- a *_configured_* slurm source tree (`slurm/slurm.h` exists) that *_matches_* your slurm installation
29-
- `gcc` and `pkg-config` which you already have if you've built slurm successfully
30-
- [cmake](https://cmake.org/), a relatively recent version (3.4.0+)
29+
Two methods are provided for building this package from source:
30+
1. A patch set that applies patches directly over the slurm source tree and
31+
2. The slurm-redis native build system which uses [cmake](https://cmake.org/)
32+
33+
The patch set method is perhaps easier as it does not require that you have the cmake build system installed. The plugins were developed using the cmake build system, however, and using that method allows you to configure and build these plugins independently from a working slurm installation. All compile-time options are available in either case.
34+
35+
These are the additional software requirements to run slurm-redis:
36+
3137
- [redis](https://redis.io/), including its `redismodule.h` development header
3238
- [hiredis](https://github.com/redis/hiredis), the c client for redis, headers and library
3339
- `libuuid`, its header (uuid/uuid.h) and library `libuuid.so`, (available in utils-linux)
40+
___
41+
42+
#### Build slurm-redis using provided slurm patch set
43+
44+
The patch sets are named according to the version of slurm-redis and the version of slurm to which they apply, for example:
3445

46+
`slurm-redis-0.1.0-slurm-19.05.patch.bz2` would be the patch you could use for slurm-redis version 0.1.0 that patches over the slurm 19.05 source tree. Here's an example of using the patch set:
3547

36-
### Plugin Configuration
48+
```bash
49+
# Unpack both tarballs and apply the patch set
50+
$ tar -xjf slurm-19.05.2.tar.bz2
51+
$ bunzip2 slurm-redis-0.1.0-slurm-19.05.patch.bz2
52+
$ cd slurm-19.05.2
53+
$ patch -p1 < ../slurm-redis-0.1.0-slurm-19.05.patch
54+
patching file configure.ac
55+
...
56+
# Re-run autoreconf (or autogen.sh on 18.08) to apply build system changes
57+
./autoreconf
58+
# Configure slurm as you normally would, noting these additional options:
59+
./configure --help # See section "Advanced configuration"
60+
...
61+
--with-jcr-cache-size=N set jobcomp/redis cache size [128]
62+
--with-jcr-cache-ttl=N set jobcomp/redis cache ttl [120]
63+
--with-jcr-fetch-count=N
64+
set jobcomp/redis fetch count [500]
65+
--with-jcr-fetch-limit=N
66+
set jobcomp/redis fetch limit [1000]
67+
--with-jcr-query-ttl=N set jobcomp/redis query ttl [60]
68+
--with-jcr-ttl=N set jobcomp/redis ttl: -1=permanent [-1]
69+
--with-jcr-tmf=N set jobcomp/redis date/time format: 0=unix epoch,
70+
1=iso8601 [1]
71+
...
72+
```
73+
___
3774

38-
#### Basic configuration
75+
#### Build slurm-redis using native build system
3976

4077
```bash
4178
# CMAKE_INSTALL_PREFIX must be set to the system's library installation prefix,
@@ -59,7 +96,7 @@ $ make
5996
$ sudo make install
6097
```
6198

62-
After installing the plugins, restart `slurmctld` if it was running with a previous `jobcomp_redis.so` loaded. You do not have to restart redis, however, in order to load a newer version of the `slurm_jobcomp.so` plugin, in fact, keys can be lost if you restart redis in between its persistence cycles. Instead, simply open a redis cli and manually unload the current module, then load the new module (or write a script to do this):
99+
After installation, restart `slurmctld` if it was running with a previous `jobcomp_redis.so` loaded. You do not have to restart redis, however, in order to load a newer version of the `slurm_jobcomp.so` plugin, in fact, keys can be lost if you restart redis in between its persistence cycles. Instead, simply open a redis cli and manually unload the current module, then load the new module (or write a script to do this):
63100

64101
```bash
65102
redis-cli -h <host>
@@ -70,45 +107,64 @@ OK
70107
redis-cli> module load /usr/lib64/slurm/redis/slurm_jobcomp.so
71108
OK
72109
```
110+
___
73111

74112
#### Advanced configuration
75113

76114
```bash
77-
# cmake -DUSE_ISO8601 (default)
115+
$ cmake -DJCR_TMF=N ... # [0 = unix epoch times, 1 = ISO 8601 format] or
116+
$ ./configure --with-jcr-tmf=N ...
117+
# The default is 1 (ISO8601).
118+
119+
# This setting will cause the slurm jobcomp_redis plugin to send all date/time elements
120+
# either as ISO8601 strings, GMT with timezone "Z" (Zero/Zulu), or as Unix Epoch times.
78121

79-
This setting will cause the slurm jobcomp_redis plugin to send all date/time elements
80-
as ISO8601 strings, GMT with timezone "Z" (Zero/Zulu), thus all date/times will be
81-
human-readable and normalized to that timezone.
122+
$ cmake -DJCR_TTL=N ... # [-1 or a positive integer (seconds)] or
123+
$ ./configure --with-jcr-ttl=N ...
124+
# The default is -1: keys are permanent.
82125

83-
# cmake -DUSE_ISO8601=0
126+
# This setting will set the time-to-live in seconds of your job completion data. If you
127+
# use the value 86400, for example, your job keys will disappear after 1 day.
84128

85-
This setting will cause all date/times to be stored as integers (redis strings) --
86-
the number of seconds since the unix epoch.
129+
$ cmake -DJCR_QUERY_TTL=N ... # or
130+
$ ./configure --with-jcr-query-ttl=N ...
131+
# The default is 60 seconds.
87132

88-
# cmake -DTTL=<N> (default -1 = permanent key)
133+
# This setting should not need to be changed. When clients such as saact request job
134+
# data, the jobcomp_redis plugin sends the job criteria to redis as a set of transient
135+
# keys and then issues SLURMJC.MATCH. The latency between the time that the criteria
136+
# arrives in redis and the command SLURMJC.FETCH completes in redis is where this setting
137+
# matters.
89138

90-
This setting will set the time-to-live in seconds of your job completion data. If you
91-
use -DTTL=86400, your job keys will disappear after 1 day. The default is -1: keys
92-
are permanent. Use this setting if you want a fast but temporary cache of recent job
93-
data.
139+
$ cmake -DJCR_FETCH_LIMIT=N ... # or
140+
$ ./configure --with-jcr-fetch-limit=N ...
141+
# The default is 1000 job records.
94142

95-
# cmake -DQUERY_TTL=<N> (default 60)
143+
# The maximum number of jobs that redis will allow to be sent to the client in one
144+
# iteration of SLURMJC.FETCH.
96145

97-
This setting should not need to be changed. When clients such as saact request job data,
98-
the jobcomp_redis plugin sends the job criteria to redis as a set of transient keys and
99-
then issues SLURMJC.MATCH. The brief latency between the time that the criteria arrives
100-
in redis and the command SLURMJC.MATCH starts in redis is where this setting matters.
146+
$ cmake -DJCR_FETCH_COUNT=N ... # or
147+
$ ./configure --with-jcr-fetch-count=N ...
148+
# The default is 500 job records.
101149

102-
# cmake -DFETCH_LIMIT=<N> (default 1000)
150+
# The maximum number of jobs records that the client would like to receive in one
151+
# iteration of SLURMJC.FETCH.
103152

104-
The maximum number of jobs redis will allow to be sent to the client in one iteration
105-
of SLURMJC.FETCH.
153+
$ cmake -DJCR_CACHE_SIZE=N ... # or
154+
$ ./configure --with-jcr-cache-size=N
155+
# The default is 128 entries (there are separate uid and gid caches).
106156

107-
# cmake -DFETCH_COUNT=<N> (default 500)
157+
# As job records complete the jobcomp/redis plugin maintains small caches of uid and gid
158+
# to name, e.g. 0 -> root, to take pressure off distributed LDAP and similar systems.
108159

109-
The maximum number of jobs the client would like to receive in one iteration of
110-
SLURMJC.FETCH.
160+
$ cmake -DJCR_CACHE_TTL=N ... # or
161+
$ ./configure --with-jcr-cache-ttl=N
162+
# The default is 120 seconds.
163+
164+
# The time-to-live of the uid and gid cache entries. If a cache entry is missing or has
165+
# expired, slurm apis are called to fetch the names.
111166
```
167+
___
112168

113169
### Slurm Configuration
114170

@@ -123,6 +179,8 @@ JobCompType=jobcomp/redis
123179
#JobCompUser=<unused, redis has no notion of user>
124180
```
125181
182+
___
183+
126184
### Redis Configuration
127185
128186
```bash
@@ -157,6 +215,8 @@ number of ways to turn that off:
157215
158216
There may be some other system settings, e.g. overcommit_memory, that you need to adjust using `/etc/sysctl.conf`. Refer to the redis log file for more details.
159217
218+
___
219+
160220
### Usage
161221
162222
```bash

config.h.in

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#ifndef CONFIG_H
2626
#define CONFIG_H
2727

28-
#define SLURM_REDIS_VERSION_MAJOR @SLURM_REDIS_VERSION_MAJOR@
29-
#define SLURM_REDIS_VERSION_MINOR @SLURM_REDIS_VERSION_MINOR@
30-
#define SLURM_REDIS_VERSION_PATCH @SLURM_REDIS_VERSION_PATCH@
28+
#define SLURM_REDIS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
29+
#define SLURM_REDIS_VERSION_MINOR @PROJECT_VERSION_MINOR@
30+
#define SLURM_REDIS_VERSION_PATCH @PROJECT_VERSION_PATCH@
3131
#define SLURM_REDIS_ABI @SLURM_REDIS_ABI@
3232

3333
#cmakedefine HAVE_ATTRIBUTE_CLEANUP
@@ -43,14 +43,13 @@
4343
#cmakedefine HAVE_SYS_TYPES_H
4444
#cmakedefine HAVE_TIME_H
4545

46-
#cmakedefine ID_CACHE_SIZE @ID_CACHE_SIZE@
47-
#cmakedefine ID_CACHE_TTL @ID_CACHE_TTL@
48-
#cmakedefine FETCH_COUNT @FETCH_COUNT@
49-
#cmakedefine FETCH_LIMIT @FETCH_LIMIT@
50-
#cmakedefine QUERY_TTL @QUERY_TTL@
51-
#cmakedefine TTL @TTL@
52-
53-
#cmakedefine USE_ISO8601
46+
#cmakedefine JCR_CACHE_SIZE @JCR_CACHE_SIZE@
47+
#cmakedefine JCR_CACHE_TTL @JCR_CACHE_TTL@
48+
#cmakedefine JCR_FETCH_COUNT @JCR_FETCH_COUNT@
49+
#cmakedefine JCR_FETCH_LIMIT @JCR_FETCH_LIMIT@
50+
#cmakedefine JCR_QUERY_TTL @JCR_QUERY_TTL@
51+
#cmakedefine JCR_TTL @JCR_TTL@
52+
#cmakedefine JCR_TMF @JCR_TMF@
5453

5554
#define AUTO_PTR(fn) __attribute__((cleanup(fn)))
5655

0 commit comments

Comments
 (0)