Skip to content

Nit: Use /ping for daemon ready check instead of /version#414

Open
inFocus7 wants to merge 1 commit intoagentregistry-dev:mainfrom
inFocus7:infocus7/nit-daemon-ping-fix
Open

Nit: Use /ping for daemon ready check instead of /version#414
inFocus7 wants to merge 1 commit intoagentregistry-dev:mainfrom
inFocus7:infocus7/nit-daemon-ping-fix

Conversation

@inFocus7
Copy link
Copy Markdown
Collaborator

@inFocus7 inFocus7 commented Apr 2, 2026

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

NONE

Additional Notes

Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the daemon readiness/response checks used by the CLI to call the public /ping endpoint (instead of /version), avoiding confusing version requests and preventing unnecessary auth failures during readiness polling.

Changes:

  • Switch daemon “is responding” checks from GET /version to GET /ping.
  • Tighten readiness success criteria to require HTTP 200 OK (instead of any 2xx) for /ping.
Comments suppressed due to low confidence (1)

pkg/daemon/health.go:26

  • defer resp.Body.Close() is inside a retry loop. If the first request returns a non-200 status, the body won’t be closed until IsResponding returns, and multiple open bodies can accumulate across retries. Close (and ideally drain) the response body immediately within each iteration before continuing/retrying, reserving defer for non-loop scopes.
	for i := range maxRetries {
		resp, err := httpClient.Get(pingURL)
		if err == nil {
			defer resp.Body.Close()
			if resp.StatusCode == http.StatusOK {
				return true
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 41 to 46
for time.Now().Before(deadline) {
resp, err := httpClient.Get(pingURL)
if err == nil {
resp.Body.Close()
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
if resp.StatusCode == http.StatusOK {
return nil
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

WaitForReady closes the response body without reading it. In Go’s HTTP client, not draining the body can prevent connection reuse and lead to repeated TCP connections during the polling loop. Consider discarding the body content (e.g., read to EOF) before closing to improve efficiency.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants