Documentation
¶
Overview ¶
Package coldstart decides how an agent resolves a digest when its local cache misses and the DHT lookup did not return enough providers.
The mirror miss path invokes ChairResolver after a FindProviders call returns empty. Resolution is driven by the fixed set of Lease chairs: the requester ranks the chairs for the digest, asks the leading cohort to pull from the origin registry, and polls the DHT until one of them publishes. See chair.go for the cascade and the outcomes it can produce.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFailureShortCircuit reports that a chair returned a failure the // requester trusts enough to stop asking further chairs. ErrFailureShortCircuit = errors.New("coldstart: failure short-circuit") // ErrCooldownActive reports that the origin pull is in a transient // backoff window, so the requester should not pile on. ErrCooldownActive = errors.New("coldstart: transient cooldown active") // ErrExhausted fires when the cascade reaches its terminal state // without producing a provider (the chair ranking ran out, or // please_pull completed but the DHT poll timed out). ErrExhausted = errors.New("coldstart: cascade exhausted") )
Sentinel errors. The mirror layer maps all of these to 5xx; tests distinguish them to validate which rule fired.
var ErrPrefetchInvalid = errors.New("coldstart: prefetch invalid arguments")
ErrPrefetchInvalid signals a programmer error in the prefetch call: registry or repository was empty, which would produce a malformed please_pull request.
var ErrPrefetchPartial = errors.New("coldstart: prefetch had per-puller failures")
ErrPrefetchPartial signals that at least one chair's please_pull failed. The other chairs were still asked to pull. Callers can errors.Is against this for retry or logging logic; prefetch is best-effort, so this is informational rather than fatal.
Functions ¶
This section is empty.
Types ¶
type ChairClaimer ¶ added in v0.7.0
type ChairOptions ¶ added in v0.7.0
type ChairOptions struct {
Chairs ChairSnapshotCache
Discovery Discovery
Coord ifaces.ChairCoordinator
LocalPull ifaces.LocalChairPullStarter
Inflight *inflight.Map
SelfPeerID ifaces.NodeID
CurrentEpoch func() int64
InstallHolder func(chairs.Holder) error
Claimer ChairClaimer
Logger *slog.Logger
QueryTimeout time.Duration
PollManifest time.Duration
PollLayer time.Duration
APITimeout time.Duration
SeedCount int
TrustedFailureClasses []ifaces.FailureClass
// OnSeedRecruit reports one completed seed-recruitment pass: how many chairs
// were selectable, how many were contacted, and how many accepted. contacted
// above SeedCount means the cohort accepted nothing and the resolver moved
// down the ranking, which widens the set of nodes fetching from origin.
OnSeedRecruit func(kind string, selectable, contacted, accepted int)
// OnChairDispatch reports the outcome of one please_pull to one chair.
// reason is "accepted" or why the chair did not count: "rpc_error" (no
// usable reply inside QueryTimeout), "recently_failed", "stale_chair", or
// "declined". Only rpc_error is invisible to the chair itself.
OnChairDispatch func(kind, reason string)
// OnChairCall times one please_pull attempt against a remote chair.
// outcome separates a clean reply from "deadline" (QueryTimeout expired),
// so a run can tell a binding deadline from slow transport: deadline
// outcomes pile up at QueryTimeout, transport shows a long ok tail.
OnChairCall func(kind, outcome string, seconds float64)
}
type ChairResolver ¶ added in v0.7.0
type ChairResolver struct {
// contains filtered or unexported fields
}
func NewChairResolver ¶ added in v0.7.0
func NewChairResolver(opts ChairOptions) *ChairResolver
func (*ChairResolver) PrefetchManifestChildren ¶ added in v0.7.0
func (r *ChairResolver) PrefetchManifestChildren(ctx context.Context, _ digest.Digest, children []ChildDigest, registry, repository string) error
func (*ChairResolver) Resolve ¶ added in v0.7.0
func (r *ChairResolver) Resolve(ctx context.Context, d digest.Digest, kind ifaces.OriginRefKind, registry, repository string, expectedSize int64) (*Resolution, error)
type ChairSnapshotCache ¶ added in v0.7.0
type ChildDigest ¶
type ChildDigest struct {
Digest digest.Digest
Kind ifaces.OriginRefKind
}
ChildDigest is a manifest child paired with its kind. Config blobs and layer blobs are both pulled from /v2/<repo>/blobs/<digest> but are carried separately on the wire so per-kind metrics agree end-to-end across the please_pull boundary. internal/manifest's TypedChildren is the canonical producer of these values.
type Discovery ¶
type Discovery interface {
FindProviders(ctx context.Context, d digest.Digest) ([]ifaces.Provider, error)
Health() float64
}
Discovery is the subset of the libp2p discovery host that the orchestrator needs. Kept narrow for ease of mocking.
type Resolution ¶
type Resolution struct {
// Providers are transfer endpoints (host:port) the caller should
// fetch from, in priority order. Non-empty on success.
Providers []ifaces.Provider
// Outcome names which rule fired. Useful for tests and metrics.
Outcome string
}
Resolution carries the orchestrator's verdict.