Skip to content

tier4-e2e: the 'reaches clearnet THROUGH Tor' control is one Tor stream with no retry, so it fails when a single exit fails #2619

Closed

Description

@pithead-developer

What's the problem

Triaged from p2pool-starter-stack/bench-ci#583, which found nothing wrong with the bench.

The row the same container still reaches clearnet THROUGH Tor — the drop above is the firewall, not a dead route (#270/#2059) (tests/integration/lib/run-state.sh, section 8d) makes one Tor stream: curl -m 30 --socks5-hostname <tor>:9050 http://1.1.1.1/, with no retry. On the live Tor network, one stream through a random exit fails now and then, so the row is flaky by design.

Evidence (bench-ci jobs, the tor service's logs in each job's logs.txt artifact):

  • 872@532b7bb2d2e836c3b069e36d9d949bba08904a2b (matrix): the row passes in 8 scenarios and fails only in remote-tari-main-secure. Same bench, same firewall, same job. Tor had reached Bootstrapped 100% about 8.5 minutes before the dial. Minutes earlier the log shows We tried for 15 seconds to connect ... using exit ... Retrying on a new circuit.
  • 882@3da4580a70cf9c5767c77aaa4e98e427f1df595f (targeted, a different bench): Tor had reached Bootstrapped 100% about 9.5 minutes before the dial. Around it, Tor logs repeated Your network connection speed appears to have changed. Resetting timeout to 60000ms after 18 timeouts, meaning circuits were slow to build, plus exit connect retries. The dial failed after about 27.6 s, just under curl's 30 s cap. That fits two 15 s exit attempts.

In both jobs the row before it (clearnet dial is DROPPED) passed, and other Tor traffic in the stack was flowing. The bench had a route out. What failed was the one stream.

Proposed fix: keep the assertion strict, but give the control dial a few attempts on fresh circuits before it fails. For example, 3 attempts with -m 45, each with a distinct --proxy-user so IsolateSOCKSAuth puts it on a new circuit. On final failure, name the attempts in the message. The DROP half stays single-shot, because a timeout is the expected result there. Make the same change in tests/os/appliance-egress-leg.sh, which has the same single-shot control dial.

what it impacts

Impact is not separately established in the existing report; confirm the affected users or behavior.

How I found it

Discovery details are not separately established in the existing report; preserve and verify the evidence already recorded.

how important is it

Importance has not been assessed explicitly; triage must state the priority and its reason.

acceptance criteria

Acceptance script

This issue has no acceptance section of its own. The script below operationalizes its Proposed fix, and the tier-4 bar from the 2026-09-24 investigation brief: a tier4-e2e run for run-state.sh and a tier4-kvm provision run for appliance-egress-leg.sh, each with the two rows it changes green.

Done means the script at the end of this section prints ACCEPTED and exits 0 on the PR head. Every check is a mechanical pass or fail, so no judgment call is needed. Paste the script's full output into the PR body.

# save the script below as /tmp/accept_2619.py (outside the repo), then, from the repo root:
python3 /tmp/accept_2619.py --results DIR

Run it on Linux, as CI does. On macOS, run it inside the CI image: save it and DIR under the ignored tests/integration/results/ and run make test-container ARGS="python3 tests/integration/results/accept_2619.py --results tests/integration/results/DIR". It takes under a minute and changes nothing in the repo. It drives both dial legs in a temporary directory: docker, podman and curl are stubs, the curl stub fails every through-Tor attempt or only the first one, and the direct dial times out the way a silent drop does.

DIR holds two bench-ci jobs, both on the PR head: DIR/e2e is a tier4-e2e job (targeted reaches the row) and DIR/kvm is a tier4-kvm job with phase provision. Fill each with the bench-ci client:

bench-ci evidence <e2e-id>@<head-sha> --json > DIR/e2e/evidence.json
bench-ci artifacts <e2e-id>@<head-sha> e2e-harness.log --out DIR/e2e/e2e-harness.log
bench-ci artifacts <e2e-id>@<head-sha> results/manifest.txt --out DIR/e2e/results/manifest.txt
bench-ci evidence <kvm-id>@<head-sha> --json > DIR/kvm/evidence.json
bench-ci artifacts <kvm-id>@<head-sha> kvm-provision.log --out DIR/kvm/kvm-provision.log

The row names below are the ones the harnesses print today.

Check Passes when
C1 Files under both tests/integration/ and tests/os/ differ from develop, and nothing outside those two and docs/ does. CHANGELOG.md is also allowed.
C2a e2e leg (assert_egress_dial_pair, loaded the way run.sh loads it), every through-Tor attempt failing: it makes 2 to 5 SOCKS attempts, then the same container still reaches clearnet THROUGH Tor — the drop above is the firewall, not a dead route (#270/#2059) fails exactly once.
C2b e2e leg: each attempt carries its own SOCKS username (--proxy-user, -U or socks5h://user@), goes through the SOCKS endpoint in the existing container fixture (exact value retained in private issue evidence) to 1.1.1.1, and allows at least 30 s (-m/--max-time).
C2c e2e leg: the failure detail names the attempt count, for example 3 attempts.
C2d e2e leg, second attempt connecting: the row passes and no third attempt is made.
C2e e2e leg: the direct dial runs exactly once in both cases, and clearnet dial is DROPPED with the firewall on (#270/#2059) passes.
C3a-C3e The same five checks for the appliance leg (phase_provision_egress_backstop in tests/os/appliance-egress-leg.sh, with a healthy IPv4-only guest stubbed). Its rows are egress through Tor's SOCKS still works — the drop did not break real mining, the failure row that starts the mining container can no longer reach clearnet even through Tor, which carries the attempt count in its own text, and direct clearnet dial from a mining container is dropped — Tor-only egress is enforced.
C4 bash tests/os/appliance-egress-leg.sh --self-test exits 0 and prints appliance-egress-leg self-test passed.
B1 DIR/e2e/evidence.json names the full HEAD commit, tier tier4-e2e and status completed. DIR/e2e/results/manifest.txt has a git_rev: of at least 7 characters that HEAD starts with.
B2 In DIR/e2e/e2e-harness.log, the through-Tor row and the DROP row each pass at least once and never fail.
B3 DIR/kvm/evidence.json names the full HEAD commit, tier tier4-kvm and status completed. Its phases include provision, and image_checksums has a system.img entry.
B4 In DIR/kvm/kvm-provision.log, the appliance through-Tor row and drop row each pass at least once, and neither the through-Tor row nor its failure row ever fails.

Without --results, B1 to B4 print FAIL ... [bench evidence not supplied]. Neither job's overall conclusion is checked: per the brief, an unrelated red row such as #2333 in the KVM job does not void the egress rows. The rows themselves must be green.

Rules:

  • Do not change the script's test IDs, anchors or expected outcomes. If a check prints DRIVER-ERROR or error(...), harness code has moved since this issue was filed. Stop and comment here with the output instead of editing the script.
  • A reviewer re-runs the same script on the head they review. A changed head needs a fresh run and fresh bench jobs.
  • The repo's normal gates still apply on top of this: make test, make test-patch-coverage, and the adversarial review.

Baseline, run 2026-10-03 on 3822294 (develop; the goal is derived from the Proposed fix): unmodified develop prints NOT ACCEPTED: 3/16 checks pass. Only C2e, C3e and C4 pass. Each leg makes one 30 s attempt with no SOCKS username, and its failure names no attempt count. With --results pointing at fixtures modelled on jobs 872/882 (the through-Tor row red, the DROP row green), it prints NOT ACCEPTED: 5/16 checks pass. A throwaway prototype, not committed, printed NOT ACCEPTED: 12/16 checks pass without results, all local checks green. With pass fixtures it printed ACCEPTED: 16/16 checks pass on two runs. The prototype was a shared tests/integration/lib/tor-control-dial.sh, used by both legs, that makes 3 host-side attempts of 45 s, each with its own --proxy-user. The bench checks were validated only against synthetic fixtures in the harnesses' real formats: rows printed by assert_egress_dial_pair, summary, record_manifest and the battery's own ok/bad, with box I/O stubbed. No real job was used. All runs were made on a macOS host, and no check here depends on GNU tools.

Hint, not binding: draft PR #2622 has the right shape, but it predates develop's /usr/bin/curl pinning in the appliance leg. The appliance self-test requires every podman exec monerod probe to name /usr/bin/..., so an in-container loop needs /usr/bin/sh -c. It also counts the pinned /usr/bin/curl -s dials in its tor-down guest, and either retry shape changes that count, so the self-test needs updating with the leg.

Independent re-check, 2026-10-03: a second session re-ran this script in a fresh worktree at 3822294. Develop printed NOT ACCEPTED: 5/16 checks pass, and with the throwaway prototype applied and the pass fixtures it printed ACCEPTED: 16/16 checks pass. Files the script mutates were left unchanged after each run.

accept_2619.py

The complete executable acceptance script is retained unchanged in the runner's private issue evidence; use that script to verify the criteria above.

possible solutions

No distinct solution options are recorded; investigate the existing report before choosing an approach.

Exact original fixture values and log text are preserved in private runner notes; this formatting update ran no new checks.

Activity

  1. added
    testing
    needs-triage
    flaky
    on Sep 23, 2026
  2. pithead-developer commented on Sep 24, 2026

    @pithead-developer
    ContributorAuthor

    Investigation brief (operator pre-read, 2026-09-23 — corrected 2026-09-24 against live bench-ci and PR state)

    still_valid: yes. tests/integration/lib/run-state.sh:357 (section 8d) and tests/os/appliance-egress-leg.sh:122 each still make exactly one curl -m 30 --socks5-hostname <tor>:9050 http://1.1.1.1/ as the positive control for the Tor-egress-firewall row, no retry — confirmed on the read-only develop head (296c860).

    root_cause: a single Tor stream through a randomly-chosen exit fails occasionally on its own (slow/dead exit, circuit build timeout); the issue's own evidence (bench-ci jobs 872, 882) shows Tor logs retrying/timing out around the failing dial while the DROP row and other Tor traffic in the same job passed — the bench had a route out, only the one stream failed. Traced from bench-ci#583, which found nothing wrong with the bench.

    fix_shape / duplicates_or_blockers: already built. Draft PR #2622 (agent/2619-tier4-e2e-the-reaches-clearnet-through-t, author pithead-developer) implements exactly the issue's own proposal: a shared tests/integration/lib/tor-control-dial.sh making up to 3 attempts (-m 45), each with a distinct --proxy-user so IsolateSOCKSAuth forces a fresh circuit per attempt; first success stops the loop; on exhaustion the failure message names the attempt count. Both harnesses call the shared helper; the DROP/negative row (where a timeout is the expected, correct result) stays single-shot and untouched. Per the one-PR-per-issue rule, this is the PR to resume, not fork.

    evidence_tier: tier4 satisfied. bench-ci job 953 (tier4-e2e, mode=targeted, head c3a61a5e) has completed — success: the 8d row passed twice and the run summary reads "passed: 107, failed: 0, E2E PASSED." Job 954 (tier4-kvm, covers the appliance-egress-leg.sh twin) has also completed, but with overall conclusion: failure — one row failed: "reserved-node preview did not expose endpoints behind the combined approval gate ... MONERO_NODE_PASSWORD," which is a pre-existing, already-filed, unrelated bench-fixture bug (pithead#2333) that has nothing to do with Tor or this fix. Within that same job, the "Tor-only egress enforcement backstop" phase this PR actually changes — both the DROP check and the through-Tor retry check — passed cleanly. So the fix's own evidence is bench-proven on both legs; the job's red conclusion badge is a red herring caused by #2333, not a sign the retry logic is broken. The PR also carries a tier-1 selftest (selftest-tor-control-dial.sh, 11/11 with stubbed curl) plus clean shellcheck/shfmt/lint — correctly scoped as supporting evidence, not the sole proof.

    rulings_needed:

    1. Both bench legs' relevant rows now pass (953 fully green, 954's Tor-egress-backstop phase green within an otherwise-failed run caused by unrelated Bench fixture: non-blank PITHEAD_OS_MONERO_NODE_PASSWORD makes the reserved-node preview row unpassable #2333) — recommended default: don't wait for job 954 to show an all-green conclusion, since Bench fixture: non-blank PITHEAD_OS_MONERO_NODE_PASSWORD makes the reserved-node preview row unpassable #2333 may keep failing it regardless of reruns; call the tier4 evidence bar met, note Bench fixture: non-blank PITHEAD_OS_MONERO_NODE_PASSWORD makes the reserved-node preview row unpassable #2333 explicitly in the PR thread so a reviewer doesn't mistake it for a regression from this change, and merge once review is otherwise done. Do not fork a second fix.
    2. Milestone stays "maintenance & gates" (frozen until GA) even though the fix is bench-proven — recommended default: leave it there; not a GA blocker, merges once the freeze lifts.

    Triage recommendation: STAY-maintenance-gates — a test-harness flake, not a product defect, security/data-loss issue, or blocker on the Tari fork/appliance/dashboard cut; the fix already exists and is now fully bench-validated on the rows it touches. (The original brief's triage code "MOVE-2.0.x" named a milestone that doesn't exist in this repo and contradicted its own rulings_needed — corrected here.)

    Verify against the code before relying on this; it was written by an investigator, not the implementer.

  3. pithead-developer commented on Oct 12, 2026

    @pithead-developer
    ContributorAuthor

    Questions before work continues (answer here, then remove the question label):

    Should #2622 add the retry to the e2e control even though #3062 deliberately made it one-shot for the bench-ci#812 diagnosis? Default: yes. run_egress_socks_probe would keep the first request unchanged and recorded as sequence 1. Only when that request fails would it make up to 2 more attempts, each with its own --proxy-user and each recorded as its own sequence. The original failure stays in the artifact, and the verdict is a pass if any attempt connects. I would update selftest-egress-probe.sh's 'exactly N requests' and 'no replacement probe' assertions to match, and keep the shared tor-control-dial.sh for the appliance leg, which would use /usr/bin/curl as develop now does. Alternative: leave the e2e control one-shot until bench-ci#812 closes and merge only the appliance-leg retry. That leaves the flaky row in this issue's title unfixed. I would not take it unless you say the diagnosis outranks the fix.

  4. added
    question
    on Oct 12, 2026
  5. pithead-architect commented on Oct 12, 2026

    @pithead-architect

    Ruling: Take the default. The retry goes into the e2e control now; bench-ci#812 does not outrank it, because what #812 needs is the record of the original failure, which pithead#3062 built and your design keeps. Order of work: (1) in run_egress_socks_probe, sequence 1 stays exactly the request develop makes and records today (same command, same -m 30, same original-socks-probe fields), so every record #812 compares against stays comparable; only on a non-zero exit do attempts 2 and 3 run, each with its own --proxy-user for a fresh circuit, each written as its own sequence with exit, elapsed and class, and the verdict passes if any attempt connects. (2) On a pass after a retry, the row's message names the attempt that connected ("passed on attempt 2 of 3; attempt 1 exit=52 class=empty-reply"), and on a final failure it names all three, so a flake and a dead route still read differently in the log and three identical failing records keep #812's diagnostic value. (3) The DROP half stays single-shot. (4) Update selftest-egress-probe.sh: the one-shot and no-replacement assertions become "sequence 1 unchanged and recorded first", "no retry after a success", "retries are recorded, never substituted"; show one of them red then green. (5) Keep the shared tor-control-dial.sh for tests/os/appliance-egress-leg.sh with /usr/bin/curl as develop does; do not let the two harnesses drift on attempt count or isolation. (6) Jobs 953 and 954 are on an older head and will not stand for the merged diff: rebase onto develop, then one fresh tier4-e2e targeted job and one fresh tier4-kvm provision job on the final head, conclusions quoted in the PR body, correcting the Evidence section in place. (7) Add a one-line pointer on bench-ci#812 saying the verdict now tolerates a transient exit while the per-attempt records remain its evidence. This is a test-correctness fix against the live Tor network, which bench-ci#583 already cleared the bench of, not a workaround of a bench fault. Milestone stays maintenance & gates.

  6. removed
    question
    on Oct 12, 2026
  7. pithead-developer commented on Oct 19, 2026

    @pithead-developer
    ContributorAuthor

    Waiting on a transient bench_outage condition, not on another issue. bench-ci submit and list fail from the submitting machine with 'No route to host' after the client's 5 retries; the tier4-e2e targeted and tier4-kvm provision submissions for de2c4c7 created no job. The runner re-checks it (first at 2026-10-19T14:21Z, at most 5 times).

  8. pithead-developer commented on Oct 19, 2026

    @pithead-developer
    ContributorAuthor

    Questions before work continues (answer here, then remove the question label):

    A bench_outage condition has held since 2026-10-19T14:06Z through 5 re-checks: bench-ci submit for tier4-e2e (mode=targeted) and tier4-kvm (phases=provision) on de2c4c7 still returns '503 draining: the runner is shutting down; retry shortly' on a keyed retry (fifth consecutive re-check); no job was created. Idempotency keys: tier4-e2e b882f4b3c50648989a58d358e188ffe2, tier4-kvm 2f399738e11e41a78cee26a7121f7892. Give the worker one bounded recovery step, or identify a genuine dependency; default: the worker re-checks and resubmits.

  9. 25 remaining items

  10. pithead-developer commented on Oct 26, 2026

    @pithead-developer
    ContributorAuthor

    Additional executed subnet-phase occurrence from #3617 / draft #3649 on the preserved candidate head.

    The initial through-Tor control passed. After the subnet apply, the retained original probe reports sequence 2, exit 56, elapsed 15 seconds, receive-or-socks-failed, stage unknown; the direct DROP control passed. The saved Tor log reaches completed bootstrap and records circuit connection retries; its retained health snapshot is healthy. These observations do not identify the failed stream's cause or establish a host fault.

    The Tari-enable assertions executed and passed despite this unrelated red row. Reusing this canonical control correction; no Tor fix, retry-policy change, guard bypass or host action is folded into #3649.

    bench-ci job 3015@8a21bc2deb20ff7d2be8051e720ad92ed48b9bc9 · pithead · tier4-e2e

  11. pithead-developer commented on Oct 26, 2026

    @pithead-developer
    ContributorAuthor

    The required second Tari verification, 3018 on the same source head as 3015, completed both original through-Tor positive controls successfully (probe sequences 1 and 2, exit 0). The Tari change does not modify Tor, and these observations do not identify the earlier subnet stream failure's cause. Retain 3015's failed control under this canonical issue; no separate flaky issue or Tor retry was created.

    bench-ci job 3018@8a21bc2deb20ff7d2be8051e720ad92ed48b9bc9 · pithead · tier4-e2e

    • options: {"phases": ["safety-backup", "subnet", "lifecycle"]}
    • status: completed · conclusion: failure · exit 1 · 73m 10s
    • baseline verified: yes · rig restored: yes
    • node guard: not recorded · no comparison recorded
    • steps: checkout success · reserve success · preflight success · run failure · collect success · restore success · cleanup success
    • rows: 327 pass · 3 fail · 1 skip (by-design 1)
    • failed rows:
  12. added a commit that references this issue on Oct 27, 2026
  13. removed
    operator-action
    on Oct 27, 2026
  14. pithead-developer commented on Oct 27, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #2622.

  15. pithead-developer commented on Oct 27, 2026

    @pithead-developer
    ContributorAuthor

    Additional historical-head recurrence from #2771 / draft PR #3513: job 3079@d8f58becae033d915268a5607c2c5ac2caf4ced3 failed the original single-stream through-Tor control. Its retained probe reports sequence 1, exit 56, elapsed 16 seconds, receive-or-socks-failed, stage unknown. The direct DROP row passed; later original probes 2 and 3 passed. This does not establish the failed stream's cause or a firewall defect.

    The tested source does not include the separately merged #2622 correction on develop. Retain this occurrence under the existing owner; no reopening, new flaky issue, source workaround or unchanged bench rerun is requested. The other failed row is the safety-rollback diagnostic gap owned by #3641; final runner baseline and rig restoration passed.

    bench-ci job 3079@d8f58becae033d915268a5607c2c5ac2caf4ced3 · pithead · tier4-e2e

  16. pithead-developer commented on Oct 31, 2026

    @pithead-developer
    ContributorAuthor

    Additional scoped evidence from #3806 / draft PR #3807: 3251@c7f4a1061dd99650943dc2f94a68207da53bb762 failed the appliance's original single-stream through-Tor positive control; its direct DROP control passed. This release-integration source still uses the one-shot control and does not contain #2622. Retain this observation under the existing owner; no new flaky issue or unchanged-head retry is requested.

    Read the completed job log, kvm-provision.log and guest-tor-provision.jsonl. The passive samples around the failed probe report Tor running/healthy and retain its earlier bootstrap completion; they do not prove that the tested SOCKS stream or external route succeeded. The positive control discards the command's exit status and stderr, so this occurrence does not establish a firewall defect or a particular network cause. The exact generated job evidence is retained in PR #3807.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-correctnessbugflakyneeds-triagetesting

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions