Documentation
¶
Overview ¶
Package rosterprobe is how the single-shot fleet lanes — vision, text, stt upload, compose, media and the accelerator forwarder — read the fleet roster (config delegate_remotes) before they pick a node for ONE call.
Rules that live here so that six lanes cannot drift apart on them (ADR 0074):
- ADMISSION. A roster entry is judged by the same tailnet shape check the agent lane applies (netguard.TailnetURL) before it is dialled. The lanes used to rely on the dial gate alone, so one entry was refused by one lane and used by the others, and a bad entry got no message naming the key. A refused entry is a named miss, never a failed call: the other entries still serve.
- READING. The roster is probed CONCURRENTLY, in the order it is configured, with a short process-wide memo of good answers and a negative cache of transport failures, so k dead nodes cost one probe bound, once per cache window, instead of k bounds in series on the critical path of every call (see Probe and its timings).
The agent lane keeps its own admission and reading inside internal/delegate (per Run, at its own bound); this package is the single-shot lanes' and the doctor's.
Index ¶
- Constants
- Variables
- func CheckToken(ctx context.Context, base, token string) (status int, body string, err error)
- func IsRefusal(err error) bool
- func NoRedirect(*http.Request, []*http.Request) error
- func Scrub(base string, err error) string
- func Scrubbed(base string, err error) error
- type Cache
- type Member
- type Reading
- type Refusal
- type TokenState
Constants ¶
const ( DefaultTimeout = 5 * time.Second MemoTTL = 2 * time.Second NegativeTTL = 30 * time.Second TransientNegativeTTL = 5 * time.Second )
The timings, in one place (docs/systems/fleet-node.md, "The single-shot lanes read the same roster"):
DefaultTimeout 5 s how long ONE lane call waits for ONE node's /fleet/health. A single-shot call
pays it on its own critical path, so it is shorter than the 15 s the delegator
gives a node whose work lasts minutes (a node between the two is a candidate
there and a miss here, and the miss is named). The accelerator lane keeps its 2 s.
MemoTTL 2 s a GOOD answer is reused this long, by every lane in the process, so a burst of
calls reads each node once. It is the delegator's own memo window.
NegativeTTL 30 s a node that failed at the TRANSPORT is not dialled again for this long. It is
the delegator's window too: long enough that a call stops paying a probe bound for
a box that is down, short enough that a node that reboots is picked up again.
TransientNegativeTTL 5 s the cap on that window for the failures a node shows while it is only BUSY or
restarting: it did not answer in time, or the dial was refused or unroutable. A box
that comes back inside half a minute is back in rotation within seconds, not held
out for the rest of NegativeTTL; a DNS failure or a TLS fault keeps the full window.
Constants, not variables: nothing mutates a package-level window, so two tests (or a test and a running lane) can never see each other's. A cache carries its own copy (NewCache), which a test in this package sets on its own *Cache beside a fake clock.
const ( SourceProbe = "" // read from the node just now (or by a concurrent caller's probe this one joined) SourceMemo = "memo" // a good answer from the last MemoTTL SourceNegative = "negative" // a transport failure from the last NegativeTTL, replayed without a dial )
Where a Reading came from, for a caller that wants to say so.
Variables ¶
var Default = NewCache()
Default is the cache every lane shares.
Functions ¶
func CheckToken ¶
CheckToken sends the token probe to base with the bearer and returns the HTTP status and a short excerpt of the body (for ClassifyToken; callers do not print it). An empty token sends no Authorization header, which asks the same question of a node that wants none. A base the tailnet guard refuses is never sent the bearer: the error is a *Refusal. A transport failure is the error.
func IsRefusal ¶
IsRefusal reports whether err is a Refusal: the entry was judged and never dialled.
func NoRedirect ¶
NoRedirect is the CheckRedirect of every client that sends the fleet bearer to a roster node: it returns the 3xx to the caller instead of following it. The bearer is meant for the node the operator listed, and a node (or a proxy in front of it) that redirects would otherwise have the client replay the request, headers included, at a Location it chose (net/http keeps Authorization across a redirect that changes only the port, and re-sends a 307/308 body). The dial gate still confines the destination to the tailnet; this keeps the bearer on the entry that was named.
func Scrub ¶
Scrub is err as it may be printed for the entry base. A dial or guard error quotes the URL it was given (a net/http error quotes the request URL, and the health reader quotes the URL it built), so the raw base in its text is replaced by the redacted one; any other URL left in the text has its userinfo, query and fragment masked too, because the HTTP client re-serializes the URL it dials (userinfo password replaced by ***, escapes untouched) and a replace of the configured string alone would miss that spelling. The cause and the host stay: only the secrets go.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds the memo, the negative cache and the probes in flight. One process-wide instance (Default) backs every lane, so what the vision lane learns about a dead node saves the text lane the same wait.
func (*Cache) Forget ¶
Forget drops the negative verdict held against base. A lane calls it when a call to that node SUCCEEDED by a road other than a health probe (a dispatch that was accepted): the node is evidently up, and replaying "unreachable" to the next call for the rest of the window would pass over a node that is serving. A probe that succeeds does the same by itself. base is the entry as Members normalizes it (Member.Base); a trailing slash or surrounding space is tolerated.
func (*Cache) Probe ¶
func (c *Cache) Probe(ctx context.Context, remotes []string, token string, timeout time.Duration) []Reading
Probe reads every admitted member's /fleet/health CONCURRENTLY, each bounded by timeout (and by ctx, which wins when shorter), and returns one Reading per member in CONFIGURED order: the accelerator lane's "first listing node" and the compose lane's "config order breaks ties" depend on that order, and completion order is not one any caller can use. A refused member is returned flagged and never dialled. The wall time is the slowest member, not the sum.
A good answer is memoised for MemoTTL. A TRANSPORT failure (dial refused, no route, DNS, a reset, the per-member timeout) is negative-cached and replayed without a dial: for NegativeTTL, capped at TransientNegativeTTL when it is the kind a busy or restarting node shows (timeout, refused or unroutable dial). A 401, 404 or 503, or a body that is not health, is a node that ANSWERED and is never cached. Nothing is cached once ctx is done: a cancelled call says nothing about a node.
Callers that arrive while another is already probing the same base under the same bound wait for that probe's answer instead of dialling again, so a burst of lanes on a cold cache costs the node one request.
type Member ¶
type Member struct {
// Index is the entry's position in the configured list, blanks included, so a lane that
// breaks ties by "config order" and a message that names an entry both mean the same slot.
Index int
// Base is the entry trimmed of whitespace and trailing slashes.
Base string
// Refused is why the tailnet guard will not admit the entry (a *Refusal); nil when it
// admits it. A refused member is never dialled.
Refused error
}
Member is one delegate_remotes entry as a lane sees it: normalized, and judged.
func Members ¶
Members normalizes and vets the roster. A blank entry is an unset slot (the key's own loader exempts it) and is left out; every other entry comes back in configured order, the refused ones flagged rather than dropped, so a lane can name each in its "probed ..." line.
func (Member) Miss ¶
Miss words a refused member the way a lane words every other reason it passed a node over: the base first, then the cause. It names what was NOT done, so "no node is eligible" never reads as though the entry had been tried. The base is printed redacted (Shown): an entry may have been pasted with a token in it, and these lines reach chats.
type Reading ¶
type Reading struct {
Member
// View is the node's health, valid only when Err is nil. Views may be shared between callers
// (the memo hands out copies of one reading), so a lane reads them and never edits one.
View delegate.NodeView
// Err is why there is no View: the entry was refused (see Member.Refused), the node did not
// answer, answered with a status, or answered something that is not health.
Err error
// Source says whether this was dialled now, served from the memo, or replayed from the
// negative cache.
Source string
}
Reading is what a lane learned about one roster member.
func (Reading) Miss ¶
Miss words why a lane passed this member over, the same way for every cause: a refused entry says it was not dialled, anything else is the base and the error the probe returned. Both print the base redacted and the error scrubbed (Shown, Scrub), so no credential an entry was pasted with reaches a lane's "probed ..." line.
type Refusal ¶
type Refusal struct{ Reason error }
Refusal is the tailnet guard's verdict on a roster entry, as an error a caller can tell from a failed dial: errors.As(err, new(*Refusal)). Reason is the guard's own message, which names the entry only in its redacted form (netguard.TailnetURLIn), so a Refusal is safe to print.
type TokenState ¶
type TokenState int
TokenState is what a node's answer to the token probe means.
const ( // TokenUnknown: the answer says nothing about the token (an older node, a proxy, another status). TokenUnknown TokenState = iota // TokenAccepted: the bearer passed the node's check. TokenAccepted // TokenMismatch: the node has a token and this bearer is not it (401). TokenMismatch // TokenNodeHasNone: the node has no fleet_auth_token and listens beyond loopback (403). TokenNodeHasNone )
func ClassifyToken ¶
func ClassifyToken(status int, body string) TokenState
ClassifyToken reads a node's answer to the probe. A 400 counts as acceptance only when it is the `job_id required` refusal: any other 400 (a node that predates the agent lane says `unsupported task_type`) proves nothing about the bearer.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package rostertest is test support for code that reads the fleet roster: a black-holed node and a way to pin the tailnet zones for one test.
|
Package rostertest is test support for code that reads the fleet roster: a black-holed node and a way to pin the tailnet zones for one test. |