Documentation
¶
Overview ¶
Package lastcreate hosts the in-process Sandbox.Create timestamp tracker that the Pool autoscaler's quiet-window gate consumes.
Motivation: every Sandbox.Create request needs to bump "this Pool was recently asked for a sandbox" so the autoscaler can decide whether proactive idleZero scale-up is justified. Writing that timestamp to the SandboxPool annotation on every Create would put high-QPS write pressure on the K8s API server. The Tracker accumulates Bumps in memory and flushes at most once every `flushInterval` per Pool.
Because cmd/sandbox runs the API server and the controller manager in one process (see CLAUDE.md §Three Binaries), the in-memory value is directly readable by the Pool autoscaler's Snapshot loader through the LastCreateTracker interface in pkg/controllers/sandboxpool/autoscalingstate/. The persisted annotation only matters across process restarts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker records the most recent Sandbox.Create timestamp per Pool and periodically flushes the dirty entries to the SandboxPool annotation (LastSandboxCreateTimeAnnotationKey).
All methods are safe for concurrent use.
Tracker is constructed with NewTracker and bound to a controller-runtime client; the flush loop is driven by Start, which satisfies the manager.Runnable interface so the controller manager owns its lifecycle.
func NewTracker ¶
NewTracker constructs a Tracker bound to c. flushInterval <= 0 uses the package default (5 s). Both arguments may be omitted only in unit tests via NewTrackerForTest.
func (*Tracker) Bump ¶
Bump records the current time as the most-recent Sandbox.Create for the named Pool. Safe to call from any goroutine on the request hot path; takes a brief mutex.
Nil receiver is a no-op so the call site can skip nil checks when the tracker has not been wired (e.g. unit-test SandboxService).
func (*Tracker) Get ¶
Get returns the most recent observed Create time for the Pool and a bool indicating whether any Bump has been recorded. Satisfies the LastCreateTracker interface consumed by pkg/controllers/sandboxpool/autoscalingstate.
Nil receiver returns (zero, false) — the autoscaler then falls back to the persisted annotation on the Pool object.
func (*Tracker) Start ¶
Start drives the periodic flush loop until ctx is cancelled. Satisfies sigs.k8s.io/controller-runtime/pkg/manager.Runnable so the controller manager can own its lifecycle via mgr.Add(tracker).
Start blocks the calling goroutine; pass the manager's root context (controller-runtime guarantees cancellation on shutdown).