Skip to content

Commit 825e85d

Browse files
committed
fix(gallery): add fallback URI resolution for backend installation
When a backend installation fails (e.g., due to missing 'latest-' tag), try fallback URIs in order: 1. Replace 'latest-' with 'master-' in the URI 2. If that fails, append '-development' to the backend name This fixes the issue where backend index entries don't match the repository tags. For example, installing 'ace-step' tries to download 'latest-gpu-nvidia-cuda-13-ace-step' but only 'master-gpu-nvidia-cuda-13-ace-step' exists in the quay.io registry. Fixes: mudler#8437
1 parent 65082b3 commit 825e85d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

core/gallery/backends.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,36 @@ func InstallBackend(ctx context.Context, systemState *system.SystemState, modelL
182182
}
183183
}
184184

185+
// Try fallback: replace "latest-" with "master-" in the URI
186+
fallbackURI := strings.Replace(string(config.URI), "latest-", "master-", 1)
187+
if fallbackURI != string(config.URI) {
188+
xlog.Debug("Trying fallback URI", "original", config.URI, "fallback", fallbackURI)
189+
if err := downloader.URI(fallbackURI).DownloadFileWithContext(ctx, backendPath, "", 1, 1, downloadStatus); err == nil {
190+
xlog.Debug("Downloaded backend using fallback URI", "uri", fallbackURI, "backendPath", backendPath)
191+
success = true
192+
} else {
193+
// Try another fallback: add "-development" suffix to the backend name
194+
// For example: master-gpu-nvidia-cuda-13-ace-step -> master-gpu-nvidia-cuda-13-ace-step-development
195+
if !strings.Contains(fallbackURI, "-development") {
196+
// Extract backend name from URI and add -development
197+
parts := strings.Split(fallbackURI, "-")
198+
if len(parts) >= 2 {
199+
// Find where the backend name ends (usually the last part before the tag)
200+
// Pattern: quay.io/go-skynet/local-ai-backends:master-gpu-nvidia-cuda-13-ace-step
201+
lastDash := strings.LastIndex(fallbackURI, "-")
202+
if lastDash > 0 {
203+
devFallbackURI := fallbackURI[:lastDash] + "-development"
204+
xlog.Debug("Trying development fallback URI", "fallback", devFallbackURI)
205+
if err := downloader.URI(devFallbackURI).DownloadFileWithContext(ctx, backendPath, "", 1, 1, downloadStatus); err == nil {
206+
xlog.Debug("Downloaded backend using development fallback URI", "uri", devFallbackURI, "backendPath", backendPath)
207+
success = true
208+
}
209+
}
210+
}
211+
}
212+
}
213+
}
214+
185215
if !success {
186216
xlog.Error("Failed to download backend", "uri", config.URI, "backendPath", backendPath, "error", err)
187217
return fmt.Errorf("failed to download backend %q: %v", config.URI, err)

0 commit comments

Comments
 (0)