Skip to content

Commit a306a2c

Browse files
authored
Nit: Use /ping for daemon ready check instead of /version (#414)
# Description When using CLI, i noticed random calls to `/version` when using it which was confusing (i'd only expect it to be called if I'm trying to see the version). Since `/version` is not a "public path" (not in our list of paths to avoid doing AuthN checks), there are also 3 lines of "unauthenticated -> /v0/version" fails each CLI call. We could add `/version` as a public path if we don't believe having build/run info public is an issue, but at the core level if we're checking for a response, we should be hitting between `/ping` or `/health`. I chose `/ping` since this is doing a response check not actual health checks per daemon-call. **Changes** - Use `/ping` for response checks - Check for HTTP `200` specifically for OK-ness. Huma defaults to a 200 code on responses with a body (which the /ping endpoint provides.) # Change Type ``` /kind cleanup ``` # Changelog ```release-note NONE ``` # Additional Notes Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
1 parent 89dc215 commit a306a2c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/daemon/health.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ type HealthChecker struct {
1414
// IsResponding checks if the server is responding
1515
func (h *HealthChecker) IsResponding() bool {
1616
httpClient := &http.Client{Timeout: 2 * time.Second}
17-
versionURL := strings.TrimRight(h.BaseURL, "/") + "/version"
17+
pingURL := strings.TrimRight(h.BaseURL, "/") + "/ping"
1818

1919
const maxRetries = 3
2020
for i := range maxRetries {
21-
resp, err := httpClient.Get(versionURL)
21+
resp, err := httpClient.Get(pingURL)
2222
if err == nil {
2323
defer resp.Body.Close()
2424
if resp.StatusCode == http.StatusOK {
@@ -42,7 +42,7 @@ func (h *HealthChecker) WaitForReady(timeout time.Duration) error {
4242
resp, err := httpClient.Get(pingURL)
4343
if err == nil {
4444
resp.Body.Close()
45-
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
45+
if resp.StatusCode == http.StatusOK {
4646
return nil
4747
}
4848
}

0 commit comments

Comments
 (0)