registry: add Route.IsSidecar, sweep the bare Kind=="sidecar" literals
5 files changed,
+14
−6
internal/activator/activator.go+1 −1internal/edge/edge.go+1 −1internal/host/agent.go+1 −1internal/host/fleetbind.go+3 −3internal/registry/registry.go+8 −0
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 9d2e6fe04..8342a704e 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -1840,7 +1840,7 @@ func (a *Service) sweepOnce() { |
| // it would spawn via Start and spend the whole health-probe timeout |
| // dialling a socket it never binds. |
| var e *actEntry |
| - if rt.Kind == "sidecar" { |
| + if rt.IsSidecar() { |
| e = a.newWorkerEntry(rt) |
| } else { |
| e = &actEntry{host: rt.Host, route: rt, state: actWaking, ready: make(chan struct{})} |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index c3826cb2e..986f42e9f 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -325,7 +325,7 @@ func (e *Edge) Reload() error { |
| // structural guarantee that survives a future arm, column or |
| // placement finding the row: no map entry, so no proxy; and no map |
| // entry means Allowed says no, so no ACME issuance either. |
| - if t.Kind == "sidecar" { |
| + if t.IsSidecar() { |
| continue |
| } |
| // Only serve ready routes: a 'creating'/'failed' entry has no working |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index a77c7fb7b..9c196c2f2 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -403,7 +403,7 @@ func RunAgent(args []string) { |
| func workersToStart(routes []registry.Route) []registry.Route { |
| var out []registry.Route |
| for _, rt := range routes { |
| - if rt.Kind == "sidecar" && !rt.Hibernate && (rt.Status == "" || rt.Status == "ready") { |
| + if rt.IsSidecar() && !rt.Hibernate && (rt.Status == "" || rt.Status == "ready") { |
| out = append(out, rt) |
| } |
| } |
diff --git a/internal/host/fleetbind.go b/internal/host/fleetbind.go| index 710ea92f7..34e023605 100644 |
| --- a/internal/host/fleetbind.go |
| +++ b/internal/host/fleetbind.go |
| @@ -249,7 +249,7 @@ func ReconcileFleetBindings(ctx context.Context, s release.Store, reg *registry. |
| // of a mixed-version roll, and this platform box is what reads |
| // them. A binding is an untrusted claim written by another host; |
| // the route row is local truth. |
| - if rt.Kind == "sidecar" { |
| + if rt.IsSidecar() { |
| continue |
| } |
| if fleet, ok := registry.FleetPlacement(rt.Region); !ok || fleet != b.Fleet { |
| @@ -301,7 +301,7 @@ func ReconcileFleetBindings(ctx context.Context, s release.Store, reg *registry. |
| // fetching, so the refusal is now total and depends on no I/O at all. |
| func fleetBindingHook(store release.Store, fleet, box string) func(rt registry.Route) { |
| return func(rt registry.Route) { |
| - if rt.Kind == "sidecar" { |
| + if rt.IsSidecar() { |
| return |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| @@ -364,7 +364,7 @@ func publishResidentFleetBindings(store release.Store, fleet, box string, reg *r |
| func residentBindingHosts(routes []registry.Route) []string { |
| var out []string |
| for _, rt := range routes { |
| - if rt.Host == "" || rt.Kind == "sidecar" { |
| + if rt.Host == "" || rt.IsSidecar() { |
| continue |
| } |
| out = append(out, rt.Host) |
diff --git a/internal/registry/registry.go b/internal/registry/registry.go| index 775efbad1..5c1dd4e80 100644 |
| --- a/internal/registry/registry.go |
| +++ b/internal/registry/registry.go |
| @@ -237,6 +237,14 @@ func (t Route) AddrList() []string { |
| return nil |
| } |
| +// IsSidecar reports whether t is a standalone worker (Kind "sidecar") — a |
| +// process that serves no requests and that nothing can dial. A method |
| +// rather than a bare `Kind == "sidecar"` literal at each call site because |
| +// most of those sites are security EXCLUSIONS (the edge's dispatch, a |
| +// fleet's advertised set): a typo in a literal does not fail loudly, it |
| +// routes to or serves a sidecar. A method is typo-proof by construction. |
| +func (t Route) IsSidecar() bool { return t.Kind == "sidecar" } |
| + |
| // BackingUnit marks a route whose process is a carlos-app@<host> systemd unit |
| // rather than an exec child of the agent. The empty string stays the exec |
| // default so pre-existing rows keep today's behavior byte-identical. |