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

Add status.json endpoint to health check endpoints #2759

Merged
merged 1 commit into from
May 2, 2024

Conversation

moskyb
Copy link
Contributor

@moskyb moskyb commented Apr 30, 2024

Description

This PR adds a new endpoint to the healthcheck server, /status.json. the idea is that this endpoint will be a very cut-down version of the information available at /status, but in a format (JSON) that's easily machine-readable.

A sample of this output is:

{
  "health": "ok",
  "aggregate_status": "busy", # One of the workers below is busy, so the "aggregate status" of the agent is busy
  "worker_statuses": [
    {
      "status": "idle",
      "id": "018f2d68-1d0c-42cd-be6c-c1a89bda6453",
      "spawn_index": 1
    },
    {
      "status": "idle",
      "id": "018f2d68-1e33-4f09-ae1e-8b962f4e4e77",
      "spawn_index": 2
    },
    {
      "status": "busy",
      "current_job_id": "018f2d68-5e54-4255-a99e-829aa4691dc1", # only busy agents have a current job ID
      "id": "018f2d68-1f57-4374-9dbe-ec033f915c75",
      "spawn_index": 3
    },
    {
      "status": "idle",
      "id": "018f2d68-2080-4eaf-a33d-e1c3d0521206",
      "spawn_index": 4
    }
  ]
}

This PR also refactors the healthcheck server to be fully owned by the AgentPool, and replaces the use of the default mux (used when http.HandleFunc is called) with a dedicated mux for just the healthcheck server.

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

agent/agent_pool.go Outdated Show resolved Hide resolved
Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

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

Looks pretty good

agent/agent_pool.go Outdated Show resolved Hide resolved
agent/agent_pool.go Outdated Show resolved Hide resolved
This will show a summary of what the agent and its workers are up to - if they're working on jobs, etc
Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

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

🥒

@moskyb moskyb merged commit f19f1f0 into main May 2, 2024
1 check passed
@moskyb moskyb deleted the machine-readable-status branch May 2, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants