Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion server/grpc/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func createFilterFunc(agentFilter rpc.Filter) queue.FilterFn {
// all task labels are required to be present for an agent to match
agentLabelValue, ok := agentFilter.Labels[taskLabel]
if !ok {
return false, 0
// Check for required label
agentLabelValue, ok = agentFilter.Labels["!"+taskLabel]
if !ok {
return false, 0
}
}

switch agentLabelValue {
Expand Down
11 changes: 11 additions & 0 deletions server/grpc/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ func TestCreateFilterFunc(t *testing.T) {
wantMatched: true,
wantScore: 2,
},
{
name: "Required label matches without shebang",
agentFilter: rpc.Filter{
Labels: map[string]string{"!org-id": "123", "platform": "linux", "extra": "value"},
},
task: &model.Task{
Labels: map[string]string{"org-id": "123", "platform": "linux", "empty": ""},
},
wantMatched: true,
wantScore: 20,
},
}

for _, tt := range tests {
Expand Down