Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: backend versioning, upgrade detection and auto-upgrade#9315

Merged
mudler merged 7 commits into
masterfrom
feat/backend-versioning
Apr 11, 2026
Merged

feat: backend versioning, upgrade detection and auto-upgrade#9315
mudler merged 7 commits into
masterfrom
feat/backend-versioning

Conversation

@mudler
Copy link
Copy Markdown
Owner

@mudler mudler commented Apr 11, 2026

Description

  • Track backend versions: gallery backends can declare a version field, and installed backends record version, URI, and OCI digest in metadata.json
  • Detect upgrades by comparing installed version vs gallery version, with fallback to OCI digest comparison via remote.Head()
  • Atomic upgrade mechanism: download to temp dir, validate, swap directories, rollback on failure
  • Background UpgradeChecker service: checks every 6h, logs available upgrades, auto-upgrades when enabled
  • LOCALAI_AUTO_UPGRADE_BACKENDS flag + auto_upgrade_backends runtime setting (toggleable at runtime via API/UI/file)
  • CLI: localai backends upgrade [names...] command, version display in localai backends list
  • API: GET /backends/upgrades, POST /backends/upgrades/check, POST /backends/upgrade/:name
  • React UI: version badges, upgrade indicators, upgrade buttons on Backends and Manage pages, auto-upgrade toggle in Settings
  • Distributed mode: advisory lock ensures only one frontend runs periodic checks; upgrade fans out to workers via NATS

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

mudler added 7 commits April 11, 2026 11:43
Add Version, URI, and Digest fields to BackendMetadata for tracking
installed backend versions and enabling upgrade detection. Add Version
field to GalleryBackend. Add UpgradeAvailable/AvailableVersion fields
to SystemBackend. Implement GetImageDigest() for lightweight OCI digest
lookups via remote.Head. Record version, URI, and digest at install time
in InstallBackend() and propagate version through meta backends.
Add CheckBackendUpgrades() to compare installed backend versions/digests
against gallery entries, and UpgradeBackend() to perform atomic upgrades
with backup-based rollback on failure. Includes Agent A's data model
changes (Version/URI/Digest fields, GetImageDigest).
Add configuration and runtime settings for backend auto-upgrade:
- RuntimeSettings field for dynamic config via API/JSON
- ApplicationConfig field, option func, and roundtrip conversion
- CLI flag with LOCALAI_AUTO_UPGRADE_BACKENDS env var
- Config file watcher support for runtime_settings.json
- Tests for ToRuntimeSettings, ApplyRuntimeSettings, and roundtrip
- Add upgrade check/trigger API endpoints to config and api module
- Backends page: version badge, upgrade indicator, upgrade button
- Manage page: version in metadata, context-aware upgrade/reinstall button
- Settings page: auto-upgrade backends toggle
- UpgradeChecker background service: checks every 6h, auto-upgrades when enabled
- API endpoints: GET /backends/upgrades, POST /backends/upgrades/check, POST /backends/upgrade/:name
- CLI: `localai backends upgrade` command, version display in `backends list`
- BackendManager interface: add UpgradeBackend and CheckUpgrades methods
- Wire upgrade op through GalleryService backend handler
- Distributed mode: fan-out upgrade to worker nodes via NATS
In distributed mode with multiple frontend instances, use PostgreSQL
advisory lock (KeyBackendUpgradeCheck) so only one instance runs
periodic upgrade checks and auto-upgrades. Prevents duplicate
upgrade operations across replicas.

Standalone mode is unchanged (simple ticker loop).
- Test GET /api/backends/upgrades returns 200 (even with no upgrade checker)
- Test POST /api/backends/upgrade/:name accepts request and returns job ID
- Test full upgrade flow: trigger upgrade via API, wait for job completion,
  verify run.sh updated to v2 and metadata.json has version 2.0.0
- Test POST /api/backends/upgrades/check returns 200
- Fix nil check for applicationInstance in upgrade API routes
@mudler mudler force-pushed the feat/backend-versioning branch from b725472 to 6dd37a9 Compare April 11, 2026 11:44
@mudler mudler merged commit 8ab0744 into master Apr 11, 2026
34 of 36 checks passed
@mudler mudler deleted the feat/backend-versioning branch April 11, 2026 20:31
@mudler mudler added the enhancement New feature or request label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant