Skip to content

Commit d73a30c

Browse files
author
Piotr Stankiewicz
committed
Fix return on server update disabled
If we don't return an error from `ensureLatestLlamaCpp` when update is disabled, we'll fall into the wrong code path, and may end up trying to execute a non-existent `llama-server`. So, make sure we return an error from `ensureLatestLlamaCpp` if auto-update is disabled. Signed-off-by: Piotr Stankiewicz <[email protected]>
1 parent 6dd6230 commit d73a30c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

pkg/inference/backends/llamacpp/download.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ const (
2525
)
2626

2727
var (
28-
ShouldUseGPUVariant bool
29-
ShouldUseGPUVariantLock sync.Mutex
30-
ShouldUpdateServer = true
31-
ShouldUpdateServerLock sync.Mutex
32-
errLlamaCppUpToDate = errors.New("bundled llama.cpp version is up to date, no need to update")
28+
ShouldUseGPUVariant bool
29+
ShouldUseGPUVariantLock sync.Mutex
30+
ShouldUpdateServer = true
31+
ShouldUpdateServerLock sync.Mutex
32+
errLlamaCppUpToDate = errors.New("bundled llama.cpp version is up to date, no need to update")
33+
errLlamaCppUpdateDisabled = errors.New("llama.cpp auto-updated is disabled")
3334
)
3435

3536
func (l *llamaCpp) downloadLatestLlamaCpp(ctx context.Context, log logging.Logger, httpClient *http.Client,
@@ -40,7 +41,7 @@ func (l *llamaCpp) downloadLatestLlamaCpp(ctx context.Context, log logging.Logge
4041
ShouldUpdateServerLock.Unlock()
4142
if !shouldUpdateServer {
4243
log.Infof("downloadLatestLlamaCpp: update disabled")
43-
return nil
44+
return errLlamaCppUpdateDisabled
4445
}
4546

4647
log.Infof("downloadLatestLlamaCpp: %s, %s, %s, %s", desiredVersion, desiredVariant, vendoredServerStoragePath, llamaCppPath)

pkg/inference/backends/llamacpp/download_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ func (l *llamaCpp) ensureLatestLlamaCpp(_ context.Context, log logging.Logger, _
1414
) error {
1515
l.status = fmt.Sprintf("running llama.cpp version: %s",
1616
getLlamaCppVersion(log, filepath.Join(vendoredServerStoragePath, "com.docker.llama-server")))
17-
return errLlamaCppUpToDate
17+
return errLlamaCppUpdateDisabled
1818
}

pkg/inference/backends/llamacpp/llamacpp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (l *llamaCpp) Install(ctx context.Context, httpClient *http.Client) error {
9494
llamaCppPath := filepath.Join(l.updatedServerStoragePath, llamaServerBin)
9595
if err := l.ensureLatestLlamaCpp(ctx, l.log, httpClient, llamaCppPath, l.vendoredServerStoragePath); err != nil {
9696
l.log.Infof("failed to ensure latest llama.cpp: %v\n", err)
97-
if !errors.Is(err, errLlamaCppUpToDate) {
97+
if !(errors.Is(err, errLlamaCppUpToDate) || errors.Is(err, errLlamaCppUpdateDisabled)) {
9898
l.status = fmt.Sprintf("failed to install llama.cpp: %v", err)
9999
}
100100
if errors.Is(err, context.Canceled) {

0 commit comments

Comments
 (0)