Documentation
¶
Index ¶
- Constants
- Variables
- func RecordFits(record Record) bool
- func RecordWithinBudget(record Record) bool
- type CaptureStatus
- type CaptureVerificationStatus
- type ContainerState
- type Delta
- type Index
- func (index *Index) Ingest(kind string, records []Record, complete bool, observedAt time.Time) error
- func (index *Index) KindStatus(kind string) (KindStatus, bool)
- func (index *Index) Refresh(ctx context.Context, kind string, interval time.Duration, now time.Time, ...) error
- func (index *Index) RefreshGuarded(ctx context.Context, kind string, interval time.Duration, now time.Time, ...) error
- func (index *Index) Snapshot() Snapshot
- func (index *Index) Status(now time.Time) Status
- func (index *Index) Subscribe(buffer int) (<-chan Delta, func())
- type KindStatus
- type Loader
- type OwnerRef
- type Record
- type Registry
- type Scope
- type Snapshot
- type Status
- type SyncProgress
Constants ¶
const ( MaxLabels = maxLabels MaxSummaryFields = maxSummaryFields MaxOwners = maxOwners MaxImages = maxImages MaxImageBytes = maxImageBytes )
The per-record bounds every projection must respect. A projection that keeps more than these would hand the index a record it has to reject, so the projection reads these instead of guessing a larger size.
Variables ¶
var ( ErrInvalidRecord = errors.New("kubernetes index: invalid record") ErrRecordLimit = errors.New("kubernetes index: record limit exceeded") ErrScopeLimit = errors.New("kubernetes index: scope limit exceeded") // ErrKindNotServed reports that the cluster does not serve this kind, so a // caller never claims a listing that did not happen. The kind is still // recorded as known and empty; its first real listing later is a baseline, // not a wave of created changes. ErrKindNotServed = errors.New("kubernetes index: kind not served by the cluster") )
var SyncSteps = []string{"connected", "listing", "building", "metrics"}
SyncSteps are the first-sync steps in execution order: connect to the cluster, list resources, build the projections that are published, and read CPU and memory usage (which runs after the first publication).
Functions ¶
func RecordFits ¶ added in v1.4.32
RecordFits reports whether the index can hold this record, so a caller can check one record without ingesting it and without asking the index to reject a whole listing.
func RecordWithinBudget ¶ added in v1.4.32
RecordWithinBudget reports whether a record fits the per-record byte budget, including the allowance for container log metadata. A projection uses it to bound itself, because a record the index refuses costs the whole kind.
Types ¶
type CaptureStatus ¶ added in v1.4.31
type CaptureVerificationStatus ¶ added in v1.4.31
type ContainerState ¶ added in v1.4.31
type ContainerState struct {
Ready bool `json:"ready"`
Running bool `json:"running"`
StartedAt time.Time `json:"started_at,omitempty,omitzero"`
StateKnown bool `json:"state_known,omitempty"`
Name string `json:"name"`
Init bool `json:"init,omitempty"`
CurrentTermination bool `json:"current_termination,omitempty"`
WaitingReason string `json:"waiting_reason,omitempty"`
TerminatedReason string `json:"last_terminated_reason,omitempty"`
ExitCode int32 `json:"last_terminated_exit_code,omitempty"`
Signal int32 `json:"last_terminated_signal,omitempty"`
TerminatedAt time.Time `json:"last_terminated_at,omitempty,omitzero"`
RestartCount int32 `json:"restart_count"`
}
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func NewUnbounded ¶ added in v1.4.32
func NewUnbounded() *Index
NewUnbounded retains the per-record validation budget without limiting the number of safe projections in a complete background inventory.
func Restore ¶ added in v1.4.32
Restore validates a persisted projected generation without turning a failed refresh into a successful observation or resetting owner evidence timestamps.
func (*Index) KindStatus ¶
func (index *Index) KindStatus(kind string) (KindStatus, bool)
func (*Index) Refresh ¶
func (index *Index) Refresh(ctx context.Context, kind string, interval time.Duration, now time.Time, load Loader) error
Refresh loads one kind at most once per interval. Concurrent readers wait for the same bounded load instead of issuing duplicate cluster requests.
func (*Index) RefreshGuarded ¶ added in v1.4.31
type KindStatus ¶
type KindStatus struct {
State string `json:"state"`
// A time that was never observed is omitted rather than serialized as
// 0001-01-01T00:00:00Z, so no client can render it as a date.
ObservedAt time.Time `json:"observed_at,omitzero"`
// CompletedAt bounds when records from the latest successful (possibly
// partial) load became visible. ObservedAt is the LIST start, not its end.
CompletedAt time.Time `json:"completed_at,omitzero"`
LastAttemptAt time.Time `json:"last_attempt_at,omitzero"`
Records int `json:"records"`
Partial bool `json:"partial"`
Error string `json:"error,omitempty"`
// FailingSince is when this failure began. It is set on the transition into
// a failing state or class and kept until the kind recovers, so a surface can
// say how long a kind has been failing instead of how long ago it retried.
FailingSince time.Time `json:"failing_since,omitzero"`
// Skipped counts records the latest listing could not keep. It is never
// zero for an incomplete report: a dropped record is always counted, so a
// kind that lost data says so instead of looking complete.
Skipped int `json:"skipped,omitempty"`
// Absent marks a kind the cluster does not serve: it was never listed, so
// the first listing that comes back later is a baseline rather than a wave
// of created changes.
Absent bool `json:"absent,omitempty"`
// CycleFailure marks a state that came from the failure of a whole inventory
// cycle rather than from this kind's own listing. A cycle that cannot run
// says the connector could not read anything at all, so it stays a fault even
// when its class is a permission class: a per-kind capability gap and a dead
// credential are different problems with different remedies.
CycleFailure bool `json:"cycle_failure,omitempty"`
// contains filtered or unexported fields
}
type Record ¶
type Record struct {
APIVersion string
UID string
Kind string
Namespace string
Name string
ResourceVersion string
Generation int64
Labels map[string]string
Selector map[string]string
References map[string][]string
Owners []OwnerRef
// OwnerObservedAt is the first load completion for these owner references.
// Re-lists preserve it; a new UID or changed owner references reset it.
OwnerObservedAt time.Time
Target *OwnerRef
CreatedAt time.Time
Phase string
EventType string
NodeName string
NodeReady bool
Images []string
Summary map[string]string
Replicas int32
Ready int32
Available int32
ObservedGeneration int64
RequestedCPUMilli int64
RequestedMemoryByte int64
AllocatableCPUMilli int64
AllocatableMemory int64
Health string
Containers []ContainerState
LogContainers []ContainerState
MainContainer string
LogContainersPartial bool
ReadyStatus string
ReadyTransitionAt time.Time
ProgressingStatus string
ProgressingReason string
ProgressingTransitionAt time.Time
AvailableStatus string
AvailableTransitionAt time.Time
UpdateRevision string
CurrentRevision string
Revision string
Updated int32
EventFirstAt time.Time
EventLastAt time.Time
EventCount int32
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewUnboundedRegistry ¶ added in v1.4.32
NewUnboundedRegistry scopes inventories without limiting their record count.
type Snapshot ¶
type Snapshot struct {
Records []Record
Kinds map[string]KindStatus
}
type Status ¶
type Status struct {
State string `json:"state"`
AgeSeconds float64 `json:"age_s"`
Partial bool `json:"partial"`
Kinds map[string]KindStatus `json:"kinds"`
Capture *CaptureStatus `json:"capture,omitempty"`
Progress *SyncProgress `json:"progress,omitempty"`
// Pending lists requested resource IDs not listed yet; PendingKinds counts
// every resource type the cluster's published inventory still lacks.
Pending []string `json:"pending,omitempty"`
PendingKinds int `json:"pending_kinds,omitempty"`
}
type SyncProgress ¶ added in v1.4.32
type SyncProgress struct {
// Step is the step in progress, one of SyncSteps.
Step string `json:"step"`
StepIndex int `json:"step_index"`
StepTotal int `json:"step_total"`
StepsDone []string `json:"steps_done"`
// Counts holds records listed so far per Kubernetes kind. A kind appears
// once its list completes.
Counts map[string]int `json:"counts"`
// KindsDone counts resolved checks, including absent APIs and unreadable kinds;
// Counts contains only successfully listed records.
KindsDone int `json:"kinds_done"`
KindsTotal int `json:"kinds_total"`
ClusterVersion string `json:"cluster_version,omitempty"`
NodeCount *int `json:"node_count,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
RemainingKinds []string `json:"remaining_kinds,omitempty"`
KindStatus map[string]string `json:"kind_status,omitempty"`
PhaseStatus map[string]string `json:"phase_status,omitempty"`
PhaseSeconds map[string]float64 `json:"phase_seconds,omitempty"`
}
SyncProgress describes a cluster's first inventory sync until the first ready generation has been published. It only reports what the background sync has already observed; it never claims the data is complete.