rendergate

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rendergate runs the controller's own `haproxy -c` over each render, off the reconcile wall clock.

The reconcile pipeline renders and dispatches; this component decides afterwards whether HAProxy would load what was dispatched. It is a two-state latch (ADR-0022):

  • OPTIMISTIC (default): renders dispatch immediately. A pass names the plan agents may promote their rollback baseline to; a refusal reverts the pods that took the bad plan without loading it and flips the latch.
  • PESSIMISTIC: the scheduler holds every render until this gate passes one. A pass releases it and returns to OPTIMISTIC; a refusal pins the fleet on the last config it accepted.

Coverage is the same as the synchronous check it replaces. What changes is when it runs: while OPTIMISTIC the exposure window is one check plus one apply, closed by the scoped revert and the latch.

Index

Constants

View Source
const (
	// ComponentName is the unique identifier for this component.
	ComponentName = "rendergate"

	// EventBufferSize is the size of the event subscription buffer. Renders
	// arrive at most one per reconcile; pod ACKs are the higher-volume input.
	EventBufferSize = busevents.StandardSubscriberBuffer
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Check(ctx context.Context, config string, auxFiles *dataplane.AuxiliaryFiles, checksum string) error
}

Checker runs the controller's own `haproxy -c` over one rendered file set. A nil error is a pass; dataplane.ErrHAProxyRefused in the chain means HAProxy judged the config, anything else means the check could not run.

type Component

type Component struct {
	*component.ReadySignal
	// contains filtered or unexported fields
}

Component is the render gate's event adapter.

Event subscriptions:

  • TemplateRenderedEvent: the render to check (always coalesced to newest)
  • ConfigAppliedToPodEvent: which plan each pod holds, so a superseded plan that pods still run is checked too
  • HAProxyPodTerminatedEvent / HAProxyPodsDiscoveredEvent: prune that map
  • LostLeadershipEvent: drop the latch and the fleet's plans

It publishes RenderGateCompletedEvent.

func New

func New(cfg *Config) *Component

New creates the render gate.

It does NOT subscribe here: two of its inputs (pod discovery, pod termination) are published on every replica, so a construction-time subscription would fill a channel nobody drains on the standby and be reported as critical drops. Start subscribes once leadership is held.

func (*Component) HealthCheck

func (c *Component) HealthCheck() error

HealthCheck implements lifecycle.HealthChecker.

func (*Component) Logger

func (c *Component) Logger() *slog.Logger

Logger exposes the component's logger, matching the other components' shape.

func (*Component) Name

func (c *Component) Name() string

Name returns the unique identifier for this component.

func (*Component) Start

func (c *Component) Start(ctx context.Context) error

Start runs the event loop and the check worker until ctx is cancelled.

A new leadership term starts OPTIMISTIC: the agents' own last-known-good set protects the fleet, so a fresh leader has nothing to gain from validating before it trusts its first render.

type Config

type Config struct {
	EventBus *busevents.EventBus
	Logger   *slog.Logger
	Checker  Checker
	// Metrics records the rejection counter and the pinned gauge. Nil in tests.
	Metrics *metrics.Metrics
	// CheckTimeout bounds one check. Zero uses validation.DefaultValidationTimeout.
	CheckTimeout time.Duration
}

Config contains the dependencies for the render gate.

type OutputChecker

type OutputChecker interface {
	CheckOutput(ctx context.Context, snapshot *renderoutput.Snapshot, checksum string) error
}

OutputChecker validates one authenticated complete render output directly.

type ServiceChecker

type ServiceChecker struct {
	Service *validation.ValidationService
}

ServiceChecker adapts a validation.ValidationService to Checker.

func (ServiceChecker) Check

func (s ServiceChecker) Check(ctx context.Context, config string, auxFiles *dataplane.AuxiliaryFiles, checksum string) error

Check runs the service's `haproxy -c` and returns its error unchanged, so the caller can tell HAProxy's verdict from a check that could not run.

func (ServiceChecker) CheckOutput

func (s ServiceChecker) CheckOutput(
	ctx context.Context,
	snapshot *renderoutput.Snapshot,
	checksum string,
) error

CheckOutput validates a complete immutable render output without splitting its identity.

func (ServiceChecker) CheckSnapshot

func (s ServiceChecker) CheckSnapshot(
	ctx context.Context,
	config string,
	snapshot *renderartifact.Snapshot,
	checksum string,
) error

CheckSnapshot validates authenticated immutable auxiliary output.

type SnapshotChecker

type SnapshotChecker interface {
	CheckSnapshot(ctx context.Context, config string, snapshot *renderartifact.Snapshot, checksum string) error
}

SnapshotChecker validates authenticated immutable auxiliary output directly.

Jump to

Keyboard shortcuts

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