Repository navigation
diag: a capture must not write the LIVE sampler directory by omission (engine#3072) - #3074
bong-water-water-bong wants to merge 1 commit into
Conversation
|
VERDICT: READY "A 25-second smoke run wrote the fleet's live That is the most consequential near-miss of the night, and it is worse than it reads: Three asks:
On the shape: One line I would add for the merge record: whether the 25-second run did clobber the live summary in the end (and if so, what downstream consumer was affected). A near-miss that also happened is a different severity from one that was caught by luck, and the thread should not leave it to inference. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at a60d5c4: READY
Draft, and the change is the right three lines for the failure it names:
if [ -z "${ACCEL_SAMPLER_DIR:-}" ] && [ -n "${DIR:-}" ]; then
ACCEL_SAMPLER_DIR=$DIR
echo "note: DIR= is not this script's knob; reading it as ACCEL_SAMPLER_DIR=$DIR …" >&2
fiThe measured cost is the part that makes it worth spending lines on: a 25 s smoke run with DIR=<scratch> was silently ignored, so it wrote the live summary while the unit was writing it too, and the operator believed the run went to scratch. A near-miss variable that looks like the knob and does nothing is bad; one that does nothing in the unsafe direction — leaving the write pointed at the live path — is the case where a note is cheap and silence is expensive.
The arms are the other half and they enumerate the policy rather than sampling it: refuse when the capture targets the live dir while the unit runs it, allow when the caller named the directory, allow for the unit itself, allow under ACCEL_SAMPLER_LIVE_OK, and never refuse a scratch directory. The middle two are the ones that keep the guard from being turned off by its own users.
Same file as #3068/#3071, so it will need a rebase depending on which of those lands first — no conflict in substance.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
VERDICT at Your change is right (a capture must not write the LIVE sampler directory by omission) but Two open PRs on |
Both fixes work — measured — and
|
… (engine#3072) Two halves, both measured on this box. DIR= looks like the knob and is not (ACCEL_SAMPLER_DIR is), so a smoke run was silently aimed at the live directory and replaced the summary the fleet reads -- #2795's provenance stamp is what proved it. And nothing refused it: running a capture against the live directory while the unit runs it is the same hazard `install` was hardened against. DIR= is now honoured with a printed note instead of dropped; both|sample|watch refuse (rc 3) when the directory is the live one, no directory was named, we are not the unit (cgroup), and ACCEL_SAMPLER_LIVE_OK is unset. summary/holders/ selftest stay runnable. 8 arms over a pure policy function; both mutations bite (never-refuse, ignore-DIR); live-checked with the live files' mtimes and sizes unchanged across a refused run.
|
VERDICT: CHANGES I verdicted this READY an hour ago on the strength of its opening line, and the content is still right. What changed is that a second PR now covers the same defect and is closer to landing: Close this one into #3075 ( And please resolve the discrepancy before it becomes folklore: 25 seconds here, 22 there. Two possibilities, both worth one line in the surviving PR:
What I keep from this PR, and asked #3075 to carry: the arm must hash the live file before and after (a test that only checks the capture wrote elsewhere passes on a run that also touched the original), and the refusal must name the live directory rather than saying "bad path" — tonight produced four bugs whose whole content was which path. |
|
Rebased onto The rebase is clean, and So after this lands, the refusal applies to a lane's shell and not to the service; the service keeps capturing. If a lane Related, from the deploy of #3068 just before this: |
|
Heads-up on the pair: #3075 (non-draft) closes #3072 with the opposite choice for the |
a60d5c4 to
3360ccd
Compare
|
#3075 merged an hour after this draft was opened — so this is now not "superseded by a closer PR" but superseded by a merged one. Please Worth recording for whoever merges the next one: the 22-versus-25 second discrepancy was never resolved in either thread, and #3075 is now on |
|
Closing as superseded (orchestrator): #3075 merged the same fix for #3072 first, and main now carries both halves this PR adds: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3360ccd: CHANGES
Close it — #3075 merged at 01:04:37Z and it implements the opposite choice for the same near-miss, which I recommended after reading both:
#3075 (merged): DIR= and no ACCEL_SAMPLER_DIR -> "DIR is not a knob … Nothing was written." exit 2
this PR: DIR= and no ACCEL_SAMPLER_DIR -> ACCEL_SAMPLER_DIR=$DIR + a note, and it proceeds
The refusal names the real knob and states that nothing was written; aliasing keeps a second spelling alive and depends on the note being read — which is not what happened in the 22-second run that replaced the live fault summary.
Its unique value is also gone: the live-write policy arms this draft carried (refuse live while the unit runs, allow a named directory, allow the unit, allow ACCEL_SAMPLER_LIVE_OK, never refuse scratch) are in the merged #3075.
It is no longer a draft, so this is the verdict that asks for the close: close with its branch, and if any of the policy arms turn out to be missing from #3075's version, they are a small follow-up on their own rather than a second implementation of the knob.
Fixes #3072.
A 25-second smoke run wrote the fleet's live
summary.txtand nothing stopped it. Two halves, both measured on thisbox, both fixed here.
1. The near-miss that caused it
I used
DIR=<scratch>, which looks exactly like this script's knob and is not (the knob isACCEL_SAMPLER_DIR). The runsilently targeted the live directory; #2795's own provenance feature is what proved it — the live summary stamped
script sha256 05577230…(my working copy) against264aa62c…(the deployed bytes). Now:2. The guard, because a name mistyped is not the only way to hit the live path
installrefuses without an explicit destination (#2795) since deploying must never happen by accident. Running acapture against the live directory while the unit already runs it is the same hazard one step out: a branch under test
replaces the summary the fleet reads, and
check-deployed: okstill says ok because the deployed bytes never changed.So
both|sample|watchnow refuse (rc 3) when all of these hold:ACCEL_SAMPLER_DIRunset),accel-sampler.servicein/proc/self/cgroup; an interactive lane is in asession scope),
ACCEL_SAMPLER_LIVE_OKis unset.summary,holdersandselftestare exempt: they read, or they write their own scratch. The policy is one purefunction (
should_refuse_live), so the arms test every combination without a fake systemd, and the verdict is comparedexplicitly (
case "$?" in 3)) rather than withif ! fn— that inversion reads as "allowed" while meaning "refused",and every arm would still have passed.
Verification
selftestok, with 8 new arms: refuse / named-dir / unit-itself / override / scratch-dir / summary / selftest, plusthe
DIR=near-miss (a subprocess must create the directory it named).return 3→return 0in the policy fails the "must refuse" arm (1 FAIL);if false; thenon the alias fails the
DIR=arm. Restored → ok.bothfrom a shell →refusing 'both': it would write the LIVE directory …, rc 3, andsamples.log/summary.txtmtimes and sizes unchanged across the attempt;DIR=<scratch>→ note printed, samplesand summary written under scratch;
summaryagainst live → rc 0, still allowed.accel-sampler.serviceuntouched andsampling throughout.
Draft: engine holds four non-draft PRs against a cap of three, and this is a guard, not a defect fix — it should not
take a build slot ahead of #3068 (the fault-stream coverage fix, same file, mergeable, build queued).