Skip to content

Commit

Permalink
datastore: remove arbitrary 1sec timeouts registering scanners
Browse files Browse the repository at this point in the history
just used the caller-supplied context

Signed-off-by: Mark Frost <[email protected]>
  • Loading branch information
frostmar authored and crozzy committed Aug 30, 2023
1 parent 4ac58e7 commit 942834f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions datastore/postgres/registerscanners.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,10 @@ SELECT

var ok bool
var err error
var tctx context.Context
var done context.CancelFunc
for _, v := range vs {
tctx, done = context.WithTimeout(ctx, 5*time.Second)
start := time.Now()
err = s.pool.QueryRow(tctx, exists, v.Name(), v.Version(), v.Kind()).
err = s.pool.QueryRow(ctx, exists, v.Name(), v.Version(), v.Kind()).
Scan(&ok)
done()
if err != nil {
return fmt.Errorf("failed getting id for scanner %q: %w", v.Name(), err)
}
Expand All @@ -77,10 +73,8 @@ SELECT
continue
}

tctx, done = context.WithTimeout(ctx, time.Second)
start = time.Now()
_, err = s.pool.Exec(tctx, insert, v.Name(), v.Version(), v.Kind())
done()
_, err = s.pool.Exec(ctx, insert, v.Name(), v.Version(), v.Kind())
if err != nil {
return fmt.Errorf("failed to insert scanner %q: %w", v.Name(), err)
}
Expand Down

0 comments on commit 942834f

Please sign in to comment.