Description
In internal/probe/probe.go, the registerServer function logs a nil err when the HTTP registration response has a non-OK status code.
When c.Do(req) succeeds (i.e., a response is received), err is nil. However, if resp.StatusCode is neither http.StatusOK nor http.StatusCreated, the current code calls:
a.log.Error(err, "Failed to register server", "url", a.RegistryURL)
Since err is nil here, the log entry loses all meaningful failure context (status code, response body, etc.).
Expected Behavior
The log should include a concrete error describing the failure, e.g. the HTTP status code and/or response body, so operators can diagnose registration failures.
Suggested Fix
bodyBytes, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
a.log.Error(
fmt.Errorf("unexpected response status: %d", resp.StatusCode),
"Failed to register server",
"url", a.RegistryURL,
"statusCode", resp.StatusCode,
"responseBody", string(bodyBytes),
)
return false, nil
}
References
/cc @afritzler
Description
In
internal/probe/probe.go, theregisterServerfunction logs a nilerrwhen the HTTP registration response has a non-OK status code.When
c.Do(req)succeeds (i.e., a response is received),errisnil. However, ifresp.StatusCodeis neitherhttp.StatusOKnorhttp.StatusCreated, the current code calls:Since
errisnilhere, the log entry loses all meaningful failure context (status code, response body, etc.).Expected Behavior
The log should include a concrete error describing the failure, e.g. the HTTP status code and/or response body, so operators can diagnose registration failures.
Suggested Fix
References
/cc @afritzler