Documentation
¶
Overview ¶
Package routedns answers "where does this sandbox hostname go?" for a static Caddy config (plans/ingress-proxy-routing.md §3.2, task T3).
Caddy's config stays static. Instead of one route per sandbox (each route write reloads Caddy's whole config and drops ~2.6% of new connections), Caddy asks a loopback DNS responder:
owner: reverse_proxy dynamic A name={http.request.host}. → OwnerTable
ingress: caddy-l4 dial "{l4.tls.server_name}.rt.internal" → IngressIndex
Bytes stay in Caddy. sandboxd only answers where, so a sandboxd restart never resets established connections. Both tables are keyed by the EXACT hostname Caddy's old per-sandbox matchers used. Nothing parses sandbox IDs out of hostnames on the answer path; IDs may contain dashes, so parsing would be ambiguous.
Index ¶
- Constants
- func DerivedPort(host string, toolboxPort int) int
- type IngressEntry
- type IngressIndex
- type MissLookup
- type OwnerTable
- func (t *OwnerTable) Delete(host string)
- func (t *OwnerTable) DeleteFunc(match func(host string) bool)
- func (t *OwnerTable) Len() int
- func (t *OwnerTable) Lookup(host string) (OwnerTarget, bool)
- func (t *OwnerTable) Set(host string, target OwnerTarget)
- func (t *OwnerTable) SetState(host string, state TargetState)
- type OwnerTarget
- type Responder
- type TargetState
Constants ¶
const ( ProbeName = "_aerolvm-route-probe." + IngressZone ProbeIP = "127.0.0.9" )
ProbeName is answered with ProbeIP so a boot check can prove the node's SYSTEM resolver routes the ingress zone to this responder. caddy-l4 dials through that resolver; a node whose routing domain is missing must not turn the flag on.
const IngressZone = caddy.RouteDNSZone
IngressZone is the suffix caddy-l4 appends to the SNI before dialing ("{l4.tls.server_name}.rt.internal"). The node's resolver routes this domain (and only this domain) to the responder.
Variables ¶
This section is empty.
Functions ¶
func DerivedPort ¶
DerivedPort is the port Caddy's static map yields for host.
Types ¶
type IngressEntry ¶
type IngressEntry struct {
SandboxID string
OwnerNodeID string
OwnerHost string // data-plane host (IP or DNS name)
// Routable: public, actively owned, not reserved or deleting. A known
// but unroutable host is answered like an unknown one (the local router
// gives 503/404), never spliced to a guessed owner.
Routable bool
Custom bool // a tenant custom domain (not under the platform domain)
// Why an entry is not routable, for the router's answer: Private → 404
// (the sandbox exists but is not public); InFlux → 503 + Retry-After
// (orphaned, reserved, deleting, or no data-plane host yet).
Private bool
InFlux bool
}
IngressEntry is where one SNI hostname goes from an ingress node.
type IngressIndex ¶
type IngressIndex struct {
// contains filtered or unexported fields
}
IngressIndex maps every SNI hostname of every placement to its owner. It covers ALL placements (review T3): any ingress routes any sandbox, and routing does not depend on a shard-aware load balancer. It is rebuilt from the placement view (the delta feed keeps that current) and swapped in atomically.
func NewIngressIndex ¶
func NewIngressIndex() *IngressIndex
func (*IngressIndex) Len ¶
func (x *IngressIndex) Len() int
func (*IngressIndex) Lookup ¶
func (x *IngressIndex) Lookup(host string) (IngressEntry, bool)
func (*IngressIndex) Remove ¶
func (x *IngressIndex) Remove(sandboxID string)
Remove drops every host of a deleted placement.
type MissLookup ¶
MissLookup resolves a placement the ingress index doesn't hold yet (a brand-new sandbox's first connection). It is the cluster's internal placement point read.
type OwnerTable ¶
type OwnerTable struct {
// contains filtered or unexported fields
}
OwnerTable is the owner node's route table: what Caddy's per-sandbox http routes used to hold. The service's route-intent seam (publicRouteWriter) maintains it, so it has exactly the semantics of the routes it replaces.
func NewOwnerTable ¶
func NewOwnerTable() *OwnerTable
func (*OwnerTable) Delete ¶
func (t *OwnerTable) Delete(host string)
func (*OwnerTable) DeleteFunc ¶
func (t *OwnerTable) DeleteFunc(match func(host string) bool)
DeleteFunc removes every host match selects (e.g. all of a sandbox). It mirrors Caddy's DeleteSandboxRoute, which also dropped the sandbox's custom-hostname matchers that rode the root route.
func (*OwnerTable) Len ¶
func (t *OwnerTable) Len() int
func (*OwnerTable) Lookup ¶
func (t *OwnerTable) Lookup(host string) (OwnerTarget, bool)
func (*OwnerTable) Set ¶
func (t *OwnerTable) Set(host string, target OwnerTarget)
Set records a target. An empty host is ignored.
func (*OwnerTable) SetState ¶
func (t *OwnerTable) SetState(host string, state TargetState)
SetState changes only the state of an existing or new entry (wake and in-flux routes carry no upstream).
type OwnerTarget ¶
type OwnerTarget struct {
IP net.IP
Port int
State TargetState
// SandboxID and GuestPort let the sandboxd router serve a fallback
// request (wake, masked, mediator) through the existing wake proxy.
SandboxID string
GuestPort int
}
OwnerTarget is where one hostname goes on its owner node.
type Responder ¶
type Responder struct {
// Domain is the platform domain ({id}.{Domain}).
Domain string
// SelfNodeID identifies placements this node owns.
SelfNodeID string
// LocalIP is the node-local listener that terminates with the wildcard
// cert and routes through the static route: used for owner == self, and
// for unroutable platform hosts so the local router can answer 503/404
// (review 1A, wildcard only per T5).
LocalIP net.IP
// ToolboxPort is the static map's default port (root host).
ToolboxPort int
Owner *OwnerTable
Ingress *IngressIndex
Miss MissLookup
// NegativeTTL bounds how long a failed on-miss lookup is remembered, so
// a flood of connections for an unknown host costs one control-plane
// read, not one per connection.
NegativeTTL time.Duration
// contains filtered or unexported fields
}
Responder is the loopback DNS server Caddy consults.
func (*Responder) ListenAndServe ¶
ListenAndServe serves UDP and TCP on addr (loopback) until ctx ends.
type TargetState ¶
type TargetState int
TargetState distinguishes an answerable upstream from a hostname that must fall back to the sandboxd router (Caddy's static fallback upstream), which owns wake-on-request and in-flux 503s.
const ( TargetReady TargetState = iota // answer A with the target IP TargetWake // serverless and stopped: router wakes it TargetInFlux // failover or placement in flux: router answers 503 // TargetRouter always takes the fallback: the route needs per-route // behaviour a static Caddy route cannot express, such as E2B // maskRequestHost (a per-route upstream Host rewrite). The router already // applies it. TargetRouter )