From 6dba6bd93a270f747d90b77f6bf216699757d42a Mon Sep 17 00:00:00 2001 From: Ilker Manap Date: Mon, 28 Sep 2026 13:06:29 +0200 Subject: [PATCH] Run a control plane when there is nothing else to run A configuration with no static endpoints and no models was refused as having nothing to serve. That is every new cluster: under systemd the unit restarted every two seconds and nothing ever listened on 8080. With no endpoints a router-only process has nothing it could serve, so such a configuration is now a control plane with an empty catalog. Static endpoints without profiled models remain router-only. Co-Authored-By: Claude Opus 5.5 (1M context) --- internal/config/config.go | 8 +++++++- internal/config/config_test.go | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index a2e9fd6..e00a51e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -540,8 +540,14 @@ func (s Server) Catalog() (*catalog.Catalog, error) { // A model with no profiles cannot be placed, so a configuration of bare names // plus a static endpoint list is the router-only mode used for testing against // sim-engines. +// +// With no static endpoints there is nothing a router-only process could serve, +// so a configuration naming neither endpoints nor models is a control plane +// with an empty catalog — which is what every new cluster is. It used to be +// refused as having nothing to serve, and under systemd that is a unit +// restarting every two seconds with nothing on 8080. func (s Server) ControlPlaneMode() bool { - if s.Control.Enabled { + if s.Control.Enabled || len(s.Endpoints) == 0 { return true } for _, m := range s.Models { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index a75eba8..47c1bb8 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -155,19 +155,26 @@ func TestValidateAcceptsDistinctAliases(t *testing.T) { } } -func TestAControlPlaneCanBeAskedForWithNoModelsInTheFile(t *testing.T) { - // Without this, a deployment whose catalog lives entirely in the database - // cannot start: the mode is inferred from the file, an empty models block - // reads as "router only", and the process refuses to start for want of - // anything to serve — so the stored models it would have loaded are never - // read at all. +func TestAnEmptyConfigurationIsAControlPlane(t *testing.T) { + // A new cluster has no models and no endpoints. Refusing it as having + // nothing to serve left a systemd unit restarting every two seconds and + // nothing listening on 8080 — on the first start anyone ever made. var s Server + if !s.ControlPlaneMode() { + t.Fatal("a configuration with no endpoints and no models should run a control plane") + } +} + +func TestStaticEndpointsAloneAreRouterOnly(t *testing.T) { + var s Server + s.Endpoints = []Endpoint{{ID: "e", URL: "http://127.0.0.1:1"}} + s.Models = []catalog.Model{{Name: "m"}} if s.ControlPlaneMode() { - t.Fatal("an empty configuration is not a control plane") + t.Error("static endpoints and bare model names are the router-only mode") } s.Control.Enabled = true if !s.ControlPlaneMode() { - t.Error("control.enabled should run the control plane with no models declared") + t.Error("control.enabled should run the control plane alongside static endpoints") } }