Documentation
¶
Overview ¶
Package canarypolicy holds the stage schedule, thresholds and env defaults of staged canary releases. It is a leaf so the app spec can import it.
Index ¶
Constants ¶
const ( EnvStages = "APP_CANARY_STAGES" EnvInterval = "APP_CANARY_INTERVAL" EnvMaxErrorRate = "APP_CANARY_MAX_ERROR_RATE" EnvMaxP95Ratio = "APP_CANARY_MAX_P95_RATIO" EnvMinRequests = "APP_CANARY_MIN_REQUESTS" EnvP95FloorMS = "APP_CANARY_P95_FLOOR_MS" EnvTick = "APP_CANARY_TICK" EnvSticky = "APP_CANARY_STICKY" EnvMaxHealthFailures = "APP_CANARY_MAX_HEALTH_FAILURES" EnvAlertRuleID = "APP_CANARY_ALERT_RULE_ID" )
Env vars that tune the defaults a per-app policy or start request can override.
const ( // MaxStages bounds a stage schedule. MaxStages = 10 // MaxWeight is the largest share ingress gives a canary; 100 means promote. MaxWeight = 99 // Full is the stage value that means "promote". Full = 100 )
Variables ¶
This section is empty.
Functions ¶
func ParseStages ¶
ParseStages parses "10,25,50,100"; an empty string yields no stages.
func SetLiveEnv ¶
SetLiveEnv points the defaults at the runtime settings so a change applies to the next stage or release. nil goes back to the process environment alone.
func StickyEnabled ¶
StickyEnabled reports whether ingress pins a visitor to one release by cookie. It is on unless the setting says otherwise.
func ValidateStages ¶
ValidateStages checks a schedule: ascending percents of 1 to 100, at least one below 100 so something is judged before promotion.
Types ¶
type Limits ¶
type Limits struct {
// MinRequests is the canary request count a stage needs before it is judged.
MinRequests uint64
// P95FloorMS ignores latency ratios while the canary p95 is below it.
P95FloorMS float64
Tick time.Duration
// MaxHealthFailures rolls the canary back once its liveness probe has failed this many
// times in a row; 0 turns the check off.
MaxHealthFailures uint64
// AlertRuleID names an alert rule whose firing state also rolls the canary back; empty is off.
AlertRuleID string
}
Limits are the judgement knobs that are global rather than per app.
func DefaultLimits ¶
DefaultLimits returns the global limits overridden by APP_CANARY_* env vars.
type Policy ¶
type Policy struct {
Stages []int
// Interval is how long each stage observes traffic before it may advance.
Interval time.Duration
// MaxErrorRate is how far (as a fraction, 0.02 is two points) the canary's
// 5xx rate may exceed the stable release's before the canary is rolled back.
MaxErrorRate float64
// MaxP95Ratio is how many times the stable p95 the canary's p95 may reach.
MaxP95Ratio float64
}
Policy is the stage schedule and breach thresholds of one staged canary.
func DefaultPolicy ¶
DefaultPolicy returns the built-in defaults overridden by APP_CANARY_* env vars.