Status: empty lists as [] not null
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
443bf12612
commit
2bae1a5174
5 files changed
+45
-1
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# Sits on Ollama's usual port (:11434); Ollama itself moves to 127.0.0.1:11435 (ollama.service.d/gpu-broker.conf).
|
||||
[Unit]
|
||||
Description=gpu-broker: Ollama proxy (lease before a model loads, CPU fallback when GPUs are busy)
|
||||
After=gpu-broker.service ollama.service
|
||||
Wants=gpu-broker.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/gpu-broker ollama-proxy --listen 0.0.0.0:11434 --upstream http://127.0.0.1:11435 --broker http://127.0.0.1:8130 --max-wait 1m --cpu-threads 4 --prefer 1
|
||||
DynamicUser=yes
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,13 @@
|
||||
# GPU scheduler on yveltal (gitea ziadarafat/gpu-broker). API on 127.0.0.1:8130, /metrics.
|
||||
[Unit]
|
||||
Description=gpu-broker: GPU leases, priority queue, CPU fallback
|
||||
After=nvidia-persistenced.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/gpu-broker serve --listen 127.0.0.1:8130 --reserve 0=1500
|
||||
DynamicUser=yes
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,7 @@
|
||||
# /etc/systemd/system/ollama.service.d/gpu-broker.conf (gpu-broker design, option 1 rules)
|
||||
[Service]
|
||||
# The gpu-broker Ollama proxy now owns :11434
|
||||
Environment="OLLAMA_HOST=127.0.0.1:11435"
|
||||
# Idle models give their VRAM back after 10 minutes; at most two models loaded
|
||||
Environment="OLLAMA_KEEP_ALIVE=10m"
|
||||
Environment="OLLAMA_MAX_LOADED_MODELS=2"
|
||||
@@ -82,7 +82,9 @@ func (h handlers) ReleaseLease(_ context.Context, r api.ReleaseLeaseRequestObjec
|
||||
|
||||
func (h handlers) Status(_ context.Context, _ api.StatusRequestObject) (api.StatusResponseObject, error) {
|
||||
st := h.s.Status()
|
||||
out := api.Status200JSONResponse{TtlS: int(h.ttl / time.Second)}
|
||||
out := api.Status200JSONResponse{
|
||||
TtlS: int(h.ttl / time.Second), Gpus: []api.GpuStatus{}, Leases: []api.LeaseInfo{}, Waiting: []api.WaitInfo{},
|
||||
}
|
||||
for _, g := range st.GPUs {
|
||||
out.Gpus = append(out.Gpus, api.GpuStatus{Index: g.Index, TotalMb: g.TotalMB, UsedMb: g.UsedMB, ReserveMb: g.ReserveMB, FreeMb: g.FreeMB})
|
||||
}
|
||||
|
||||
@@ -117,3 +117,11 @@ func TestMetricsShowFreeVRAMPerGPU(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyListsAreArraysNotNull(t *testing.T) {
|
||||
c, _ := start(t, 0, 0)
|
||||
r, _ := c.StatusWithResponse(context.Background())
|
||||
if !strings.Contains(string(r.Body), `"leases":[]`) || !strings.Contains(string(r.Body), `"waiting":[]`) {
|
||||
t.Fatalf("%s", r.Body)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user