rolloutpolicy

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rolloutpolicy resolves a rolling deploy's max_surge, max_unavailable and min_available into replica counts, and tracks the live progress of each rollout for the API.

Index

Constants

View Source
const (
	EnvMaxSurge       = "APP_ROLLOUT_MAX_SURGE"
	EnvMaxUnavailable = "APP_ROLLOUT_MAX_UNAVAILABLE"
	EnvMinAvailable   = "APP_ROLLOUT_MIN_AVAILABLE"
)

Env names for the platform defaults an app's rollout: block overrides.

View Source
const (
	PhaseRolling  = "rolling"
	PhaseComplete = "complete"
	PhaseFailed   = "failed"
)

Rollout phases.

Variables

This section is empty.

Functions

func CheckDisruption

func CheckDisruption(app, action string, minAvailable, available, removing int) error

CheckDisruption refuses taking removing replicas out of available ones when that would drop below minAvailable. Zero minAvailable never blocks.

func ParseValue

func ParseValue(v string) (n int, percent bool, err error)

ParseValue validates an int or percent value without resolving it.

func Record

func Record(service string, p Progress)

Record stores p for service, keeping the first StartedAt of a rollout.

Types

type DisruptionError

type DisruptionError struct {
	App          string
	Action       string
	MinAvailable int
	Available    int
	Remaining    int
}

DisruptionError is returned when a voluntary operation would breach an app's min_available budget.

func (*DisruptionError) Error

func (e *DisruptionError) Error() string

type Env

type Env func(string) string

Env reads a variable; OSEnv is the process environment.

var OSEnv Env = os.Getenv

OSEnv reads the real process environment.

type Policy

type Policy struct {
	MaxSurge       string `json:"max_surge,omitempty"`
	MaxUnavailable string `json:"max_unavailable,omitempty"`
	MinAvailable   string `json:"min_available,omitempty"`
}

Policy is an app's rollout settings as written: an int ("2") or a percent of replicas ("25%"). Empty inherits the env default.

func (Policy) Validate

func (p Policy) Validate() error

Validate checks a Policy as written, before any replica count is known.

type Progress

type Progress struct {
	Active         bool      `json:"active"`
	Phase          string    `json:"phase"`
	Wave           int       `json:"wave"`
	Waves          int       `json:"waves"`
	Desired        int       `json:"desired"`
	Updated        int       `json:"updated"`
	Ready          int       `json:"ready"`
	Unavailable    int       `json:"unavailable"`
	Surge          int       `json:"surge"`
	MaxSurge       int       `json:"max_surge"`
	MaxUnavailable int       `json:"max_unavailable"`
	Message        string    `json:"message,omitempty"`
	StartedAt      time.Time `json:"started_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Progress is one app's rolling deploy as the reconciler last saw it.

func Lookup

func Lookup(service string) (Progress, bool)

Lookup returns service's last recorded rollout, if any.

type Resolved

type Resolved struct {
	MaxSurge       int `json:"max_surge"`
	MaxUnavailable int `json:"max_unavailable"`
	MinAvailable   int `json:"min_available"`
}

Resolved is a Policy turned into replica counts for one replica total.

func Resolve

func Resolve(p Policy, env Env, replicas int) Resolved

Resolve fills empty fields from env and converts them for replicas. An unusable env value falls back rather than blocking every deploy.

func (Resolved) Step

func (r Resolved) Step() int

Step is how many replicas one wave replaces.

func (Resolved) Waves

func (r Resolved) Waves(replicas int) int

Waves is how many waves a full rollout of replicas takes.

Jump to

Keyboard shortcuts

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