Skip to content

Commit 4f1f7de

Browse files
fix[agent-manager](collectors): fixed collector list tenant filtering (#2498)
1 parent 130f903 commit 4f1f7de

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

agent-manager/agent/collector_imp.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,16 @@ func (s *CollectorService) ListCollector(ctx context.Context, req *ListRequest)
250250

251251
// Scoped by the caller: the panel asks for one tenant, and only the
252252
// platform asks for all of them.
253-
where := ""
254253
if req.GetTenantId() != "" {
255-
where = fmt.Sprintf("tenant_id = '%s'", sanitizeTenant(req.GetTenantId()))
254+
filter = append(filter, utils.Filter{
255+
Field: "tenant_id",
256+
Op: utils.Is,
257+
Value:sanitizeTenant(req.GetTenantId()),
258+
})
256259
}
257260

258261
collectors := []models.Collector{}
259-
total, err := s.DBConnection.GetByPagination(&collectors, page, filter, where, false)
262+
total, err := s.DBConnection.GetByPagination(&collectors, page, filter, "", false)
260263
if err != nil {
261264
catcher.Error("failed to fetch collectors", err, map[string]any{"process": "agent-manager"})
262265
return nil, status.Errorf(codes.Internal, "failed to fetch collectors: %v", err)

0 commit comments

Comments
 (0)