teamintentobserver

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package teamintentobserver runs the independent Kubernetes status observer for durable team namespace intents. It inspects live cluster state and writes leased observations to Platform API without mutating intent, receipts, or River jobs.

Index

Constants

View Source
const (
	ReasonAllPrerequisitesReady      = "AllPrerequisitesReady"
	ReasonPrerequisiteDrifted        = "PrerequisiteDrifted"
	ReasonNamespaceMissing           = "NamespaceMissing"
	ReasonNamespaceTerminating       = "NamespaceTerminating"
	ReasonNamespaceOwnershipMismatch = "NamespaceOwnershipMismatch"
	ReasonNamespaceUIDMismatch       = "NamespaceUIDMismatch"
	ReasonAwaitingReconcile          = "AwaitingReconcile"
	ReasonReconciling                = "Reconciling"
	ReasonReconcileTerminal          = "ReconcileTerminal"
	ReasonReconcileExhausted         = "ReconcileExhausted"
	ReasonCleanupComplete            = "CleanupComplete"
	ReasonCleanupPending             = "CleanupPending"
	ReasonCleanupTerminal            = "CleanupTerminal"
	ReasonTraefikWatchDrifted        = "TraefikWatchDrifted"
	ReasonSupersededByNewIncarnation = "SupersededByNewIncarnation"
)

Variables

View Source
var ErrObserverLeaseLost = errors.New("observer lease superseded by newer epoch")

ErrObserverLeaseLost is returned when Platform API rejects an observation because a newer observer holds a higher lease epoch.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClusterKey     string
	ObserverID     string
	Platform       PlatformClient
	K8sClient      kubernetes.Interface
	Traefik        k8sprovision.TraefikWatchConfig
	VerifyInterval time.Duration
	InformerResync time.Duration
	QueueMaxDepth  int
	Now            func() time.Time
	Logger         *slog.Logger
}

Config configures the independent team namespace status observer.

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

Observer watches managed Kubernetes namespaces and periodically verifies live prerequisites against Platform API's team namespace intents.

func New

func New(cfg Config) (*Observer, error)

New validates cfg and creates an Observer.

func (*Observer) ClaimLease

func (o *Observer) ClaimLease(ctx context.Context) error

ClaimLease acquires a monotonic observer epoch from Platform API.

func (*Observer) Epoch

func (o *Observer) Epoch() int64

Epoch returns the currently held observer lease epoch.

func (*Observer) ObserveAll

func (o *Observer) ObserveAll(ctx context.Context) error

ObserveAll fetches all team intents from Platform API and records fresh live observations for every incarnation.

func (*Observer) ObserveTeam

func (o *Observer) ObserveTeam(ctx context.Context, teamID string) error

ObserveTeam fetches one team intent and records its live Kubernetes observation.

func (*Observer) Run

func (o *Observer) Run(ctx context.Context) error

Run claims an observer lease (if not already held), starts a SharedInformer on managed namespaces, runs an initial full sweep, and continuously handles informer events and periodic freshness verification until ctx is cancelled or a newer observer supersedes the lease.

type PlatformClient

type PlatformClient interface {
	ListTeamIntents(ctx context.Context) ([]apikit.TeamNamespaceIntent, error)
	GetTeamIntent(ctx context.Context, teamID string) (apikit.TeamNamespaceIntent, bool, error)
	ClaimTeamIntentObserverLease(ctx context.Context, clusterKey, observerID string) (apikit.TeamIntentObserverLeaseResponse, error)
	RecordTeamIntentObservation(ctx context.Context, teamID string, req apikit.TeamIntentObservationRequest) (apikit.TeamNamespaceObservation, error)
}

PlatformClient exposes only intent reads, observer lease claims, and observation writes. By design it cannot mutate intent, receipts, or jobs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL