From 68a442ddacb0974c71630864a4dc1b58fcd03a05 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Tue, 5 Dec 2023 06:41:20 -0700 Subject: [PATCH] improve error logs for prober Signed-off-by: Hector Fernandez --- cmd/prober/write.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/prober/write.go b/cmd/prober/write.go index c17004340..57e7ca916 100644 --- a/cmd/prober/write.go +++ b/cmd/prober/write.go @@ -163,11 +163,14 @@ func rekorWriteEndpoint(ctx context.Context, cert *x509.Certificate, priv *ecdsa defer resp.Body.Close() exportDataToPrometheus(resp, rekorURL, endpoint, POST, latency) + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("invalid status code when checking an entry in rekor: %s", resp.Status) + } // If entry was added successfully, we should verify it var logEntry models.LogEntry err = json.NewDecoder(resp.Body).Decode(&logEntry) if err != nil { - return fmt.Errorf("unmarshal: %w", err) + return fmt.Errorf("error decoding the log entry with body '%v' and error: %w", resp.Body, err) } var logEntryAnon models.LogEntryAnon for _, e := range logEntry {