Documentation
¶
Overview ¶
Package registry is the inventory of workloads: their labels, enforcement mode, reported host facts and the addresses derived from them, listening services, agent details, and the convergence state the sync stream reports. The certificate authenticates; the registry authorizes (ADR-0016). Labels are the only input to policy; addresses are an input to rendering because peers resolve to them (ADR-0018).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLabelsChanged = errors.New("registry: the workload's labels have changed since they were read")
ErrLabelsChanged is returned by a conditional label write whose expected version is not the labels' current one. The error carrying it is a *LabelsVersionError naming the current version.
var ErrWorkloadUnknown = errors.New("registry: workload is not registered")
ErrWorkloadUnknown is returned when an id is not registered.
Functions ¶
func AddressesFromFacts ¶
func AddressesFromFacts(facts *innerwallv1.HostFacts) []netip.Addr
AddressesFromFacts derives the addresses a workload can be reached at from its reported interfaces: every unicast address that is not loopback, link-local, multicast, or unspecified, in sorted order without duplicates. These become host routes in peers' rendered policies. An address that does not parse is skipped; facts are descriptive input from the host and never trusted to be well-formed.
func LabelsVersion ¶
LabelsVersion is the version of a workload's labels: a digest of the set itself, since nothing persisted records when labels last changed and the set is the whole of what an operator edits. Two label sets that say the same thing have the same version, whatever order they were written in.
Types ¶
type ClockSkew ¶ added in v0.2.0
type ClockSkew struct {
// Offset is the agent's clock minus the control plane's in the latest
// skewed report: negative when the agent is behind.
Offset time.Duration
// ObservedAt is when that report was received.
ObservedAt time.Time
// Current says the latest report received was skewed; false once a
// report within tolerance has followed it.
Current bool
}
ClockSkew is a skewed reading of an agent's clock from its flow reports: the windows it stamps land at the wrong times.
type Heartbeat ¶ added in v0.2.0
type Heartbeat struct {
DroppedFlowRecords uint64
SourceOverruns uint64
RenewalError string
// OwnedTable is the owned table's state as the agent read it; an
// unspecified state leaves the recorded one as it was.
OwnedTable innerwallv1.OwnedTableState
}
Heartbeat is what one heartbeat reports.
type LabelsVersionError ¶
type LabelsVersionError struct {
Current string
}
LabelsVersionError is a refused conditional label write with the version the labels hold now.
func (*LabelsVersionError) Error ¶
func (e *LabelsVersionError) Error() string
func (*LabelsVersionError) Unwrap ¶
func (e *LabelsVersionError) Unwrap() error
type LateRenewal ¶ added in v0.2.0
LateRenewal is a renewal made with a credential that had already expired, within the renewal grace: when it happened and when the credential it replaced had expired. The difference is how late it was.
type ListeningService ¶
type ListeningService struct {
Protocol innerwallv1.Protocol
Port uint32
ProcessName string
ProcessPath string
}
ListeningService is a service the agent reported as listening.
type Store ¶
type Store interface {
ListWorkloads(ctx context.Context) ([]Workload, error)
LookupWorkload(ctx context.Context, id identity.WorkloadID) (*Workload, error)
ListListeningServices(ctx context.Context, id identity.WorkloadID) ([]ListeningService, error)
// SetWorkloadLabels replaces the workload's labels.
SetWorkloadLabels(ctx context.Context, id identity.WorkloadID, labels []Label) error
// SetWorkloadMode changes the enforcement mode.
SetWorkloadMode(ctx context.Context, id identity.WorkloadID, mode innerwallv1.EnforcementMode) error
// RecordFacts stores host facts and refreshes last-seen. It reports
// whether the set of addresses derived from the facts changed, which is
// a render trigger because peers resolve to those addresses.
RecordFacts(ctx context.Context, id identity.WorkloadID, facts *innerwallv1.HostFacts, now time.Time) (addressesChanged bool, err error)
// RecordListeningServices replaces the workload's listening services.
RecordListeningServices(ctx context.Context, id identity.WorkloadID, services []ListeningService, now time.Time) error
// RecordAgent stores what a Hello said: agent info and the version the
// agent claims to have applied.
RecordAgent(ctx context.Context, id identity.WorkloadID, agent AgentInfo, appliedVersion uint64, now time.Time) error
// RecordHeartbeat refreshes last-seen and what the heartbeat carries:
// the loss counters, the renewal status, and the owned table's state.
RecordHeartbeat(ctx context.Context, id identity.WorkloadID, hb Heartbeat, now time.Time) error
// SetSyncState records the convergence state with an optional detail.
SetSyncState(ctx context.Context, id identity.WorkloadID, state innerwallv1.SyncState, detail string, now time.Time) error
// RecordApplied stores an acknowledged version and the resulting
// state, and stamps now as the last acknowledgement.
RecordApplied(ctx context.Context, id identity.WorkloadID, version uint64, state innerwallv1.SyncState, now time.Time) error
// RecordApplyFailed stores a failed apply: the degraded state and the
// agent's detail, and stamps now as the last apply failure. The
// applied version is untouched.
RecordApplyFailed(ctx context.Context, id identity.WorkloadID, detail string, now time.Time) error
// RecordSnapshotSent stamps the instant the sync path sent the
// workload a snapshot. The sync path is its only caller.
RecordSnapshotSent(ctx context.Context, id identity.WorkloadID, at time.Time) error
}
Store is the persistence the registry needs, implemented with hand-written SQL in internal/store (ADR-0006). Methods that take an id return ErrWorkloadUnknown when it is not registered.
type Workload ¶
type Workload struct {
ID identity.WorkloadID
Hostname string
Labels []Label
Mode innerwallv1.EnforcementMode
Facts *innerwallv1.HostFacts
Addresses []netip.Addr
Agent AgentInfo
EnrolledAt time.Time
LastSeenAt *time.Time
SyncState innerwallv1.SyncState
AppliedVersion uint64
SyncError string
DroppedFlowRecords uint64
// SourceOverruns is the kernel-side overruns of the agent's flow
// sources since it started, as its heartbeat reported them.
SourceOverruns uint64
// CredentialRenewalError is the reason the agent's last automatic
// renewal failed, as its heartbeat reported it; empty when healthy.
CredentialRenewalError string
CredentialExpiresAt time.Time
// LateRenewal is the latest renewal made with an already-expired
// credential, within the renewal grace; nil when the workload has
// never renewed late. Written by renewal alone (ADR-0016 as amended).
LateRenewal *LateRenewal
// LastSnapshotSentAt is when the sync path last sent this workload a
// snapshot, whatever caused it; nil when none has been recorded. It
// is a record of what the control plane did, written by the sync
// path alone.
LastSnapshotSentAt *time.Time
// LastAckedAt is when the agent last acknowledged an applied
// version; nil when none has been recorded. The version a Hello
// claims is not an acknowledgement.
LastAckedAt *time.Time
// LastApplyFailedAt is when the agent last reported a failed apply;
// nil when none has been recorded. A later successful apply leaves
// it: SyncState says whether the workload is still degraded.
LastApplyFailedAt *time.Time
// ClockSkew is the latest flow report whose agent clock was beyond
// the tolerance; nil when none has been received. Written by flow
// ingest alone.
ClockSkew *ClockSkew
// OwnedTable is whether the agent's owned firewall table is in the
// kernel, as its heartbeats last said: unspecified until a heartbeat
// that knows has arrived. OwnedTableAbsentSince is when the control
// plane first heard it was absent, nil unless it is.
OwnedTable innerwallv1.OwnedTableState
OwnedTableAbsentSince *time.Time
// LastFlowReportAt is when the control plane last received a flow
// report from the agent; nil when none has been. Flow reports travel
// on a connection of their own (ADR-0015), so this can move while the
// sync stream is down. Written by flow ingest alone.
LastFlowReportAt *time.Time
}
Workload is the control plane's record of one workload: identity plus everything mutable that lives beside it rather than in the credential.