Skip to content

Commit

Permalink
Let's log stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
epapbak committed Jun 24, 2024
1 parent 0b0bb32 commit ac42768
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion consumer/ocp_rules_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ func TestParseProperMessageWithInfoReport(t *testing.T) {
"links": {}
}
]
}`
message := sarama.ConsumerMessage{Value: []byte(createConsumerMessage(consumerReport))}
parsed, err := consumer.ParseMessage(&ocpConsumer, &message)
Expand Down
12 changes: 10 additions & 2 deletions storage/ocp_recommendations_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,21 @@ func (storage OCPRecommendationsDBStorage) WriteRecommendationsForCluster(
// Delete current recommendations for the cluster if some report has been previously stored for this cluster
if _, ok := storage.clustersLastChecked[clusterName]; ok {
// Get impacted_since if present
query := "SELECT rule_fqdn, error_key, impacted_since FROM recommendation WHERE org_id = $1 AND cluster_id = $2 LIMIT 1;"
query := "SELECT rule_fqdn, error_key, impacted_since FROM recommendation WHERE org_id = $1 AND cluster_id = $2;"
impactedSinceMap, err = storage.getRuleKeyCreatedAtMap(
query, orgID, clusterName)
if err != nil {
log.Error().Err(err).Msgf("Unable to get recommendation impacted_since")
}

log.Info().Any("impactedSinceMap", impactedSinceMap).Msg("Impacted since map without limit")
// Get impacted_since if present
query = "SELECT rule_fqdn, error_key, impacted_since FROM recommendation WHERE org_id = $1 AND cluster_id = $2 LIMIT 1;"
impactedSinceMap, err = storage.getRuleKeyCreatedAtMap(
query, orgID, clusterName)
if err != nil {
log.Error().Err(err).Msgf("Unable to get recommendation impacted_since")
}
log.Info().Any("impactedSinceMap", impactedSinceMap).Msg("Impacted since map with limit")
// it is needed to use `org_id = $1` condition there
// because it allows DB to use proper btree indexing
// and not slow sequential scan
Expand Down

0 comments on commit ac42768

Please sign in to comment.