From ac427686c7f59b8c3f4eaa2716cc8a8025f37a33 Mon Sep 17 00:00:00 2001 From: Papa Bakary Camara Date: Mon, 24 Jun 2024 02:27:52 +0200 Subject: [PATCH] Let's log stuff --- consumer/ocp_rules_consumer_test.go | 1 - storage/ocp_recommendations_storage.go | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/consumer/ocp_rules_consumer_test.go b/consumer/ocp_rules_consumer_test.go index 9836b3a49..e3290b14b 100644 --- a/consumer/ocp_rules_consumer_test.go +++ b/consumer/ocp_rules_consumer_test.go @@ -504,7 +504,6 @@ func TestParseProperMessageWithInfoReport(t *testing.T) { "links": {} } ] - }` message := sarama.ConsumerMessage{Value: []byte(createConsumerMessage(consumerReport))} parsed, err := consumer.ParseMessage(&ocpConsumer, &message) diff --git a/storage/ocp_recommendations_storage.go b/storage/ocp_recommendations_storage.go index d994ac24a..1d41ce33e 100644 --- a/storage/ocp_recommendations_storage.go +++ b/storage/ocp_recommendations_storage.go @@ -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