Skip to content

run.sh: fail fast when venv package install fails#608

Merged
berendt merged 1 commit into
mainfrom
fix-run-sh-uv-exit-code
Jul 12, 2026
Merged

run.sh: fail fast when venv package install fails#608
berendt merged 1 commit into
mainfrom
fix-run-sh-uv-exit-code

Conversation

@ideaship

Copy link
Copy Markdown
Contributor

Problem

The manager bootstrap run.sh 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.

Observed live in an autodrive/tbng deploy on regiocloud.

Fix

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.

A targeted || exit $? was chosen over set -euo pipefail deliberately: these exits occur before the trap cleanup ERR EXIT is registered (further down the script), so the fix cannot trigger cleanup's rm -rf "$VENV_PATH" on the failure path.

Impact on downstream copies

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.

🤖 Generated with Claude Code

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>
@ideaship ideaship marked this pull request as ready for review July 12, 2026 07:55
@ideaship ideaship moved this from New to Ready for review in Human Board Jul 12, 2026
@ideaship ideaship requested a review from berendt July 12, 2026 07:56
@ideaship ideaship moved this from Ready for review to In review in Human Board Jul 12, 2026
@berendt berendt merged commit 8f8cfeb into main Jul 12, 2026
3 checks passed
@berendt berendt deleted the fix-run-sh-uv-exit-code branch July 12, 2026 15:36
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants