Skip to content

Commit 58cf56a

Browse files
committed
Improve logging for error processing source
1 parent 1f86512 commit 58cf56a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Diff for: pkg/processor/processor.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ func (p *CheckProcessor) ProcessMessage(m string) error {
148148
l.Debugf("Processing source with %d source findings: %#v", len(sourceFindings), source)
149149
source, err = p.store.ProcessSourceExecution(source, sourceFindings)
150150
if err != nil {
151-
l.Errorf("Error while processing source: %#v", err)
152-
if !store.IsDuplicateErr(err) {
153-
return err
151+
if store.IsDuplicateErr(err) {
152+
l.Warnf("duplicated source: %#v", err)
153+
return nil
154154
}
155+
return err
155156
}
156157

157158
l.Debug("Sending open findings")

Diff for: pkg/store/sources.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (db *psqlxStore) lockTxBySources(tx *sqlx.Tx, sff SourceFamilies) error {
271271
}
272272

273273
func createSource(ctx context.Context, tx *sqlx.Tx, s Source) (*Source, error) {
274-
r := tx.QueryRowxContext(ctx, `INSERT INTO sources (name, component, instance, options, time, target_id)
274+
r := tx.QueryRowxContext(ctx, `INSERT INTO sources (name, component, instance, options, time, target_id)
275275
VALUES ($1, $2, $3, $4, $5, $6) RETURNING *`, s.Name, s.Component, s.Instance, s.Options, s.Time, s.Target)
276276
err := r.StructScan(&s)
277277
if err != nil {
@@ -284,11 +284,11 @@ func createSourceIfNotExists(ctx context.Context, tx *sqlx.Tx, s Source) (*Sourc
284284
var err error
285285
q := `
286286
WITH q as (
287-
SELECT * FROM sources
287+
SELECT * FROM sources
288288
WHERE name=$1 AND component=$2 AND instance=$3 AND options=$4
289-
),
289+
),
290290
c AS (
291-
INSERT INTO sources (name, component, instance, options, time, target_id)
291+
INSERT INTO sources (name, component, instance, options, time, target_id)
292292
SELECT $1, $2, $3, $4, $5, $6
293293
WHERE NOT EXISTS (SELECT 1 FROM q)
294294
RETURNING *

0 commit comments

Comments
 (0)