Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Turns the probe from a config check into the actual probe loop. After validating config,
python -m probenow keeps doing this:POST /functions/v1/probe-check-inwithprobe_idandX-Probe-Token.run.shandtest.jsonfrom the signed paths (appended toBACKEND_URL) and check each against its sha256. If either doesn't match, nothing runs.bash run.shfrom a temp dir with a 30s deadline and read the one JSON object it prints.POST /functions/v1/probe-measurementswith the record, using thetest_revision_idthat actually ran and a freshuuid4run ID.{"assignment":null}, wait 30s and try again.The upload finishes before the next check-in, so an assignment change takes effect on the next pass.
How results are reported:
{"result_data": {...}}iscompleted. That includes 100% loss withrtt_avg_ms: null.failed, with the exit code and emptyresult_data.timeout. The whole process group gets killed, sopingdoesn't keep running, andresult_codeisnull.Script stderr goes to the probe's own logs.
Token handling:
X-Probe-Tokenis only sent on check-in and upload. It's left off the downloads,PROBE_TOKENis stripped from the script's environment, and it never shows up in logs or error messages.Errors: any non-2xx response, network error, malformed response, or hash mismatch stops the probe with a short message and exit code 1.
Shutdown: SIGTERM and Ctrl-C let the current pass finish, upload included, then exit 0. I set
stop_grace_period: 1mincompose.yamlso Docker doesn't kill a pass partway through.No new dependencies; it's all stdlib.
Files:
probe/src/probe/runner.py: new, the loop itself.probe/src/probe/__main__.py: starts the loop after config validation, plus signal handling.probe/tests/test_runner.py: new tests against a fake HTTP backend.probe/compose.yaml,probe/README.md,AGENTS.md: stop grace period and docs.Status codes: this matches what #9 (check-in) and #10 (measurements) currently return. The probe treats any 2xx as success and anything else as a stop.
Related issue
Closes #2
Testing
From
probe/:uv run --locked --extra test python -m pytest: 16 passed. The new tests use a fake backend and a fixed-output script. They cover:docker compose --env-file .env.example config --quiet: OK.Docker check with the real Ping script: I built the image and ran it against a small local fake backend that served the real
ping/run.shandping/test.json. Their sha256s matched the ones in the issue (9552c9a3…,b478fc86…).completed:dddddddd…, run3afc8f3a…: 24.69 ms, 0% losseeeeeeee…, run3c63d797…: 16.57 ms, 0% lossnulland nothing ran.X-Probe-Tokenheader.download …/run.sh failed its hash check, exit code 1. It never ran the script and nothing was uploaded.docker stopduring the idle wait: exit 0 in under a second.docker stopmid-ping: the run finished and uploaded, there was no further check-in, exit 0 in about 3s.Checklist