mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-22 06:04:55 -04:00
Distributed mode has not dialled a message broker since the control plane moved onto the workers' own outward tunnels and every fan-out family moved onto PostgreSQL LISTEN/NOTIFY. What was left was the dependency itself, and the code that existed only to feed it. Dropped from go.mod: nats-io/jwt/v2, nats-io/nats.go, nats-io/nkeys, nats-io/nuid and testcontainers-go/modules/nats, along with the fourteen indirect requires that only the NATS testcontainer pulled in. go.sum carries no nats line either, so the removal is not the partial kind where the require goes and the checksum stays. Deleted with them: pkg/natsauth in full, the broker client's remaining options and TLS files, the per-node JWT minting on both the register and the approve path, and the natsauth.Config parameter threaded through the node routes. The credential manager is renamed and stripped rather than deleted, because it still holds the tunnel token that every re-registration rotates. The bus flags stay accepted and ignored, and are now hidden, on every command that had them, so an existing unit file, compose file or Helm values file still starts on the day of the upgrade. What is not kept is the validation that REQUIRED one: a distributed frontend started with no bus URL is no longer fatal. The TLS paths lose type:"existingfile" deliberately, so a certificate deleted along with the broker cannot fail a startup. One operator-visible behaviour change: --nats-require-auth no longer makes an agent worker wait through admin approval. Ask for that wait with --distributed-require-auth, which already implied it. It is documented in the migration section and pinned from both sides. A deployment now needs PostgreSQL and the frontends' own HTTP listener, and nothing else. coverage-baseline.txt moves from 54.2 to 62.0. Assisted-by: Claude Opus 5 [claude-code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
86 lines
3.3 KiB
Go
86 lines
3.3 KiB
Go
package cluster_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"github.com/mudler/LocalAI/pkg/httpclient"
|
|
"github.com/mudler/LocalAI/tests/e2e/distributed/cluster"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Cluster options", Label("Distributed"), func() {
|
|
It("rejects a binary path that does not exist", func() {
|
|
_, err := cluster.Start(cluster.Options{
|
|
Binary: filepath.Join(os.TempDir(), "definitely-not-local-ai"),
|
|
PGDSN: "postgres://test:test@127.0.0.1:5432/x?sslmode=disable",
|
|
LogDir: GinkgoT().TempDir(),
|
|
Frontends: 1,
|
|
})
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("local-ai binary"))
|
|
})
|
|
|
|
It("rejects a cluster with no frontends", func() {
|
|
_, err := cluster.Start(cluster.Options{
|
|
Binary: "/bin/true",
|
|
PGDSN: "postgres://test:test@127.0.0.1:5432/x?sslmode=disable",
|
|
LogDir: GinkgoT().TempDir(),
|
|
Frontends: 0,
|
|
})
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("at least one frontend"))
|
|
})
|
|
})
|
|
|
|
// The HTTP flow inside AdminSession and GetJSON cannot run here: it needs a
|
|
// built local-ai plus real Postgres, which arrives with the failover suites.
|
|
// These specs cover the argument validation that would otherwise panic on an
|
|
// out-of-range slice index inside a helper every later spec calls.
|
|
var _ = Describe("Admin session", Label("Distributed"), func() {
|
|
It("reports a clear error when the frontend index is out of range", func() {
|
|
c := cluster.ForTestingEmpty()
|
|
_, err := c.AdminSession(3)
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("frontend 3"))
|
|
})
|
|
|
|
It("reports a clear error when GetJSON names a frontend that does not exist", func() {
|
|
c := cluster.ForTestingEmpty()
|
|
err := c.GetJSON(httpclient.NewWithTimeout(time.Second), 1, "/api/nodes", &struct{}{})
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(ContainSubstring("frontend 1"))
|
|
})
|
|
})
|
|
|
|
// Like the admin specs above, these cover argument validation only. Killing,
|
|
// stopping and restarting a real replica needs a built local-ai plus Postgres,
|
|
// so those paths stay unexecuted until the failover suites land.
|
|
var _ = Describe("Failure primitives", Label("Distributed"), func() {
|
|
It("rejects an out-of-range frontend index rather than panicking", func() {
|
|
c := cluster.ForTestingEmpty()
|
|
Expect(c.KillFrontend(0)).To(MatchError(ContainSubstring("frontend 0 out of range")))
|
|
Expect(c.StopFrontendGracefully(2)).To(MatchError(ContainSubstring("frontend 2 out of range")))
|
|
Expect(c.KillWorker(1)).To(MatchError(ContainSubstring("worker 1 out of range")))
|
|
})
|
|
|
|
It("rejects a restart of a frontend index that does not exist", func() {
|
|
Expect(cluster.ForTestingEmpty().RestartFrontend(0)).
|
|
To(MatchError(ContainSubstring("frontend 0 out of range")))
|
|
})
|
|
|
|
It("rejects a negative index without treating it as an offset from the end", func() {
|
|
c := cluster.ForTestingEmpty()
|
|
Expect(c.KillFrontend(-1)).To(MatchError(ContainSubstring("frontend -1 out of range")))
|
|
Expect(c.KillWorker(-1)).To(MatchError(ContainSubstring("worker -1 out of range")))
|
|
Expect(c.FrontendAlive(-1)).To(BeFalse())
|
|
})
|
|
|
|
It("reports a frontend that was never started as not alive", func() {
|
|
Expect(cluster.ForTestingEmpty().FrontendAlive(0)).To(BeFalse())
|
|
})
|
|
})
|