run.sh: fail fast when venv package install fails#608
Merged
Conversation
The venv seed path installed uv and the Python/ansible environment
without checking exit codes:
pip3 install uv
uv pip install -r requirements.txt
uv pip install "ansible==$ANSIBLE_VERSION"
Unlike the surrounding lines (ansible-galaxy, osism.manager.*), which
use "|| exit $?", these three swallowed any failure. When uv could not
install -- e.g. it failed to initialize its cache
("Failed to initialize cache at ~/.cache/uv: Permission denied") --
run.sh proceeded with a half-built environment: requirements.txt (which
pulls in ansible plus collection dependencies such as ansible.posix)
never installed, ansible-galaxy still installed the osism.* collections,
and the operator playbook aborted much later with a misleading
"couldn't resolve module/action 'ansible.posix.authorized_key' -- No
module named ansible_collections.ansible.posix", tens of lines removed
from the real cause.
Guard all three install lines with "|| exit $?" so a uv/pip failure
aborts run.sh immediately with uv's own error message instead of
producing a broken venv and a confusing downstream failure.
This file is also vendored by cloud-in-a-box, metalbox, the
generics-drift-* repos, and tbng, which pick up the fix on their next
sync.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Roger Luethi <luethi@osism.tech>
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.
Problem
The manager bootstrap
run.shvenv seed path installed uv and thePython/ansible environment without checking exit codes:
pip3 install uv uv pip install -r requirements.txt uv pip install "ansible==$ANSIBLE_VERSION"Unlike the surrounding lines (
ansible-galaxy,osism.manager.*), which use|| exit $?, these three swallowed any failure. When uv could not install — e.g. it failed to initialize its cache (Failed to initialize cache at ~/.cache/uv: Permission denied) —run.shproceeded with a half-built environment:requirements.txt(which pulls in ansible plus collection dependencies such asansible.posix) never installed,ansible-galaxystill installed theosism.*collections, and theoperatorplaybook aborted much later with a misleadingcouldn't resolve module/action 'ansible.posix.authorized_key' — No module named ansible_collections.ansible.posix, tens of lines removed from the real cause.Observed live in an autodrive/tbng deploy on regiocloud.
Fix
Guard all three install lines with
|| exit $?so a uv/pip failure abortsrun.shimmediately with uv's own error message instead of producing a broken venv and a confusing downstream failure.A targeted
|| exit $?was chosen overset -euo pipefaildeliberately: these exits occur before thetrap cleanup ERR EXITis registered (further down the script), so the fix cannot triggercleanup'srm -rf "$VENV_PATH"on the failure path.Impact on downstream copies
This file is also vendored by
cloud-in-a-box,metalbox, thegenerics-drift-*repos, and tbng, which pick up the fix on their next sync.🤖 Generated with Claude Code