policy

package
v0.14.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseRouteAttrs added in v0.11.0

func BaseRouteAttrs(p *config.PolicyConfig) model.RouteAttrs

BaseRouteAttrs returns the attributes from the announce block: the base prepend and communities carried by every announcement of the VIP.

func Evaluate

func Evaluate(healthy bool, lowerPriorityFilePresent bool, p *config.PolicyConfig) model.VIPState

func RouteAttrsFor added in v0.11.0

func RouteAttrsFor(p *config.PolicyConfig, state model.VIPState) model.RouteAttrs

RouteAttrsFor returns the BGP attributes to originate the VIP with in the given state:

  • announced: the announce block (base prepend + communities)
  • pessimized: base prepend + lower_priority prepend, and the union of both community lists, so a degraded node never outranks a healthy node with a larger base prepend
  • withdrawn: zero value (no route)

Types

type BGPNotifier

type BGPNotifier interface {
	AnnounceVIP(ctx context.Context, prefix string, attrs model.RouteAttrs) error
	WithdrawVIP(ctx context.Context, prefix string) error
	PessimizeVIP(ctx context.Context, prefix string, attrs model.RouteAttrs) error
}

type CheckSeed added in v0.14.0

type CheckSeed struct {
	Health     model.HealthStatus
	LastResult checks.Result
	LastTime   time.Time
}

CheckSeed is the state a check starts from when a reload commits it: the verdict its shadow scheduler reached and the result that produced it.

type Manager

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

func NewManager

func NewManager(vipConfigs []config.VIPConfig, m *metrics.Metrics, notifier BGPNotifier) *Manager

func (*Manager) AddVIP added in v0.14.0

func (m *Manager) AddVIP(cfg *config.VIPConfig)

AddVIP registers a VIP added by a config reload. It starts withdrawn with unknown health, exactly like a VIP at startup.

func (*Manager) CombineChecks added in v0.12.0

func (m *Manager) CombineChecks(vipName string, healthy map[string]bool) (result, ok bool)

CombineChecks applies the VIP's checks_policy to an ad-hoc per-check outcome (e.g. a triggered run). ok is false for an unknown VIP.

func (*Manager) CommitVIP added in v0.14.0

func (m *Manager) CommitVIP(ctx context.Context, cfg *config.VIPConfig, seeds map[string]CheckSeed) error

CommitVIP switches a VIP to a new definition with the same name and prefix. seeds carries the state of every check whose definition changed (its shadow verdict); checks absent from seeds keep their running state, checks absent from the new config are dropped. The VIP health and state are re-evaluated once, and the route is re-originated when the announce attributes changed.

func (*Manager) GetVIPStatuses

func (m *Manager) GetVIPStatuses() []model.VIPStatus

func (*Manager) OnCheckResult

func (m *Manager) OnCheckResult(vipName, checkName string, result checks.Result)

func (*Manager) OnHealthTransition

func (m *Manager) OnHealthTransition(t checks.HealthTransition)

func (*Manager) RemoveVIP added in v0.14.0

func (m *Manager) RemoveVIP(ctx context.Context, name string) error

RemoveVIP withdraws a VIP's route if it is installed and forgets the VIP, including its metric series. The schedulers must already be stopped. A withdraw error is returned and the VIP is kept so a later reload (or restart) can retry; nothing else is left half done.

func (*Manager) SetTransitionListener added in v0.12.0

func (m *Manager) SetTransitionListener(fn func())

SetTransitionListener registers fn to be called after each VIP state transition. It must be set before the schedulers start.

func (*Manager) VIPNames added in v0.14.0

func (m *Manager) VIPNames() []string

VIPNames returns the registered VIP names in order.

type StateChange

type StateChange struct {
	VIPName  string
	Prefix   string
	OldState model.VIPState
	NewState model.VIPState
	Reason   string
}

Jump to

Keyboard shortcuts

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