diff --git a/server/grpc/filter.go b/server/grpc/filter.go index ba806ba1f29..177499abe2d 100644 --- a/server/grpc/filter.go +++ b/server/grpc/filter.go @@ -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 { diff --git a/server/grpc/filter_test.go b/server/grpc/filter_test.go index 781f59e3cb4..4a4b01f7934 100644 --- a/server/grpc/filter_test.go +++ b/server/grpc/filter_test.go @@ -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 {