fix(install): stop requiring sudo when the driver install is already root - #305
Draft
volen-silo wants to merge 1 commit into
Draft
fix(install): stop requiring sudo when the driver install is already root#305volen-silo wants to merge 1 commit into
volen-silo wants to merge 1 commit into
Conversation
…root Every command in the native driver plan carried a literal `sudo ` prefix, applied unconditionally. As root that prefix is redundant; on a root host with no `sudo` binary it is fatal, and the first command dies with `sudo: not found` before any driver work happens. Containers and minimal cloud images are exactly that shape — root, no sudo — and `install driver` is the documented Linux driver path, so on those hosts it could not run. The command's own preflight already distinguished the two cases, promising `sudo` was needed only "when not running as root". Only the generator disagreed, so the preflight passed and execution then contradicted it. Resolve the escalation into a prefix that is empty when already root, and thread it through every distro plan builder. Resolution happens when the plan is built rather than when it runs, so the plan `--dry-run` prints, the plan the approval prompt shows, and the commands recorded in state.json are all the commands that actually execute. The preflight no longer claims a `sudo` binary is required when the plan has stopped using one. Non-root behaviour is unchanged: the existing plan tests pass untouched under an explicit non-root escalation. The new coverage asserts the absence of `sudo` across every supported distro rather than checking commands one by one, so a templating site missed on some distro fails the suite instead of shipping. Signed-off-by: Eugene Volen <Eugene.Volen@amd.com>
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.
tests/e2e-cucumber/expectations.tomlfor the fixed ticket ID and removed/narrowed any now-stale xfail rows. — no such row exists onmainyet; see Coordination.Summary
rocm install driver --dkmsbuilt every command in its plan with a literalsudoprefix, applied unconditionally. As root that prefix is redundant; on a root host with nosudobinary it is fatal:Containers and minimal cloud images are exactly that shape — uid 0, no
sudo— and this is the documented Linux driver path, so on those hosts it could not run at all.Root cause: only the command generator was wrong. The command's own preflight already distinguished the two cases, promising
sudowas needed "when not running as root". The preflight passed and execution then contradicted it.What changed:
--dry-runprints, the plan the approval prompt shows, and the commands recorded instate.jsonare all the commands that actually execute. Stripping the prefix at execution instead would leave all three misreporting what ran.sudobinary is required when the plan has stopped using one.Non-root behaviour is unchanged — all 25 pre-existing driver plan tests pass untouched under an explicit non-root escalation, rather than having their expectations rewritten.
Risk: low. No change to execution, approval, or the state-file shape; only the text of the generated commands, and only when already root.
Test plan
sudoacross all eight supported distro paths rather than checking commands one by one, so a templating site missed on some distro fails the suite instead of shipping. The others cover the inverse (off root, every privileged command still escalates), shell-pipeline integrity (| tee,| gpg— which a naive leading-prefix strip would miss),state.jsonagreement, and the preflight change.rhel: a plan built as root must not invoke sudo, got 'sudo dnf clean all'. A green assertion that cannot fail would have been worse than none.cargo test -p rocm480 passed;clippy --workspace --all-targets,fmt,prekclean.--reconcilepath never reads the persisted command strings, so plans differing by uid cannot break it.Not verified locally, stated rather than skipped: the apt/DKMS path end to end. Every container on my machine inherits a WSL
/proc/version, sois_wsl_host()matches and the plan short-circuits to the ROCDXG branch before distro dispatch — the DKMS path is unreachable here regardless of the container image. I confirmed that short-circuit still behaves after this change, but that is a guard on the branch above the fix, not evidence the fix works. End-to-end verification is the root-runner scenario described below.Coordination
#291 adds a root-gated e2e scenario for this defect plus an
expectations.tomlxfail row. It is still open, so there is no stale row for this PR to remove. Whichever merges second must reconcile: