Repository navigation
studio: report a denied rename as a possible ACL fault, not a scanner - #10075
danielhanchen merged 14 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
Thanks for taking this further — the two-surface point is right and mine was wrong. A failed You noted no check runs fired after the push, so here is an independent run of both touched
The 11 Windows failures are identical by name on both sides — pre-existing on this box, The Linux column is the one worth having: the On preserving the busy exit: I think that is the correct call, and the codebase backs it
and, about the aside-move specifically:
Since the code cannot tell a scanner from an unreadable ACL, keeping One consequence worth naming about my own commit: it printed Nothing outstanding from me. Happy to pick up anything else on it. |
This comment has been minimized.
This comment has been minimized.
|
Confirmed for a transient denial, and not confirmed for one that outlasts the backoff — Transient is safe, and the budget is the reason
The case that does changeThe re-raise at
The reason this matters is the aside rename specifically: when that is the one that fails,
which is What I would suggestThe intent behind the re-raise is right —
Happy to push that, or to drop it to the narrower version — move the re-raise below the Two consequences worth naming for the option I am proposing. A fourth exit code is a new |
|
Before I push this: #10533 has since assigned Node's exit 4 to I would rather not add one.
To coordinate with #10182, I would take the llama.cpp message out of this PR and leave it to #10182. What stays is the Node side and the cause-neutral exit-3 wording in One consequence worth naming: the llama half here also names the Unless you would rather have the dedicated exit code, or keep both halves here, I will push that. |
The re-raise of a reported access denial sat ahead of install_prebuilt's keep-existing check, so a WinError 5 rename that outlasted the retries failed setup even when the Node already on disk still ran: exit 1, which setup.ps1 and setup.sh turn into "Could not install an isolated Node runtime". The re-raise was there for a real reason -- both scripts show the installer's output only on a non-zero exit, so a plain keep-existing return would have swallowed the takeown/icacls lines -- but the two goals conflicted only because exit 0 was silent. It no longer is. install_llama_prebuilt.py already exits 0 when it keeps the tree on disk after a transient failure, and setup.ps1 and setup.sh match its "keeping the existing complete install" line to warn "update unavailable, existing prebuilt kept". Node now takes the same shape: the reported denial reaches the keep-existing check like any other failure, a Node that still runs is kept with exit 0 on a line ending "keeping existing isolated Node", as the download-failure case already logs, and both scripts match that line, warn "update not applied, existing isolated Node kept", and relay the installer output when it carries takeown lines. The line names the rename instead of "Node download failed" when that is what failed. The warning is not llama.cpp's text, which test_pr10648_offline_and_status.py holds to exactly two keep arms. No new exit code, and nothing else moves: a Node that does not run, a forced reinstall, and a same-version install whose digest is not the pin still raise, exactly as they do for a failed download. setup.sh gets the arm for parity; its takeown branch can only fire on Windows output. test_install_prebuilt_keeps_existing_when_a_reported_denial_blocks_the_swap replaces test_install_prebuilt_does_not_hide_reported_acl_denial and fails without this change, when the swap's OSError escapes. The three cases of test_install_prebuilt_reraises_a_reported_denial_it_cannot_keep_existing_through are parity guards. Studio.Setup.BlockedInstallCause.Tests.ps1 gains a block on the setup.ps1 arm, four of its five tests failing without it, and tests/sh/test_setup_node_kept_existing.sh runs the real setup.sh block against a stand-in installer, three of its thirteen checks failing without it. One consequence worth naming: setup now carries on with a Node it could not replace, so a user can stay on an older runtime while setup succeeds, and the warning prints once per run. Refs unslothai#9928.
_replace_with_retry printed takeown/icacls for its source whenever a WinError 5 outlasted the retries, and flagged the exception as a reported denial, whoever called it. Since unslothai#10648 that includes atomic_replace_from_tempfile, which renames a temp file onto the downloaded archive and onto the install marker. A denial there named a temp file that is removed moments later, and the flag made the keep-existing line say the existing Node "could not be replaced" when the swap had never run. The repair lines and the flag now need access_denied_paths, which only _swap_into_place passes, for its three renames. A temp-file rename still retries the same budget and still raises; it only stops naming a path that will not exist, and a Node kept after it is logged as "Node download failed", as before. test_a_denied_marker_write_offers_no_repair_for_its_temp_file drives atomic_replace_from_tempfile into an exhausted 5 and fails without this change. test_replace_names_acl_recovery_when_access_denied_persists now passes its paths, as the callers that get the lines do. Refs unslothai#9928.
954b3b4 to
d972ab7
Compare
The comment above setup.ps1's llama.cpp exit-3 branch said "The helper prints takeown guidance only when access was denied", and the header of Studio.Setup.BlockedInstallCause.Tests.ps1 named _access_denied_recovery_lines as the source of llama.cpp's repair commands. Both described the installer half this PR carried before the llama.cpp message was left to unslothai#10182. On main no installer prints those lines: install_llama_prebuilt.py and prebuilt_core.py contain no takeown at all, and _access_denied_recovery_lines exists only in install_node_prebuilt.py. So the branch's `-match 'takeown /F'` arm is correct but cannot fire until unslothai#10182 lands, and both comments said it could. The gate stays, because it is what unslothai#10182's output needs, and without it the ACL repair hint would be offered to every busy install. Only the text changes: both comments now describe the check rather than a producer. Comments only, no assertion changes. Refs unslothai#9928
Get-BlockSource took the Node exit handling from the first `$nodeExit = $LASTEXITCODE` to the next closing brace at that indent. unslothai#11786 put the mirror retry between the two, `if ($nodeExit -notin 0, 3, 4 -and (Use-MirrorSpare node)) { ... }`, so the slice ended at the retry's own brace. Merged with main, four of the five tests on a kept Node failed against a setup.ps1 that still has the branch they look for. The marker is now `$nodeExit -eq 3`, the chain's first line, once in setup.ps1. Against main's setup.ps1 the file still fails 11 of 22 (4, 3, 1, 3 and 0 by block), as it did at a09f376; with this branch's it passes 22.
Since unslothai#10533, a denied swap that cannot keep the existing Node reaches main() as a PermissionError and exits 4, and setup.ps1 answers exit 4 with Exit-PathAccessDenied: its own elevated takeown/icacls for the refused path and a note that antivirus can deny it too. _replace_with_retry had already printed ours, so that path showed two sets of repair commands for the same folder, with different icacls flags, around unslothai#10533's advice that elevation may not clear a security-software block. The lines now ride on the error and install_prebuilt logs them only in the branch that keeps a Node that still runs. That is exit 0, where setup.ps1 and setup.sh relay them on `takeown /F` and nothing else names a repair. "rename still blocked (5) after N attempts" still prints at the retry, so the exit-4 output keeps the rename's own record. Measured through main() with the real swap and a refused rename: exit 4 printed our four repair commands ahead of unslothai#10533's message, and now prints none, with the denied-path and denied-scope markers unchanged. A kept Node prints the same lines as before, ahead of "existing Node could not be replaced". test_a_denial_that_cannot_keep_node_leaves_the_repair_to_setup fails without this change; test_a_kept_node_prints_the_repair_setup_relays is a parity guard for the kept path. Four tests that read the lines from the log or checked the old flag, and the swap stand-in that set it, now use the error. One consequence worth naming: when the rollback of a failed forward rename is denied too, the repair lines naming the backup no longer print. The line "could not restore the previous Node install from <backup>" still names it, and the run exits 4.
|
Merged
The description is updated to match the branch as it is now. |
|
tested at details: LeoBorcherding#92 (comment) |
|
Review record for #10075, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#437. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Refs #9928.
The llama.cpp message this PR used to change is left to #10182, which changes the same one (coordination). What remains is the Node installer and the two setup scripts, brought up to date with
main1783a35e2, where #10533 already turns a denied Node install into exit 4.The defect
_replace_with_retryinstudio/install_node_prebuilt.pyretriesos.replaceon WinError 5, 32 and 145 and logs one message for all three:32 and 145 mean a handle is open. 5 (
ERROR_ACCESS_DENIED) is equally what a tree with unreadable ACLs looks like, which no backoff clears, and_swap_into_placeuses the same helper to move the existing install aside. In #9928 the reporter's cause was corrupt ACLs, fixed bytakeown /F … /R /D Ythenicacls … /reset /T /C, and nothing in the output pointed there.On
maina denied swap over a Node that still runs is kept, and reported as a failed download: measured throughmain()with the rename refused, it exits 0 withNode download failed ([WinError 5] Access is denied: …). Setup then says nothing, because both scripts show the Node installer's output only on a non-zero exit (setup.ps1:5674,:5681,:5695;setup.sh:2233,:2238).is_busy_lock_error(studio/prebuilt_core.py:347) also counts 5 as busy, so an ACL fault on the llama.cpp tree reachessetup.ps1's exit-3 branches, and both named an active llama.cpp process as the cause.The change
maintakeown/icaclsfor the tree (/R) and its parent (without), then "existing Node could not be replaced (…); keeping existing isolated Node"; both scripts warn "update not applied, existing isolated Node kept" and relay the repair lines--force, or a pin mismatchsetup.ps1'sExit-PathAccessDeniedprints the repairsetup.ps1llama.cpp exit 3, both sitestakeown /F, which no installer onmainprints yet (#10182 adds it)5 stays in the retry set. A scanner does raise it right after extraction;
activate_staged_dirdocuments exactly that for a freshly extracted DLL. The ambiguity was never in the retry, only in the message.The repair lines print only where nothing else names a repair.
_replace_with_retryattaches them to the error, andinstall_prebuiltprints them only when it keeps the existing Node. A denial it cannot keep through reachesmain()as aPermissionError, #10533 turns that into exit 4, andsetup.ps1answers exit 4 with its owntakeown/icaclsfor the refused path. Printing ours there as well showed two sets. Since #10648,atomic_replace_from_tempfilealso goes through_replace_with_retry, for the downloaded archive and the install marker; its source is a temp file about to be removed, so it gets no repair lines, and a Node kept after it is still logged as "Node download failed".No new exit code. The exit-0 shape is the one llama.cpp already uses when it keeps a working install (
install_llama_prebuilt.py:11407, matched atsetup.ps1:9894andsetup.sh:4848). The warning text is Node's own, becausetest_the_keep_arm_sits_beside_the_status_arms_it_did_not_replaceholds llama.cpp's to exactly two keep arms per script.The two commands go on separate lines for the reason
tests/studio/install/test_setup_denied_install_tree.pypins. No docs page covers Windows permissions, ACLs or antivirus blocks (checked 2026-09-14:get-started/install/windows-installation,basics/troubleshooting-and-faqs, and thellms.txtindex), so they are spelled out inline.Tests
Measured by running this branch's test files against
main's source at1783a35e2.test_replace_names_acl_recovery_when_access_denied_persiststakeown/icacls, the path and an elevated shell, one command per line, when the caller names the paths, and prints none of it itselftest_replace_does_not_blame_a_scanner_for_access_deniedtest_replace_keeps_the_scanner_message_for_a_sharing_violationtest_swap_into_place_reports_the_managed_parent_on_destination_denialtest_swap_into_place_reports_the_managed_parent_when_aside_is_denied/Rand its parent withouttest_a_denied_marker_write_offers_no_repair_for_its_temp_fileatomic_replace_from_tempfilecarries no repair linesmain, which has none at all; it fails if the lines are offered to every caller (checked by mutation)test_install_prebuilt_keeps_existing_when_a_reported_denial_blocks_the_swaptest_install_prebuilt_reraises_a_reported_denial_it_cannot_keep_existing_through(3 cases)--force, and a pin mismatch still raisetest_a_kept_node_prints_the_repair_setup_relaysmain(), with the real swap and a refused rename: exit 0, and the repair lines ahead of "could not be replaced"test_a_denial_that_cannot_keep_node_leaves_the_repair_to_setupmain(): exit 4, #10533's scope marker, and notakeownline from this PRtests/studio_setup_ps1/Studio.Setup.BlockedInstallCause.Tests.ps1, a source scan ofsetup.ps1: 11 of 22 fail without the change.takeown /F, close-users fallbackThe kept-Node block is anchored on
$nodeExit -eq 3, the first line of the exit chain, because #11786 put the mirror retry between reading$LASTEXITCODEand the chain.tests/sh/test_setup_node_kept_existing.shruns the realsetup.shexit-handling block against a stand-in installer: 3 of 13 checks fail without the change, the warning for both kept cases and the relayed repair lines. Exit 1, exit 3, a fresh install, no relay without repair lines, and not reusing llama.cpp's text are parity checks.Collateral
main1783a35e2against this PR's head, failure sets compared by name.maintests/studio/install, Linux containertests/sh, Linux container, file by filetests/studio_setup_ps1(Pester), Windowstest_install_node_prebuilt_logic.py, Windowstests/studio/test_path_probe_access_denied.ps1(#10533), WindowsThe three Linux failures on
mainaretest_unsupported_arch_routing_guards_8529.py::TestInstallShCpuSummaryBlamesTheRightCard::test_a_covered_peer_keeps_the_summary_quiet, in all three of its cases.Style gates run as the pinned hooks:
[email protected] checkclean, andscripts/run_ruff_format.py(ruff 0.6.9) applied and idempotent.One consequence worth naming
Setup now carries on with a Node it could not replace, so a user can stay on an older runtime while setup succeeds, and the warning prints once per run. A 5 that really was a scanner also prints ACL lines that do not apply to it, at the point the rename has already failed. And when the denial cannot be kept through, the only repair shown is #10533's, which names the Node directory, or its parent when the refused path is outside it, rather than the exact path the rename was refused on.
Not in scope
takeown /Flines are what the exit-3 gate above waits for; until it lands, that branch prints only the neutral lines.uvfailing to replacepydantic-corewhile its.pydis loaded.