Skip to content

fix(backends): keep the installed backend when its upgrade fails - #13413

Merged
mudler merged 1 commit into
mudler:masterfrom
mudler-agent:fix/backend-upgrade-keeps-installed
Nov 23, 2026
Merged

mudler merged 1 commit into
mudler:masterfrom
mudler-agent:fix/backend-upgrade-keeps-installed

Conversation

@mudler-agent

Copy link
Copy Markdown
Collaborator

What

A failed backend upgrade no longer deletes the backend that is installed.

Why

After a failed install, the backend op handler removes the named backend to clear a half-written directory. It ran the same cleanup after a failed upgrade. For an upgrade, the name is the installed, working build. So an upgrade that failed for any reason that is not a cancel (for example, an interrupted download) left the user with no backend at all.

gallery.UpgradeBackend already puts the old build back when its own swap fails, and a failure before the swap leaves the old build untouched. The handler's cleanup could only remove a good backend.

Change

  • core/services/galleryop/backends.go: skip the failure cleanup when the operation is an upgrade. A failed first install still removes its leftover directory.
  • core/services/galleryop/backend_failed_op_cleanup_test.go: two specs. A failed upgrade keeps the installed run.sh and reports the error. A failed plain install still cleans up.

Tests

The upgrade spec fails without the change and passes with it.

gofmt -l core/services/galleryop core/gallery
go vet -tags nosqlite,purego_utp ./core/services/galleryop/ ./core/gallery/
go test -tags nosqlite,purego_utp ./core/services/galleryop/... ./core/gallery/...

golangci-lint and the full suite were not run.

Not in this PR

A failed forced reinstall (op.Force, not an upgrade) probably still runs the same cleanup. I did not change it because I did not check how that path swaps files.

Assisted-by: Claude:claude-sonnet-5-5

The backend op handler removes the named backend after any failed
install, to clear a half-written directory. It ran the same cleanup for
a failed upgrade, but there the name is the installed, working build.
gallery.UpgradeBackend already restores the old build when its own swap
fails, and a failure before the swap (for example a download error)
leaves it untouched, so the handler's cleanup only ever deleted a good
backend.

Skip the cleanup for upgrades. A failed plain install still removes its
leftover directory.

Assisted-by: Claude:claude-sonnet-5-5
@mudler
mudler merged commit 3c725a1 into mudler:master Nov 23, 2026
71 of 78 checks passed
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