Skip to content

Commit

Permalink
broker: check type of [queues] table
Browse files Browse the repository at this point in the history
Problem: a malformed queues config such as queues=42 is
allowed by the broker policy/queues config validator.

Check that queues is a table.
Add test to t2241-policy-config.t.

Drop t2112-job-ingest-frobnicator.t test that expects that to get
through the broker and fail in the frobnicator.
  • Loading branch information
garlick committed Sep 20, 2022
1 parent 0fd1b0b commit ad7525b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/broker/brokercfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ static int validate_queues_config (flux_conf_t *conf, flux_error_t *error)
const char *name;
json_t *entry;

if (!json_is_object (queues)) {
errprintf (error, "queues must be a table");
goto inval;
}
json_object_foreach (queues, name, entry) {
json_error_t jerror;
json_t *policy = NULL;
Expand Down
13 changes: 0 additions & 13 deletions t/t2112-job-ingest-frobnicator.t
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,6 @@ test_expect_success 'job-frobnicator errors on a missing queue config' '
>bad1.out 2>&1 &&
grep "default queue.*debug.*must be in" bad1.out
'
test_expect_success 'job-frobnicator errors on an invalid queue config' '
cat <<-EOF >conf.d/conf.toml &&
queues = 42
[policy.jobspec.defaults.system]
queue = "debug"
EOF
flux config reload &&
flux mini run --env=-* --dry-run hostname \
| test_expect_code 1 \
flux job-frobnicator --jobspec-only --plugins=defaults \
>bad2.out 2>&1 &&
grep "queues must be a table" bad2.out
'
test_expect_success 'configure queue constraints' '
cat <<-EOF >conf.d/conf.toml &&
[queues.debug]
Expand Down
6 changes: 6 additions & 0 deletions t/t2241-policy-config.t
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ test_expect_success 'well formed policy.access works' '
EOT
flux config reload
'
test_expect_success 'malformed queues table fails' '
cat >config/policy.toml <<-EOT &&
queues = 1
EOT
test_must_fail flux config reload
'
test_expect_success 'unknown queues.NAME.policy.foo key fails' '
cat >config/policy.toml <<-EOT &&
queues.x.policy.foo = 1
Expand Down

0 comments on commit ad7525b

Please sign in to comment.