Skip to content

Commit

Permalink
RHINENG-9452: add fatal errors for evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Aug 16, 2024
1 parent 9571534 commit a9cf180
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions evaluator/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func evaluateInDatabase(ctx context.Context, event *mqueue.PlatformEvent, invent

thirdParty, err := analyzeRepos(system)
if err != nil {
return nil, nil, errors.Wrap(err, "Repo analysis failed")
return nil, nil, errors.Wrap(err, "repo analysis failed")
}
system.ThirdParty = thirdParty // to set "system_platform.third_party" column

Expand Down Expand Up @@ -414,7 +414,7 @@ func tryGetSystem(accountID int, inventoryID string,
system, err := loadSystemData(accountID, inventoryID)
if err != nil {
evaluationCnt.WithLabelValues("error-db-read-inventory-data").Inc()
return nil, errors.Wrap(err, "error loading system from DB")
return nil, base.WrapFatalDBError(err, "error loading system from DB")
}
if system.ID == 0 {
evaluationCnt.WithLabelValues("error-db-read-inventory-data").Inc()
Expand Down Expand Up @@ -496,7 +496,7 @@ func evaluateAndStore(system *models.SystemPlatform,
err = commitWithObserve(tx)
if err != nil {
evaluationCnt.WithLabelValues("error-database-commit").Inc()
return errors.New("database commit failed")
return base.WrapFatalDBError(err, "database commit failed")
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion evaluator/evaluate_baseline.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package evaluator

import (
"app/base"
"app/base/database"
"app/base/models"
"app/base/vmaas"
Expand All @@ -24,7 +25,7 @@ func limitVmaasToBaseline(system *models.SystemPlatform, vmaasData *vmaas.Update
Where("public_date >= ?", baselineConfig.ToTime.Truncate(24*time.Hour)).
Pluck("name", &filterOutNames).Error
if err != nil {
return err
return base.WrapFatalDBError(err, "load reported advisories")
}

// create map of advisories we need to filter out
Expand Down
5 changes: 3 additions & 2 deletions evaluator/remediations.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func publishRemediationsState(system *models.SystemPlatform, response *vmaas.Upd
state := createRemediationsStateMsg(system.InventoryID, response)
msg, err := mqueue.MessageFromJSON(system.InventoryID, state)
if err != nil {
return errors.Wrap(err, "Formatting message")
return errors.Wrap(err, "formatting message")
}
return remediationsPublisher.WriteMessages(base.Context, msg)
err = remediationsPublisher.WriteMessages(base.Context, msg)
return base.WrapFatalKafkaError(err, "write message")
}

0 comments on commit a9cf180

Please sign in to comment.