Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve error logs for prober #886

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading