Deterministic HTTP chaos for testing uptime monitors and retry logic
  • Go 75.9%
  • HTML 12.4%
  • Nix 6.6%
  • CSS 3.5%
  • Go Template 1.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mikhail Lukianchenko 5e6f737218
Build the chart and the release set with nix (#2)
## Summary

```diff
 packages
+  chart     helm package, version from VERSION, in the sandbox
+  release   linkFarm: image-amd64, image-arm64, chart.tgz
 checks
+  chart     helm lint --strict, helm template
```

```diff
 publish:
-  nix build --out-link image .#image-amd64 .#image-arm64
-  nix develop --command helm package charts/flakybin --version ... --destination $RUNNER_TEMP/chart
+  nix build .#release
```

## Evidence

- `nix build .#release` → `result/{image-amd64,image-arm64,chart.tgz}`; the chart says version and appVersion 0.6.0.
- `checks.chart` passes; `helm push result/chart.tgz` reads the chart as `flakybin` whatever the file is called.

## Merge Danger

**Door:** two-way

**Blast Radius:** release

The next release is the first to push the chart built by nix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: #2
2026-11-28 09:09:31 +00:00
.forgejo Build the chart and the release set with nix (#2) 2026-11-28 09:09:31 +00:00
.github/workflows Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
charts/flakybin Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
static Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
.gitignore Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
.golangci.yaml Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
assets.go flakybin: deterministic intermittently-failing HTTP server 2026-06-05 18:07:56 +03:00
CHANGELOG.md release: 0.6.0 2026-11-25 21:39:18 +00:00
crawl_test.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
diceroll_test.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
flake.lock Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
flake.nix Build the chart and the release set with nix (#2) 2026-11-28 09:09:31 +00:00
go.mod Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
handlers.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
inspect_test.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
LICENSE docs: prepare for public release — MIT license, canonical module, badges 2026-06-05 20:16:02 +03:00
log.go feat: /healthz probe endpoint (204), excluded from access log 2026-06-05 19:34:37 +03:00
log_test.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
main.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
params.go feat: even mode (uniformly spaced outages), now the default 2026-06-05 20:58:56 +03:00
README.md Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
render.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
render_test.go Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
schedule.go fix: even mode keeps spacing across period boundaries 2026-06-07 16:11:25 +03:00
schedule_test.go fix: even mode keeps spacing across period boundaries 2026-06-07 16:11:25 +03:00
Taskfile.yaml Make flakybin the nix reference repository (#1) 2026-11-25 21:37:25 +00:00
VERSION release: 0.6.0 2026-11-25 21:39:18 +00:00

flakybin

GitHub License GitHub Release Go Version GitHub Stars

Deterministic HTTP chaos for testing uptime monitors and retry logic.

The source is at sarak.sh/mikluko/flakybin; github.com/mikluko/flakybin mirrors it.

flakybin is a fault-injection server that fails on a deterministic, seed-reproducible schedule: it returns errors, hangs, and drops connections during scheduled outage windows, emulating a service that goes down on a repeating cycle.

Outage placement is computed purely from the request URL. The same parameters always yield the same outage windows on the wall clock, across restarts and across machines. No state, no database.

Run

go run .            # listens on :8080 (override with -addr or PORT)
PORT=9000 go run .

go install sarak.sh/mikluko/flakybin@latest   # or install the binary

Then open http://localhost:8080/ for the interactive schedule explorer, or http://localhost:8080/docs for the full reference.

Modes

The first path segment selects how outages are placed within each period.

  • even (default) — count outages of length duration spaced uniformly across the period (one per period/count interval); the seed shifts the whole pattern's phase. No divisibility constraint; regular and predictable.
  • jitter — count outages of length duration are dropped at seed-hashed offsets anywhere within the period. No divisibility constraint; looks like organic flapping.
  • noise — the period is divided into N = period/duration fixed slots; count of them are outages. period must divide evenly by duration. Grid-aligned.

Common parameters

param meaning
period length of one repeating cycle, e.g. 24h, 1h, 10m (default 24h)
duration length of a single outage, e.g. 5m (default 15m)
count number of outages per period — supply this or uptime (not both)
uptime target availability percent, e.g. 99.9; converted to a count. Defaults to 90 when neither count nor uptime is given. 100 → 400
seed RNG seed (default 0); change to reshuffle placement

Endpoints

route during an outage
GET /{mode}/status/{code} responds with HTTP {code}; 200 when up. Optional retry-after=auto or retry-after=<seconds> sets Retry-After.
GET /{mode}/hang withholds the response until the outage ends, or for for=<duration>. Emulates a timeout.
GET /{mode}/drop writes after=<bytes> of body (default 0) then resets the TCP connection.
GET /{mode}/inspect shows the schedule and its outage windows. Browsers get a graphical timeline, scripts get JSON (override with ?format=html/?format=json). The JSON includes a failure_links block with ready-to-call URLs for every status code plus hang and drop. Triggers no failure.

Examples

# Even (default): ~99% availability over a 24h period, evenly spaced, 503 + Retry-After.
curl -i 'localhost:8080/even/status/503?period=24h&duration=5m&uptime=99&retry-after=auto'

# Ten 1-minute blips scattered through each hour, seed 42.
curl -i 'localhost:8080/jitter/hang?period=1h&duration=1m&count=10&seed=42'

# Noise: 24h period, 5m slots, 12 down (~99.58% uptime).
curl -i 'localhost:8080/noise/status/503?period=24h&duration=5m&count=12&retry-after=auto'

# Noise, first 10 minutes of every hour are down.
curl -i 'localhost:8080/noise/status/500?period=1h&duration=10m&count=1'

# Inspect the schedule without triggering it.
curl -s 'localhost:8080/jitter/inspect?period=24h&duration=5m&uptime=99'

Response headers

Every response advertises the resolved schedule and current state via X-Flaky-* headers: Mode, Period, Duration, Count, Seed, Uptime, In-Outage, and either Outage-Ends or Next-Outage (RFC 3339).

Develop

The flake carries the toolchain and the build; nix develop enters a shell with Go, golangci-lint, task, crane and helm.

task test           # go test -race
task lint           # golangci-lint
task check          # both, in the nix sandbox, as CI runs them
nix build .#image-amd64   # or .#image-arm64: a script that streams the image

Release

A pull request with a notable change adds its note as a fragment in .changelog/. Running the Release workflow on main releases the version the fragments call for: it folds them into CHANGELOG.md, commits that with VERSION to main, and publishes the image sarak.sh/mikluko/flakybin:<version>, the chart oci://sarak.sh/mikluko/charts/flakybin and the tag v<version>.

With prerelease ticked it publishes <version>-pre.N from main as it stands instead, and commits nothing.

Deploy

Install from the OCI chart (or the local charts/flakybin path):

helm install flakybin oci://sarak.sh/mikluko/charts/flakybin --version 0.6.0 \
  --set ingress.enabled=true \
  --set ingress.hosts[0].host=flakybin.example.com

The container listens on :8080, runs as non-root with a read-only root filesystem, and uses GET / for liveness/readiness. Set flakybin.quiet=true to disable per-request access logging. See charts/flakybin/values.yaml for all options.