Skip to content

Commit

Permalink
remotematcher: Add a realistic deadline for QueryRemoteMatcher call
Browse files Browse the repository at this point in the history
  • Loading branch information
arajkumar committed Jul 16, 2020
1 parent eeb850f commit 26d2bfa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/matcher/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package matcher

import (
"context"
"time"

"github.com/rs/zerolog"

Expand Down Expand Up @@ -49,8 +50,9 @@ func (mc *Controller) Match(ctx context.Context, records []*claircore.IndexRecor
if remoteMatcher {
if err != nil {
log.Error().Err(err).Msg("remote matcher error, returning empty results")
return map[string][]*claircore.Vulnerability{}, nil
}
return map[string][]*claircore.Vulnerability, nil
return matchedVulns, nil
}

dbSide, authoritative := mc.dbFilter()
Expand Down Expand Up @@ -86,7 +88,10 @@ func (mc *Controller) queryRemoteMatcher(ctx context.Context, interested []*clai
if !ok {
return false, nil, nil
}
vulns, err := f.QueryRemoteMatcher(ctx, interested)
// Uses same deadline as postgres batch get op.
tctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
vulns, err := f.QueryRemoteMatcher(tctx, interested)
return true, vulns, err
}

Expand Down

0 comments on commit 26d2bfa

Please sign in to comment.