mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-30 01:54:31 -04:00
fix(failover): send remote targets their own upstream model
A chain request reached a cloud-proxy target with the client's model, the chain name, whenever the target set no upstream_model: passthrough forwards the body's model and translate falls back to it. The upstream answered 404, which neither retries nor trips, while the liveness probe, which checks the target's own name, kept passing. PrepareTarget now sets the upstream model of a remote target to proxy.upstream_model or the target name, the same name the probe uses. The request pipeline and realtime chain stages both call it. Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
1 parent
d1a59aae41
commit
e183ea11d1
8 files changed
+98
-7
No files matched your search
@@ -106,6 +106,11 @@ var _ = Describe("Failover chains", Label("failover"), func() {
|
||||
Expect(resp.Header.Get("X-LocalAI-Served-Model")).To(Equal("up-2"))
|
||||
Expect(resp.Header.Get("X-LocalAI-Failover")).To(Equal("fallback"))
|
||||
Expect(chainActive("chain-remote")).To(Equal("up-2"))
|
||||
// The targets set no upstream_model: each upstream must get its
|
||||
// target's name (what the liveness probe checks), not the chain
|
||||
// name the client sent. up-2 is healthy, so only this request
|
||||
// posted to it.
|
||||
Expect(upstreamBodyModel(up2)).To(Equal("up-2"))
|
||||
|
||||
up1.SetScript(chatReply)
|
||||
Eventually(func() string { return chainActive("chain-remote") }, 30*time.Second, 500*time.Millisecond).
|
||||
@@ -116,10 +121,22 @@ var _ = Describe("Failover chains", Label("failover"), func() {
|
||||
Expect(resp2.StatusCode).To(Equal(200))
|
||||
Expect(resp2.Header.Get("X-LocalAI-Served-Model")).To(Equal("up-1"))
|
||||
Expect(resp2.Header.Get("X-LocalAI-Failover")).To(BeEmpty())
|
||||
Expect(upstreamBodyModel(up1)).To(Equal("up-1"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// upstreamBodyModel returns the "model" field of the last request body the
|
||||
// fake upstream recorded.
|
||||
func upstreamBodyModel(up *fakeOpenAIUpstreamServer) string {
|
||||
_, _, _, body := up.recorder.snapshot()
|
||||
var req struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
Expect(json.Unmarshal(body, &req)).To(Succeed(), string(body))
|
||||
return req.Model
|
||||
}
|
||||
|
||||
// chainActive returns the active target of a chain as the REST status reports
|
||||
// it, or "" when the status cannot be read.
|
||||
func chainActive(chain string) string {
|
||||
|
||||
Reference in new issue
Block a user