From 4b9680be8bff15b4a5ea0f0813d01c6e689c4db7 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 7 May 2020 17:03:34 -0700 Subject: [PATCH] Report errors connecting to the database If the postgres collector encounters an error, report it as a failure in the analyzer. Otherwise the error is completely suppressed. Fixes #187. --- pkg/analyze/postgres.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/analyze/postgres.go b/pkg/analyze/postgres.go index 9205f1f5..4cf285c8 100644 --- a/pkg/analyze/postgres.go +++ b/pkg/analyze/postgres.go @@ -39,6 +39,12 @@ func analyzePostgres(analyzer *troubleshootv1beta1.DatabaseAnalyze, getCollected IconURI: "https://troubleshoot.sh/images/analyzer-icons/postgres-analyze.svg", } + if databaseConnection.Error != "" { + result.IsFail = true + result.Message = databaseConnection.Error + return result, nil + } + for _, outcome := range analyzer.Outcomes { if outcome.Fail != nil { if outcome.Fail.When == "" {