Repository navigation
CLI restore puts the fixed files back when a later step fails (#4450) - #4493
pithead-developer[bot] wants to merge 9 commits into
Conversation
… later step fails (#4450) restore installed the three fixed files before copying the data directories, and a failed copy left the archive's files in place. It now keeps a copy of each live file beside it, moves the copies back on any later failure, and says so when a copy cannot be put back. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
FAIL What I investigatedReviewed head 5c6ec94 (3 files: lib/pithead/16a-restore-safety.sh, tests/stack/test-cli-restore-hardening.sh, docs/operations.md) against #4450. The core fix works and its new test is red on the base and green on the head. The PR still lacks a tier4-e2e job on the head, one new rollback branch has no test, and two explanatory comments sit in edited hunks.
Reviewed head: What are the gaps
|
…emoval (#4450) Address reviewer findings: move the two explanatory comments to docs, add a per-file warning when the restore cannot put a file back, and add the missing test for the rollback branch where a file did not exist before the restore (backup is empty). Co-Authored-By: Claude Code <noreply@anthropic.com>
…test The test for an empty backup (config.json did not exist before restore) removed it from $BK/config.json. Subsequent tests expected it present. Restore it from $CR/pre-config before the next test block.
tier4-e2e submission blocked by macOS soak-test infraBlocker: What this prevents: bench-submit refuses tier4-e2e with "held: tier1/tier2 not passed for the head" — the macOS soak cancellations make the Shell workflow conclusion What is finished: All code changes are committed and CI green for the changed paths:
How to clear: The macOS soak runners need investigation — jobs start but are cancelled after ~16m with no steps logged. This is a CI infra issue, not a code regression. The soak tests are pre-existing and not touched by this change. Re-submit tier4-e2e once the macOS soak runners are healthy, or ask a runner to override the soak test gate. Evidence:
|
|
Ready for review. |
|
Head re-proved on the bench after a bench outage window: |
|
FAIL What I investigatedRe-review of head 78d6990 against 5c6ec94 (the earlier head is in this clone). The test for the added-file rollback (F4493-2) and the comment cleanup (F4493-3) are fixed. F4493-1 still stands. The quoted tier4-e2e jobs 4648 and 4628 ran only
Reviewed head: What are the gaps
|
…cli-restore-installs-the-config-before-t
…cli-restore-installs-the-config-before-t
|
FAIL What I investigatedRe-review of head ccf7127 against 78d6990 (present in this clone). The worker's own diff is unchanged: the only new commits are two merges of develop-v2.0.5, and the PR diff has the same stable patch id on both heads. F4493-1 still stands, but it is now narrow. Job 1129 on this head did run the changed CLI restore on a bench with every restore row green. What is missing is an open owning issue for one of its three unrelated red rows, and a body that quotes the job as evidence instead of calling it "Not evidence" beside a stale "held fleet-wide" claim. No new bench job is needed to close it.
Reviewed head: What are the gaps
|
|
PASS What I investigatedRound 4 re-review of head ccf7127: the code diff since the last reviewed head is empty, so I held the one standing finding, F4493-1, against the current PR body and issue #4641, and it is closed. I also re-derived the proof myself: the quoted bench blocks match, job 1129 ran
Reviewed head: |
Owner brief for
|
…before-t Resolve the restore commit conflict by keeping the pre-install backup and writing through develop's rename-based sudo_install_file; narrow the put-back failure test's fake mv to the .restore-old move, since the install step now also lands files with mv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tore-installs-the-config-before-t
|
Blocked on p2pool-starter-stack/bench-ci#2830. The Done so far: develop is merged, the conflict is resolved, the Bash 3.2 rollback loop is fixed, and all 45 GitHub checks pass on a37ac51. To unblock: bench-ci#2830 must be fixed, or that bench's dashboard database restored (bench-ci or operator work). After that, resubmit |
…fter a signal The EXIT trap now starts from an empty rollback list, so an inherited RESTORE_FIXED_BACKUPS can no longer move or remove files. A signal while the .restore-old copies are being removed after a successful restore finishes removing them instead of putting part of the old files back. The put-back runs before the staging directory is removed, a partial copy that cannot be removed is named, and the copies are ignored by git. Tests pin the per-file put-back warning and the Caddyfile mode, and docs/operations.md states what a failed restore does and does not undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Blocked on #4676 (the Tor image fix in #4683).
|
What's the problem
Part of #4450
./pithead restoreinstalled the archive'sconfig.json,.envand Caddyfile first and copied the data directories afterwards. When a data copy failed (a full disk, a permission error), restore stopped with an error and left the archive's three files in place next to the box's own data, with no rollback.How I fixed it
restore_commit_stage(lib/pithead/16a-restore-safety.sh) keeps a copy of the live one beside it as<name>.restore-old.XXXXXXXXXX, made withmktempandcp -aso it keeps the original's owner and mode.restore_discard_stagemoves the copies back and removes a fixed file that did not exist before. After a successful restore the copies are removed; a signal during that removal finishes it instead of putting part of the old files back.Restore could not put <file> back — it is kept as <copy>.) and a summary warning, and restore still ends with the original error and exit 1. A partial copy that cannot be removed, a copy left after success and an added file that cannot be removed are each named too.stack_restore(lib/pithead/17-backup-restore.sh) arms its EXIT trap with an empty list, so an inheritedRESTORE_FIXED_BACKUPScannot move or remove files, and the put-back runs before the staging directory is removed..gitignoreignores the.restore-oldcopies, which hold secrets.docs/operations.md(Restore collision rules) says what a failed restore puts back and what it does not undo: data directories copied before or during the failure, removed database sidecars, and failures after the last data copy. It also carries the Caddyfile 644 rationale and the staging-snapshot note from the deleted code comments; the deleted Tor circuit-state comment was already covered there./bin/bash3.2.57 run at a37ac51 (exit 1 withunbound variableat ccf7127, exit 0 at a37ac51); d29b3c0 adds a local and a flag test to that function and was not rerun under 3.2, and tier-1 CI runs Bash 5. Upgrade when a tier-1 job runs the CLI under Bash 3.2.Here is the proof
Acceptance criteria (#4450):
tests/stack/test-cli-restore-hardening.shfails the copy intodata/dashboard/with a fakecpand checks the content of all three files,config.jsonat 600, the Caddyfile at 644 and no copy left.mvfails the.envput-back; the test checks the per-file warning with the copy's path, the summary warning, exit 1, and that the copy holds the previous.env.Checks I ran on d29b3c0 (Linux, bash 5.3; the fragment is run the way the
shell-fragmentCI job runs it):test-cli-restore-hardening.sh: 99 passed, 0 failed. With16a-restore-safety.sh,17-backup-restore.shand.gitignoreat a37ac51 and the new tests: 91 passed, 8 failed, the eight assertions for this round's fixes. Withcp -achanged tocpand the per-file warning removed: 97 passed, 2 failed (the Caddyfile mode and the per-file warning). At a37ac51, with16a-restore-safety.shreverted to the merge-base c93d2aa: 73 passed, 10 failed, all ten put-back assertions.make lint-pithead-build,make lint-docs-voice,make lint-path-references,make lint-operator-stringsandmake lint-mdpass.make lint-file-budgetfails locally only because develop lowered thetor_heal.pyceiling after this branch's merge-base; it passes withFILE_BUDGET_BASE_REFset to the merge-base and on a trial merge with current develop. The local shellcheck 0.12.0 and shfmt 3.15.0 are not the pins: no new shellcheck warning on the generated CLI and no new shfmt hunk; the pinned gates are CI's.Build image (tor)fails on every develop head: Alpine now carries only tor 0.4.9.18-r0 and develop pins 0.4.9.17-r0 (Pin-bump workflows push their branch but cannot open the PR #4677); the bump is Bump tor to 0.4.9.18-r0 and upgrade busybox in the Alpine images #4683, part of tor image: busybox CVE-2026-140044 (HIGH, fixed in 1.37.0-r32) fails the image scan #4676.Soak self-test (macOS, homebrew)was cancelled at its 10-minute job limit.rm/mvin the EXIT trap, the signal race while copies are removed, the missing assertions for the per-file warning and the copy mode, the overstated docs paragraph, the silent partial-copy removal, the stage removal ahead of the put-back, and the copies not being git-ignored. Left as is: a TAB in the install path, and no Bash 3.2 run of a filled list (shortcut above).Bench: the restore change runs on a deployed box in the
safety-backupphase and in thelifecyclephase, which callspithead restore -y(tests/integration/lib/run-lifecycle.sh:137).phases=safety-backupandphases=lifecycle: not submitted. The submission wrapper holds tier 4 until every check on the head passes, andBuild image (tor)cannot pass before Bump tor to 0.4.9.18-r0 and upgrade busybox in the Alpine images #4683 lands on develop. Blocked on tor image: busybox CVE-2026-140044 (HIGH, fixed in 1.37.0-r32) fails the image scan #4676; once it closes, develop is merged in and both phases run on the new head.CLI restore refreshes dashboard configuration and running energy cost (#3432),restore preserves secrets,restore probe returns the original healthy Tari baseline (#3432)); its three red rows are boot-firewall rows owned by e2e hardening: "after the boot unit ... a private source can (#2749)" fails with the lan-guard unit inactive #4641 and ran before the lifecycle phase. Jobs 4767 and 4768 on a37ac51 failed at the#196telemetry-schema row before their phases ran, because the bench's dashboard database carried another branch's migration (p2pool-starter-stack/bench-ci#2830, cured on the bench and fixed by p2pool-starter-stack/bench-ci#2902). Jobs 4889 and 4890 were cancelled before they ran because the head changed.bench-ci job 4648@78d6990477816de70e80a0316c2dfc7b11459347 · pithead · tier4-e2e
Generated by
bench-ci evidence 4648@78d6990477816de70e80a0316c2dfc7b11459347; re-run it to check.bench-ci job 1129@ccf71270cba921b4489709f6bea9a55361185bdf · pithead · tier4-e2e
Generated by
bench-ci evidence 1129@ccf71270cba921b4489709f6bea9a55361185bdf; re-run it to check.bench-ci job 4767@a37ac510d21254f7e42a0a3d2382d75452489479 · pithead · tier4-e2e
Generated by
bench-ci evidence 4767@a37ac510d21254f7e42a0a3d2382d75452489479; re-run it to check.bench-ci job 4768@a37ac510d21254f7e42a0a3d2382d75452489479 · pithead · tier4-e2e
Generated by
bench-ci evidence 4768@a37ac510d21254f7e42a0a3d2382d75452489479; re-run it to check.bench-ci job 4889@a37ac510d21254f7e42a0a3d2382d75452489479 · pithead · tier4-e2e
Generated by
bench-ci evidence 4889@a37ac510d21254f7e42a0a3d2382d75452489479; re-run it to check.bench-ci job 4890@a37ac510d21254f7e42a0a3d2382d75452489479 · pithead · tier4-e2e
Generated by
bench-ci evidence 4890@a37ac510d21254f7e42a0a3d2382d75452489479; re-run it to check.🤖 Generated with Claude Code