Skip to content

Commit 92a6915

Browse files
committed
resource: support resource.config array
Problem: Generating a system R for resource configuration of a Flux system instance is not user friendly, and can be confusing since the ranks assigned in R are overridden by the ranks from the bootstrap hostlist anyway. Allow an alternate method for resource configuration via the [[resource.config]] arrray using the rlist_from_config() function from librlist.
1 parent adde058 commit 92a6915

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/modules/resource/resource.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "src/common/libutil/errprintf.h"
2323
#include "src/common/libidset/idset.h"
2424
#include "src/common/libeventlog/eventlog.h"
25+
#include "src/common/librlist/rlist.h"
2526

2627
#include "resource.h"
2728
#include "inventory.h"
@@ -38,8 +39,11 @@
3839
* exclude = "targets"
3940
* Exclude specified broker rank(s) or hosts from scheduling
4041
*
42+
* [[resource.confg]]
43+
* Resource configuration array
44+
*
4145
* path = "/path"
42-
* Set path to resource object
46+
* Set path to resource object (if no resource.config array)
4347
*
4448
* noverify = true
4549
* Skip verification that configured resources match local hwloc
@@ -61,12 +65,14 @@ static int parse_config (struct resource_ctx *ctx,
6165
int noverify = 0;
6266
int norestrict = 0;
6367
json_t *o = NULL;
68+
json_t *config = NULL;
6469

6570
if (flux_conf_unpack (conf,
6671
&error,
67-
"{s?:{s?:s s?:s s?:b s?b !}}",
72+
"{s?:{s?:s s?:o s?:s s?:b s?b !}}",
6873
"resource",
6974
"path", &path,
75+
"config", &config,
7076
"exclude", &exclude,
7177
"norestrict", &norestrict,
7278
"noverify", &noverify) < 0) {
@@ -75,7 +81,19 @@ static int parse_config (struct resource_ctx *ctx,
7581
error.text);
7682
return -1;
7783
}
78-
if (path) {
84+
if (config) {
85+
struct rlist *rl = rlist_from_config (config, &error);
86+
if (!rl) {
87+
errprintf (errp,
88+
"error parsing [resource.config] array: %s",
89+
error.text);
90+
return -1;
91+
}
92+
if (!(o = rlist_to_R (rl)))
93+
return errprintf (errp, "rlist_to_R: %s", strerror (errno));
94+
rlist_destroy (rl);
95+
}
96+
else if (path) {
7997
FILE *f;
8098
json_error_t e;
8199

@@ -96,17 +114,16 @@ static int parse_config (struct resource_ctx *ctx,
96114
e.line);
97115
return -1;
98116
}
99-
if (!R)
100-
json_decref (o);
101117
}
102-
103118
*excludep = exclude;
104119
if (noverifyp)
105120
*noverifyp = noverify ? true : false;
106121
if (norestrictp)
107122
*norestrictp = norestrict ? true : false;
108123
if (R)
109124
*R = o;
125+
else
126+
json_decref (o);
110127
return 0;
111128
}
112129

0 commit comments

Comments
 (0)