Skip to content

fix(gallery): make backend (re)install a clean replace instead of an overlay#10726

Merged
mudler merged 1 commit into
masterfrom
fix/backend-install-clean-replace
Jul 7, 2026
Merged

fix(gallery): make backend (re)install a clean replace instead of an overlay#10726
mudler merged 1 commit into
masterfrom
fix/backend-install-clean-replace

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

InstallBackend now stages the download/extraction into a <name>.install-tmp dir, validates run.sh, writes metadata, then atomically swaps it into place (rename current → .install-backup, staging → current, drop backup) with rollback on failure — mirroring the atomic swap UpgradeBackend already performs.

Why

Previously InstallBackend extracted the artifact directly into the target directory with no pre-clean (it only cleaned up on a failed download). Because each backend artifact is a full image, not a diff layer, extraction overwrote same-named files but left behind any file from a previous version that no longer exists in the new artifact. For a heavy backend like vLLM, that means a stale .so or an orphaned package dir from an old version can linger next to the freshly pulled one and shadow it at import time — surfacing as confusing load failures.

After this change, install and upgrade leave identical on-disk state: a reinstall fully replaces the backend (including its prebuilt venv/) rather than overlaying onto it. This makes local-ai backends install a reliable recovery path for a stale/mismatched backend once a rebuilt artifact is available.

Testing

  • TDD: added a functional test that installs a backend shipping a stale file, reinstalls from an artifact that omits it, and asserts the orphan is gone (fails before the change, passes after).
  • Full core/gallery suite passes (incl. the real install-from-gallery test that exercises the swap on an actual OCI extraction). golangci-lint clean (new-from-merge-base).

Scope note

This addresses the recovery half of #10720 (making reinstall a real clean replace). The issue's other asks — surfacing the backend subprocess stderr on load failure, and a WARN on LocalAI-version/backend mismatch — were intentionally descoped here and remain open as follow-ups.

Part of #10720

🤖 Generated with Claude Code

…overlay

InstallBackend extracted the artifact directly into the target directory
with no pre-clean, so a reinstall overlaid the new files onto the old
ones. Files present in a previous version but absent in the new artifact
(a stale .so, an orphaned package dir) survived and could shadow the new
build at import time -- e.g. an old vllm shared object lingering next to
a freshly pulled one. Only a failed download cleaned the directory.

Stage the download/extraction into a `<name>.install-tmp` dir, validate
run.sh is present, write metadata, then atomically swap it into place
(rename current -> .install-backup, staging -> current, drop backup),
rolling back on failure. This mirrors the atomic swap UpgradeBackend
already performs, so install and upgrade now leave identical on-disk
state with no orphaned files.

Reported as part of #10720.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
@mudler mudler enabled auto-merge (squash) July 7, 2026 19:58
@mudler mudler merged commit 1d5139f into master Jul 7, 2026
66 checks passed
@mudler mudler deleted the fix/backend-install-clean-replace branch July 7, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants