Skip to content
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
9 changes: 8 additions & 1 deletion internal/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -221,7 +223,12 @@ func (a *Agent) registerServer(ctx context.Context) error {
}()

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afritzler do we want to retry on all errors? 401 or 403 for example won't fix themselves

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I would keep it simple for now. But you are are of course right.

a.log.Error(err, "Failed to register server", "url", a.RegistryURL)
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1024))
if readErr != nil {
a.log.Error(fmt.Errorf("HTTP %d: failed to read response body: %w", resp.StatusCode, readErr), "Failed to register server", "url", a.RegistryURL)
return false, nil
}
a.log.Error(fmt.Errorf("HTTP %d: %s", resp.StatusCode, string(body)), "Failed to register server", "url", a.RegistryURL)
return false, nil
}

Expand Down
Loading