Skip to content

Commit 3464b31

Browse files
authored
Merge pull request #5870 from grondo/issue#5868
fix broker crash in `resource.status` RPC handling when exlcuded ranks are also down
2 parents e479077 + 17a2855 commit 3464b31

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

src/common/librlist/rlist.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ static int rlist_remove_rank (struct rlist *rl, int rank)
398398
errno = ENOENT;
399399
return -1;
400400
}
401+
rank_hash_delete (rl, rank);
401402
zlistx_delete (rl->nodes, handle);
402403
return 0;
403404
}
@@ -2163,6 +2164,7 @@ struct rlist *rlist_alloc (struct rlist *rl,
21632164

21642165
if (!rl || !ai) {
21652166
errno = EINVAL;
2167+
errprintf (errp, "Invalid argument");
21662168
return NULL;
21672169
}
21682170

@@ -2173,6 +2175,8 @@ struct rlist *rlist_alloc (struct rlist *rl,
21732175
result = rlist_alloc_constrained (rl, ai, errp);
21742176
else {
21752177
result = rlist_try_alloc (rl, ai);
2178+
if (!result)
2179+
errprintf (errp, "%s", strerror (errno));
21762180

21772181
if (!result && (errno == ENOSPC)) {
21782182
if (!rlist_alloc_feasible (rl,
@@ -2312,9 +2316,11 @@ static int rlist_mark_state (struct rlist *rl, bool up, const char *ids)
23122316
i = idset_first (idset);
23132317
while (i != IDSET_INVALID_ID) {
23142318
struct rnode *n = rlist_find_rank (rl, i);
2315-
if (n->up != up)
2316-
count += idset_count (n->cores->avail);
2317-
n->up = up;
2319+
if (n) {
2320+
if (n->up != up)
2321+
count += idset_count (n->cores->avail);
2322+
n->up = up;
2323+
}
23182324
i = idset_next (idset, i);
23192325
}
23202326
idset_destroy (idset);

src/common/librlist/test/rlist.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,43 @@ static void test_rlist_config_inval (void)
21122112
json_decref (o);
21132113
}
21142114

2115+
static void test_issue_5868 (void)
2116+
{
2117+
char *R;
2118+
char *s;
2119+
struct rlist *rl;
2120+
struct idset *ranks;
2121+
2122+
if (!(R = R_create ("0-3",
2123+
"0-3",
2124+
NULL,
2125+
"foo[0-3]",
2126+
NULL)))
2127+
BAIL_OUT ("issue5868: R_create");
2128+
2129+
if (!(rl = rlist_from_R (R)))
2130+
BAIL_OUT ("issue5868: rlist_from_R() failed");
2131+
/* Remove ranks 0-1
2132+
*/
2133+
if (!(ranks = idset_decode ("0-1")))
2134+
BAIL_OUT ("issue5868: idset_create failed");
2135+
if (rlist_remove_ranks (rl, ranks) < 0)
2136+
BAIL_OUT ("issue5868: rlist_remove_ranks failed");
2137+
idset_destroy (ranks);
2138+
2139+
ok (rlist_mark_down (rl, "0-2") == 0,
2140+
"issue5868: rlist_mark_down (0-2) ignores missing ranks");
2141+
2142+
s = rlist_dumps (rl);
2143+
diag ("%s", s);
2144+
is (s, "rank3/core[0-3]",
2145+
"issue5868: expected resources remain up");
2146+
2147+
free (s);
2148+
rlist_destroy (rl);
2149+
free (R);
2150+
}
2151+
21152152
int main (int ac, char *av[])
21162153
{
21172154
plan (NO_PLAN);
@@ -2142,7 +2179,7 @@ int main (int ac, char *av[])
21422179
test_properties ();
21432180
test_issue4290 ();
21442181
test_rlist_config_inval ();
2145-
2182+
test_issue_5868 ();
21462183
done_testing ();
21472184
}
21482185

0 commit comments

Comments
 (0)