fix(lib): a malformed select in a resreq fails the parse instead of being dropped (bug-1887)

The primary_resreq action ignored parse_resreq_primary()'s result, so a
primary whose select (or rusage) clause failed to parse was accepted
without that clause: select[type==] or select[mem>] matched every host.
A malformed clause now fails the whole resreq, and parse_resreq() returns
the clause's own message.

A select naming an unregistered resource is still dropped, not an
error: parse_select() reports it as -ENOENT (new select_context_t
.unknown_resource) and the action lets it pass, because jobs rely on it
-- the scheduler's own "type == any" default among them when no "type"
resource is registered (making it fatal failed 36 scheduler suites).

Test: test_resreq_primary_select_error_fails_parse RED before (all
accepted), GREEN after.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-29 10:26:35 +00:00
parent 077b1213d3
commit b5712c053d
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
6 changed files with 117 additions and 9 deletions

View file

@ -2,6 +2,7 @@
%value "char *"
%auxil "resreq_context_t *"
%source {
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -108,7 +109,18 @@ primary_resreq <- < (! ('{' / '}' ) .)* > {
auxil->primary = primary;
free(auxil->errmsg); /* bug-1884: an earlier primary's message */
auxil->errmsg = NULL;
parse_resreq_primary(primary, (char *)$0, auxil->resmgr, &(auxil->errmsg));
/* bug-1887: a primary whose select/rusage is malformed fails the
* whole resreq (it was kept without that clause). A select naming
* an unregistered resource (-ENOENT) is still dropped, as before --
* jobs rely on it, the scheduler's own "type == any" default among
* them when no "type" resource is registered. */
{
int prc = parse_resreq_primary(primary, (char *)$0, auxil->resmgr,
&(auxil->errmsg));
if ((prc < 0) && (prc != -ENOENT)) {
auxil->has_error = 1;
}
}
}
}