Skip to content

fix: test endpoints, probe knobs, clearer docs - #27

Merged
donkeyx merged 10 commits into
masterfrom
wip/api-review-and-docs
Aug 10, 2026
Merged

donkeyx merged 10 commits into
masterfrom
wip/api-review-and-docs

Conversation

@donkeyx

@donkeyx donkeyx commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

Readme now says what this is for — drop into an env and poke probes / routing / headers / params (pair with cluster-utils).

What landed

  • clearer purpose docs
  • /version, /status/:code, /delay/:seconds, /echo, /metrics
  • real kube-style probes:
    • /startupz — cold start + latch (sticky started until reset)
    • /livez — liveness (restart on fail)
    • /readyz — readiness (leave endpoints on fail)
    • env seed: LIVE_MODE, READY_MODE, STARTUP_BOOT_DELAY, *_DELAY, …
    • runtime control: GET/PUT /a/control/probes (bearer)
  • sample k8s manifest: startup + live + ready with timeoutSeconds: 1
  • more tests, swagger regen

Test plan

  • go test ./...
  • docker job on the pr
  • optional: deploy sample, flip ready via control API, watch endpoints

Readme now spells out what this is for (drop into an env and poke probes,
routing, headers, params) next to cluster-utils.

Also wired up the bits that were half done or missing:
- /version with real ldflags Version/GitHash
- controllable /health* and /ready* via HEALTHY/READY env or ?ok=0
- /status/:code, /delay/:seconds, /echo
- /metrics actually registered + request counter middleware
- AUTH_TOKEN env for a fixed bearer token
- more tests, swagger regen, k8s readinessProbe
Probes now follow kube roles properly:
- /startupz latches after cold start (STARTUP_BOOT_DELAY), sticky until reset
- /livez and /readyz use mode+delay (env seed or PUT /a/control/probes)
- fail = 503, delaySeconds can trip short probe timeouts
- sample manifest uses startup/live/ready with timeoutSeconds: 1

Also kept /healthz /ready aliases and documented the whole thing.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

mode=flap alternates ok/fail either on a wall-clock half-period
(flapSeconds, default 5) or every Nth request (flapEvery). Control
API reports current phase; README + k8s examples updated.
Spell out how to get the bearer (AUTH_TOKEN, docker/kubectl logs, swagger)
and add practical curl recipes for ingress, env dumps, probes, flap,
timeouts, cold start, and in-cluster use. Startup logs are a bit more
greppable for the token too.
Drop hardcoded localhost host so Try it out follows wherever you open
the UI (docker/port-forward/ingress). Optional ?host=&scheme= override.
PersistAuthorization so the Authorize token sticks in the browser.
Match utils vibe a bit with the donkey header. Raise delay cap
(MAX_DELAY_SECONDS, default 120). Add GET/POST /proxy so north-south
can trigger east-west calls with header passthrough for mesh testing.
Comment thread handlers/proxy.go

client := &http.Client{Timeout: time.Duration(timeout * float64(time.Second))}
start := time.Now()
resp, err := client.Do(outReq)
Proxy is SSRF if public — moved under /a/ with bearer like /env.
Do not auto-forward Authorization/Cookie east-west unless opted in.
README spells out the JSON wrap (upstream status/headers/body) and
which endpoints stay open for kube vs what must stay locked.
- rename module to github.com/donkeyx/cluster-utils-api
- bump gin, prometheus, zap, swag, testify and related to current latest
- proper HTTP metrics middleware (count, duration, in-flight) + Go/process
  collectors on a dedicated registry (OpenMetrics scrape)
- pin swag CLI, make swagger/update targets; Dockerfile mod download cache
@donkeyx
donkeyx merged commit a60d297 into master Aug 10, 2026
2 of 3 checks passed
@donkeyx
donkeyx deleted the wip/api-review-and-docs branch August 10, 2026 11:17

This branch was previously deployed

1 inactive deployment
ci — 5b43d39f Deployed Aug 10, 2026 by donkeyx via docker #53
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.

2 participants