Skip to content

Commit

Permalink
chore: improve error logs for prober (#886)
Browse files Browse the repository at this point in the history
* improve error logs for prober

Signed-off-by: Hector Fernandez <[email protected]>

* address reviewer comments

Signed-off-by: Hector Fernandez <[email protected]>

---------

Signed-off-by: Hector Fernandez <[email protected]>
  • Loading branch information
hectorj2f authored Dec 5, 2023
1 parent 7e15745 commit f2b97f5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/prober/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,16 @@ func rekorWriteEndpoint(ctx context.Context, cert *x509.Certificate, priv *ecdsa
defer resp.Body.Close()
exportDataToPrometheus(resp, rekorURL, endpoint, POST, latency)

if resp.StatusCode != http.StatusCreated {
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("invalid status code '%s' when checking an entry in rekor with body '%s'", resp.Status, string(body))
}
// 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)
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("error decoding the log entry with body '%s' and error: %w", string(body), err)
}
var logEntryAnon models.LogEntryAnon
for _, e := range logEntry {
Expand Down

0 comments on commit f2b97f5

Please sign in to comment.