fix(apiserver): job_status notnull filter matches every job (bug-1504)
`xcecli jobs list -a` returned "no job found" even when jobs existed. FilterRows routes every condition on a bitmask field (job_status / host_status) to MatchesBitmaskCondition, which only implemented OpEQ/OpNE bitmask semantics — the `-a` filter compiles to `job_status notnull` (OpNOTNULL), which fell through to `return false` and filtered out every job. (The default list's `notin(EXIT,DONE)` is compiled to OpEQ(mask), so it was unaffected.) Add OpISNULL/OpNOTNULL branches to MatchesBitmaskCondition that test the raw field value. New query_test.go: 3 regression tests (notnull matches all, null matches none, bitmask notin path unaffected), RED->GREEN. Verified live: `xcecli jobs list -a` now lists all jobs including DONE. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
60ebf4af72
commit
c630809116
4 changed files with 116 additions and 1 deletions
|
|
@ -78,8 +78,18 @@ func MatchesCondition(row utils.OrderMap, cond utils.Condition) bool {
|
|||
// MatchesBitmaskCondition handles bitmask fields (job_status, host_status).
|
||||
// For bitmask EQ: (val & mask) != 0 means the status is set.
|
||||
// For bitmask NE: (val & mask) == 0 means the status is NOT set.
|
||||
// null/notnull are handled on the raw field value (bug-1504: job_status
|
||||
// notnull previously fell through to `return false`, so `jobs list -a`
|
||||
// filtered out every job).
|
||||
func MatchesBitmaskCondition(row utils.OrderMap, field string, bitmask int64, op utils.OperatorType) bool {
|
||||
val := toInt64(row.Data[field])
|
||||
fieldVal := row.Data[field]
|
||||
switch op {
|
||||
case utils.OpISNULL:
|
||||
return fieldVal == nil
|
||||
case utils.OpNOTNULL:
|
||||
return fieldVal != nil
|
||||
}
|
||||
val := toInt64(fieldVal)
|
||||
result := val & bitmask
|
||||
switch op {
|
||||
case utils.OpNE: // bitmask "eq" is stored as OpNE (val & mask != 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue