Documentation
¶
Overview ¶
Package server is the HAPTIC agent: an HTTP endpoint that owns one HAProxy pod's file tree and its runtime socket. It executes what the controller decided and reports truthfully; it makes no HAProxy decisions of its own.
Index ¶
Constants ¶
const ( DefaultDrainQuietPeriod = 2 * time.Second DefaultDrainMaxWait = 10 * time.Second MaxDrainWait = 5 * time.Minute )
Drain defaults. A terminating pod keeps its listeners until kube-proxy has stopped routing new connections to it; the pod cannot observe kube-proxy, but it can observe the effect, so the hook ends after a quiet period and never later than the bound, which must stay inside the termination grace period together with hard-stop-after.
const ( DrainReasonQuiet = "quiet" DrainReasonBound = "bound" DrainReasonCancelled = "cancelled" )
Drain reasons reported to the hook and the log.
const DefaultReloadTimeout = api.MaxReloadMs * time.Millisecond
DefaultReloadTimeout bounds the wait for the new worker to answer after a reload. Past it the apply reports what it knows rather than blocking.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BaseDir string
ConfigFile string
MasterSocket string
WorkerSocket string
StateFile string
Listen string
ReloadIntervalMin time.Duration
// ReloadTimeout bounds one reload. Zero means DefaultReloadTimeout.
ReloadTimeout time.Duration
Username string
Password string
TLS *transportsecurity.Source
AgentVersion string
Logger *slog.Logger
Registry *prometheus.Registry
// DrainSocket is the unix socket path of GET /drain; empty disables it.
DrainSocket string
// AdminSocket exposes read-only state through the pod's filesystem permissions.
AdminSocket string
// DrainQuietPeriod ends the drain once no traffic frontend accepted a new
// connection for this long; DrainMaxWait bounds the whole drain.
DrainQuietPeriod time.Duration
DrainMaxWait time.Duration
// DrainIgnoreFrontends names frontends whose connections are not traffic
// (probes, scrapes); the chart passes its status frontend.
DrainIgnoreFrontends []string
}
Config is everything the agent needs to run.
type DrainResult ¶
type DrainResult struct {
// Reason is why the drain ended: quiet, bound, unavailable (the worker no
// longer answers, so there is nothing to keep open) or cancelled.
Reason string `json:"reason"`
// Waited is how long the caller was held.
Waited string `json:"waited"`
// Connections is the last accepted-connection count seen on the traffic frontends.
Connections uint64 `json:"connections"`
}
DrainResult is the answer of GET /drain on the drain socket.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is the agent's own Prometheus surface plus the invariant helper. Everything here is instance-based so a test registry stays isolated.
func NewMetrics ¶
func NewMetrics(registry prometheus.Registerer, logger *slog.Logger) *Metrics
NewMetrics registers the agent's metrics on registry.
func (*Metrics) DeferredDeleteAbandoned ¶
DeferredDeleteAbandoned implements cli.Observer.
func (*Metrics) DeferredDeleteDeferred ¶
DeferredDeleteDeferred implements cli.Observer.
func (*Metrics) DeferredDeleteDone ¶
DeferredDeleteDone implements cli.Observer.
func (*Metrics) DeferredDeleteSuperseded ¶
DeferredDeleteSuperseded implements cli.Observer.
func (*Metrics) LastViolation ¶
LastViolation is the invariant that failed most recently, for /v1/state.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns the tree, the runtime plumbing and the apply state machine.
func New ¶
New builds the agent. It probes the mounts under the base directory and loads the state file, but it does not touch HAProxy: Start does that, and readiness is what reports it.
func (*Server) Addr ¶
Addr is the address the endpoint bound to, which is the resolved port when the configured address asked for any.