manager

package
v0.0.0-...-7c0b2e9 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package manager provides shared bootstrap logic for controller-runtime managers used by both the agent and registrar commands.

Index

Constants

View Source
const ControllerRuntimeMaxVerbosity = 1

ControllerRuntimeMaxVerbosity is the most verbose logr V-level controller-runtime (and anything else logging through ctrl.Log) may emit, whatever the component's own slog level.

logr's slog bridge maps V(n) to slog level -n, and --debug lowers the shared handler to log.LevelTrace (-8) for aether's own debug output — which, without a cap, also switches on everything controller-runtime logs at V(2)..V(8). Its V(5) is the expensive one (issue #1131): every priority queue's logState goroutine, ticking every 10 s, then locks the queue, copies every item and serialises a "workqueue_items" record (900 lines per agent per 30 min, almost all "items=[]"), and every reconcile logs "Reconciling"/"Reconcile successful". V(1) keeps controller-runtime's own debug lines while dropping that per-item tracing; aether's slog records do not pass through this cap.

Variables

This section is empty.

Functions

func CurrentNamespace

func CurrentNamespace() string

CurrentNamespace returns the namespace this pod runs in. It reads POD_NAMESPACE (set via the downward API by the chart), falls back to the service-account namespace file, and finally to "default".

func FlushLogs

func FlushLogs(ctx context.Context, l *slog.Logger, shutdown func(context.Context) error)

FlushLogs flushes and stops the OTLP log exporter, i.e. runs the shutdown returned by SetupManagerLogging. No-op when shutdown is nil (OTLP logging is disabled). A failure is logged on l, never returned.

func RegisterFlags

func RegisterFlags(cmd *cobra.Command, cfg *Config)

RegisterFlags binds the common manager configuration flags to the given command.

Telemetry is aether system config: enabling OTEL and the collector endpoint are set once for the whole system (the aether umbrella chart's global values) and passed to every component as these flags. The proxy data plane can override its own observability via MeshConfig, but the control-plane components inherit the system config wholesale.

func SetupLogging

func SetupLogging(debug bool, name string) *slog.Logger

SetupLogging creates a stderr slog logger named name and points controller-runtime at it (via the logr→slog bridge).

func SetupManagerLogging

func SetupManagerLogging(ctx context.Context, cfg Config, name, version string) (*slog.Logger, func(context.Context) error)

SetupManagerLogging is SetupLogging for manager-based components (agent, registrar). When cfg.LogsEnabled and an OTLP endpoint are set, it also creates an OTel LoggerProvider and fans the logger out to the otelslog bridge, so records go to both stderr (kubectl logs) and OTLP → collector. Because slog's Handle is context-aware, otelslog populates trace_id/span_id natively from the ctx passed to the *Context log methods. controller-runtime is wired via the logr→slog bridge over the same handler. The returned shutdown flushes and stops the LoggerProvider; it is nil when OTLP logging is disabled.

It returns no error by design (issue #662): OTLP log export is best-effort, so a collector that is missing, unreachable or shedding degrades the component to stderr-only logging with a WARN rather than killing the process. Setup runs on a detached, bounded context so it can neither spend the caller's startup budget nor observe a cancellation of the caller's context, and the returned shutdown flushes on its own detached context so the final flush still runs after SIGTERM.

func ShutdownTelemetry

func ShutdownTelemetry(ctx context.Context, l *slog.Logger, shutdown func(context.Context) error)

ShutdownTelemetry runs the telemetry shutdown returned by Bootstrap (Result.Shutdown). No-op when shutdown is nil. A failure is logged on l, never returned.

Types

type Config

type Config struct {
	// CacheOptions optionally scopes the manager's informer cache (e.g. the
	// agent limits Pod watches to its own node). Nil keeps the default cache.
	CacheOptions *cache.Options
	// Debug enables debug logging
	Debug bool
	// HealthProbeBindAddress is the address for the health probe HTTP server
	HealthProbeBindAddress string
	// MetricsEnabled enables the controller-runtime Prometheus metrics server
	MetricsEnabled bool
	// MetricsBindAddress is the address for the metrics HTTP server
	MetricsBindAddress string
	// LeaderElection enables controller-runtime leader election so only one
	// replica is active (used by the aether-controller singleton).
	LeaderElection bool
	// LeaderElectionID is the name of the lease resource used for leader election.
	LeaderElectionID string
	// OTelEnabled enables the OTel MeterProvider with Prometheus exporter bridge
	OTelEnabled bool
	// OTLPEndpoint is the OTLP gRPC collector endpoint (e.g. "localhost:4317"); empty disables OTLP export
	OTLPEndpoint string
	// LogsEnabled enables the OTel LoggerProvider with OTLP log export, tee'd into
	// the component's slog logger (requires OTLPEndpoint); stderr logging is unaffected
	LogsEnabled bool
	// TraceSampleRate is the head-sampling ratio for traces (0.0–1.0). The
	// TracerProvider is always installed (for trace_id on logs); this only bounds
	// what gets exported when TracingExport is set.
	TraceSampleRate float64
	// TracingExport attaches the OTLP span exporter; without it the always-on
	// TracerProvider still gives logs their trace_id but exports no spans (no
	// trace backend needed)
	TracingExport bool
	// SchedulerLatency exports the Go runtime's scheduler-latency histogram
	// (go.schedule.duration) when OTel metrics are enabled. Not a flag: the node
	// agent sets it (issue #1131), the other components leave it off.
	SchedulerLatency bool
	// WithoutHostName leaves host.name off the component's telemetry resource.
	// Not a flag: it is a fact about how the component is deployed. A component
	// that is not hostNetwork sets it (the registrar, the controller, the edge
	// control plane), because its host.name is its pod name and a collector that
	// derives a node label from host.name then labels its series with a pod
	// (#1596, #1041). The node agent is hostNetwork and leaves it off.
	WithoutHostName bool
}

Config holds common configuration shared across all controller-runtime manager-based commands.

func (Config) Telemetry

func (c Config) Telemetry(serviceName, serviceVersion string) setup.Config

Telemetry is the telemetry setup of the component called serviceName, built at serviceVersion. The meter, tracer and logger providers are all built from it, so the three signals of one component describe the same resource.

type Result

type Result struct {
	Manager  ctrl.Manager
	Shutdown func(context.Context) error // nil if neither OTel metrics nor tracing enabled
}

Result holds the bootstrapped manager and an optional telemetry shutdown function.

func Bootstrap

func Bootstrap(ctx context.Context, cfg Config, serviceName, serviceVersion string, l *slog.Logger, optFns ...func(*ctrl.Options)) (*Result, error)

Bootstrap sets up telemetry (best-effort), creates a controller-runtime Manager, and registers the standard health and readiness probes. Optional opts mutate the ctrl.Options before the manager is built (e.g. to supply a custom webhook server backed by SPIRE).

Telemetry never fails the bootstrap: see setupTelemetry.

Jump to

Keyboard shortcuts

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