Documentation
¶
Overview ¶
Package agent is the edgeweir-node runtime (`edgeweir-node run`).
Lifecycle:
start ─► serve LKG (or the bootstrap config) ─► wait for enrollment
─► mTLS channel ─► watch + poll ─► fetch (snapshot | diff)
─► verify hash ─► validate ─► render/test/reload (structural only)
─► push site table to Lua ─► persist LKG ─► ReportStatus
Dynamic bans travel outside revisions (bans.go): GetBans ─► bans.json ─► Lua (delta or full set) and nftables for platform bans.
The data plane keeps serving the last-known-good configuration whenever the console is unreachable or a new configuration is rejected.
Index ¶
Constants ¶
const ( HealthCertFile = "health.crt" HealthKeyFile = "health.key" )
The health certificate (feature probe-health-v1): TLS listeners answer SNI health.edgeweir.invalid, and handshakes without SNI, with a self-signed ECDSA P-256 certificate the agent generates for itself and keeps in the state directory (both files 0600). Like site certificates it reaches the data plane with every site table (health_certificate), never through nginx.conf. Probes do not verify it: it only lets the handshake complete so that GET /.edgeweir/health can be asked.
const ( DefaultPurgeMarkersPerSite = 1000 DefaultPurgeTagsPerSite = 5000 )
DefaultPurgeMarkersPerSite bounds the URL and prefix markers of one site, DefaultPurgeTagsPerSite its tag markers; beyond either the site's markers collapse into one site-level marker.
const FeatureDecommission = "decommission-v1"
FeatureDecommission is announced while the agent can run decommission tasks.
Variables ¶
var ErrDecommissioned = errors.New("this node was decommissioned by the console: it serves nothing and has no identity; " +
"enroll it again (edgeweir-node enroll) or remove the edgeweir-node package")
ErrDecommissioned is returned by Run when the console decommissioned the node, now or before this start. The command exits with status 3 (upgrade.ExitDecommissioned), which neither the supervisor nor systemd restarts and systemd counts as a clean stop, or with 2 under a unit older than 1.7.0 (upgrade.DecommissionedExit).
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the node runtime.
type Config ¶
type Config struct {
// StateDir holds the identity and the LKG configuration.
StateDir string
SupervisorSocket string
// DiagSocket is the unix socket of the diagnostics (internal/diag:
// status and pprof, 0600); empty: none.
DiagSocket string
// NodeLogs holds the process's warnings, errors and events (its
// logger's nodelog.Handler and the engine's LogSink); the agent
// uploads them (feature node-logs-v1). nil: no node logs.
NodeLogs *nodelog.Collector
// DebugLogs is the process's debug log ring (its logger's
// nodelog.Handler and the engine's DebugSink); the agent uploads it
// for a DebugLogsTask (feature debug-logs-v1). nil: none.
DebugLogs *nodelog.Ring
// NodeLogsUnsupportedRetry: a console without ReportNodeLogs is asked
// again this often (default 10m).
NodeLogsUnsupportedRetry time.Duration
// NodeLogsSealAfter: entries wait at most this long before they are
// sealed into a batch (default 5s).
NodeLogsSealAfter time.Duration
// ConfPath is where nginx.conf is written (inside the nginx prefix).
ConfPath string
// Render holds the node-local nginx.conf settings.
Render render.Params
// DefaultPort is served before any configuration exists.
DefaultPort uint32
// GeoIP selects the local MMDBs; an empty path disables that source.
GeoIP geoip.Paths
// Extensions is the node's own setting for node extensions.
Extensions ExtensionsConfig
EnrollPollInterval time.Duration // default 2s
PollInterval time.Duration // GetConfig fallback poll, default 30s
ReportInterval time.Duration // heartbeat until the console says otherwise, default 15s
StatsInterval time.Duration // default 60s
DataPlaneInterval time.Duration // data plane health/resync check, default 5s
WatchIdleTimeout time.Duration // no message (incl. keepalive) for this long = dead stream, default 45s
WatchBackoffMin time.Duration // default 1s
WatchBackoffMax time.Duration // default 30s
PushTimeout time.Duration // retry budget for pushing a site table, default 15s
ReloadTimeout time.Duration // wait for workers running a new nginx.conf, default 15s
TestTimeout time.Duration // `nginx -t` of a new nginx.conf, default 60s
RPCTimeout time.Duration // unary RPC timeout, default 30s
// CacheUsageInterval is how often the cache zones' disk usage is
// measured (ReportStatus.cache_usage), default 10m; the first
// measurement runs after at most a minute.
CacheUsageInterval time.Duration
TaskPollInterval time.Duration // PullTasks fallback poll, default 30s
// SupervisorHealthInterval: the supervisor hears how the node is this
// often (default 5s; see supervisorHealthLoop).
SupervisorHealthInterval time.Duration
// IdentityInterval: identity.json is compared with the identity in use
// this often; a new one (re-enrolled) stops the agent so that it starts
// again with it (default 10s).
IdentityInterval time.Duration
// Following the console's node channel address (controlplane.Follower;
// zero values take its defaults): how long the address in use may fail
// before the fallback is tried, how often the persisted address is
// tried again from the fallback, and the waits between checks of an
// address that failed one. Tests shorten them.
ChannelFailoverAfter time.Duration
ChannelRetryPrimary time.Duration
ChannelBackoff []time.Duration
// PurgeMarkersPerSite bounds a site's URL and prefix purge markers,
// PurgeTagsPerSite its tag markers; beyond either the site's markers
// collapse into one site-level marker (defaults 1000 and 5000).
PurgeMarkersPerSite int
PurgeTagsPerSite int
// Prefetch tasks request URLs through the node's local edge listeners
// (Render.EdgeSocket, Render.EdgeTLSSocket).
PrefetchConcurrency int // default 4
PrefetchTimeout time.Duration // per URL, default 60s
// PrefetchBudget bounds the prefetches of one pulled batch, counted
// from the pull (default 4m: the console hands a task out again after
// 5 minutes without a result).
PrefetchBudget time.Duration
// BanCapacity is the number of bans the data plane holds (default
// render.DefaultBanCapacity; the same value goes into nginx.conf).
BanCapacity int
// Kernel runs nft scripts for kernel bans; nil disables them.
Kernel nft.Executor
// Image configures the WebP / AVIF converter (ADR-0043); Workers 0
// turns it off (the node does not announce image-convert-v1).
Image ImageOptions
// Markdown configures the Markdown converter (Markdown for Agents);
// Workers 0 turns it off (the node does not announce markdown-v1).
Markdown MarkdownOptions
// AutoBanInterval: the node's own bans are drained and reported this
// often (default 5s).
AutoBanInterval time.Duration
// BanRetryInterval: manual bans that did not fit are retried this often
// (default 1m).
BanRetryInterval time.Duration
// CaptchaInterval: a new captcha pool of CaptchaPoolSize images is
// generated this often while the configuration uses challenges
// (default 10m, 256 images).
CaptchaInterval time.Duration
CaptchaPoolSize int
// SecurityInterval: CC events are drained and reported this often
// (default 5s).
SecurityInterval time.Duration
// ChallengeKeyRetry: challenge keys the configuration names but the
// console did not hand out are asked for again this often (default 30s).
ChallengeKeyRetry time.Duration
// ChallengeVerify checks the answers of interactive challenge providers
// (agent socket POST /v1/challenge/verify, feature challenge-v3); nil
// uses the providers' own endpoints.
ChallengeVerify *challengeverify.Verifier
// ActiveHealth configures the active health checker; the agent sets
// the trust store (unless RootCAs is set), IPv6 and OnChange. Tests
// replace the resolver, dialer and clock.
ActiveHealth healthcheck.Options
// ActiveHealthRefresh: the active health marks are pushed again this
// often (default 30s).
ActiveHealthRefresh time.Duration
// Prober probes the other nodes while the console lets this node probe
// (nil: the defaults; tests replace the dialer).
Prober *probe.Prober
// Metrics measures the host metrics of the heartbeats (nil: /proc on
// Linux, none elsewhere).
Metrics *metrics.Collector
}
Config configures the agent.
type DataPlane ¶
type DataPlane interface {
Status(ctx context.Context) (*dataplane.Status, error)
PutSites(ctx context.Context, t *dataplane.SiteTable) (*dataplane.Status, error)
DrainStats(ctx context.Context, all bool) ([]dataplane.MinuteStats, error)
PutPurge(ctx context.Context, t *dataplane.PurgeTable) (*dataplane.PurgeStatus, error)
AddPurge(ctx context.Context, t *dataplane.PurgeTable) (*dataplane.PurgeStatus, error)
OriginHealth(ctx context.Context) ([]dataplane.OriginHealth, error)
BanStatus(ctx context.Context) (*dataplane.BanStatus, error)
PutBans(ctx context.Context, t *dataplane.BanTable) (*dataplane.BanStatus, error)
AddBans(ctx context.Context, d *dataplane.BanDelta) (*dataplane.BanStatus, error)
DrainAutoBans(ctx context.Context) ([]dataplane.AutoBan, error)
ReleaseOwnBans(ctx context.Context, list []dataplane.OwnBanRelease) (int, error)
ChallengeStatus(ctx context.Context) (*dataplane.ChallengeStatus, error)
PutChallengeKeys(ctx context.Context, k *dataplane.ChallengeKeys) (*dataplane.ChallengeStatus, error)
PutCaptchas(ctx context.Context, p *dataplane.CaptchaPool) (*dataplane.ChallengeStatus, error)
SecurityStatus(ctx context.Context) (*dataplane.SecurityStatus, error)
DrainSecurity(ctx context.Context) ([]dataplane.SecurityEvent, error)
PutActiveHealth(ctx context.Context, doc *dataplane.ActiveHealth) (*dataplane.ActiveHealthStatus, error)
// Layer-4 applications (the stream subsystem, through the control API).
L4Status(ctx context.Context) (*dataplane.L4Status, error)
PutL4(ctx context.Context, t *dataplane.L4Table) (*dataplane.L4Status, error)
DrainL4Stats(ctx context.Context, all bool) ([]dataplane.L4MinuteStats, error)
}
DataPlane is the Lua control API (see package dataplane).
type Engine ¶
type Engine interface {
// Run supervises the engine until ctx is done (no-op when unmanaged).
Run(ctx context.Context) error
Version(ctx context.Context) (string, error)
// Test validates a configuration file without applying it.
Test(ctx context.Context, conf string) error
// Reload applies the installed configuration file (starting the
// engine if it is managed and not running).
Reload(ctx context.Context) error
Running() bool
// Started fires whenever a managed engine (re)starts.
Started() <-chan struct{}
// ModuleFeatures returns the features of the optional static modules
// compiled into the engine (brotli-v1, zstd-v1).
ModuleFeatures(ctx context.Context) ([]string, error)
}
Engine is the data plane process controller (see package engine).
type ExtensionsConfig ¶ added in v1.7.0
type ExtensionsConfig struct {
// Disabled (--no-extensions): extensions-v1 is not announced and no
// package is downloaded or loaded; the console cannot override it.
Disabled bool
// KeysFile (--extension-keys) lists the publisher keys (JWKs, one per
// line, or a JSON array) this node accepts on top of the console's
// trust store; empty: whatever key the console delivers.
KeysFile string
// SidecarMode (--sidecar-mode) is auto, user or off: user runs
// sidecars as SidecarUser (the agent must run as root), auto does so
// when it can; off never runs one.
SidecarMode string
// SidecarUser (--sidecar-user) is the user sidecars run as.
SidecarUser string
// SidecarDir (--sidecar-dir) holds the sidecars' copies of their
// packages, state and data (default: the state directory + "-sidecar",
// outside the state directory the sidecar user must not read).
SidecarDir string
}
ExtensionsConfig is the node's own say over node extensions (docs/reference/extensions.md in the console repository).
type ImageOptions ¶ added in v1.0.0
type ImageOptions struct {
// Workers bounds concurrent conversions (0: no converter).
Workers int
// Memory bounds the sum of the running conversions' estimates.
Memory int64
// Timeout bounds one conversion.
Timeout time.Duration
// Executable runs the conversions (ChildCommand); default this
// process's binary.
Executable string
}
ImageOptions configure the WebP / AVIF converter (ADR-0043).
type MarkdownOptions ¶ added in v1.7.0
type MarkdownOptions struct {
// Workers bounds concurrent conversions (0: no converter).
Workers int
// Memory bounds the sum of the running conversions' estimates.
Memory int64
// Timeout bounds one conversion.
Timeout time.Duration
// Executable runs the conversions (ChildCommand); default this
// process's binary.
Executable string
}
MarkdownOptions configure the Markdown converter (Markdown for Agents).
Source Files
¶
- activehealth.go
- agent.go
- api_security.go
- apply.go
- bans.go
- certificates.go
- challenge.go
- challengeverify.go
- content.go
- credentials.go
- debuglogs.go
- decommission.go
- diag.go
- dims.go
- extensions.go
- extruntime.go
- healthcert.go
- imageconv.go
- listeners.go
- location.go
- logs.go
- loops.go
- markdown.go
- modules.go
- nodelogs.go
- ocsp.go
- origintls.go
- owner_unix.go
- prefetch.go
- probe.go
- public_address.go
- purge.go
- purgestate.go
- receipts.go
- sidecar_linux.go
- sitemap.go
- spool.go
- stats.go
- tasks.go
- tickets.go
- tier.go
- upgrades.go
- usage_unix.go