brbzull0 opened a new pull request, #13732:
URL: https://github.com/apache/trafficserver/pull/13732
## What
`traffic_ctl hostdb status <hostname>` lists every partition that holds
entries. A partition whose
entries are all excluded by the hostname filter was emitted as a bare
`{"id": N}`, with no `records`
key: `records` was only created as a side effect of `push_back` inside the
record loop. With the
default 64 partitions, a single-hostname query can return up to 63 such
stubs next to the real
match, and a consumer iterating `partitions[].records` fails on them.
Filtering to a name that matches nothing, before:
```json
"partitions": [{"id": "34"}, {"id": "42"}]
```
## Fix
Construct `records` as an empty sequence before the loop, the way #13609
constructs `partitions`,
so every listed partition carries the array:
```json
"partitions": [{"id": "34", "records": []}, {"id": "42", "records": []}]
```
The unfiltered output is unchanged. The alternative, dropping the partitions
the filter empties, is
discussed in #13710; it would make the list of partitions depend on the
filter.
## Testing
New autest `traffic_ctl_hostdb_status_filter`. It populates HostDB through
DNS (microDNS and Proxy
Verifier), then queries `get_hostdb_status` and `traffic_ctl hostdb status`,
with and without a
filter, against two ATS processes: one with the default 64 partitions, and
one with a single
partition that both names share. Each filtered answer has to list the same
partitions as the
unfiltered one, each holding exactly its records that match the filter.
- Without the fix, 6 of the test's 11 runs fail with `partition carries no
records array`.
- `ctest`: 1103/1103.
- `traffic_ctl/*` and `jsonrpc/*` autests: 26 of 27 pass.
`basic_plugin_handler` fails the same way
on unmodified master on macOS.
Fixes: #13710
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]