deploywatch

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package deploywatch pins released images as rollback targets and watches each new release after cutover, rolling it back when it misbehaves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PinRef

func PinRef(namespace, serviceName, attemptID string) string

PinRef is the local tag that pins attemptID's image for serviceName.

Types

type Notifier

type Notifier func(ctx context.Context, app, image, message string)

Notifier tells operators a live release was rolled back or needs one.

type PinStore

type PinStore interface {
	LatestDeployAttemptFor(ctx context.Context, serviceName, image string) (*store.DeployAttempt, error)
	SaveRollbackPin(ctx context.Context, p store.RollbackPin) error
	ListRollbackPins(ctx context.Context, serviceName string) ([]store.RollbackPin, error)
	DeleteRollbackPin(ctx context.Context, serviceName, attemptID string) error
}

PinStore is the store surface the Pinner needs. *store.DB satisfies it.

type Pinner

type Pinner struct {
	Store       PinStore
	Images      docker.ImagePinner
	Keep        int
	Namespace   string
	LocalNodeID string
	Logger      *slog.Logger
}

Pinner tags each release that takes traffic with an extra local reference, keeping the newest Keep per app. It only pins apps on the local node, where its image client can reach the image.

func (*Pinner) PinServing

func (p *Pinner) PinServing(ctx context.Context, desired store.DesiredService, imageID string) (string, error)

PinServing implements application.RollbackPinner. It returns the new pin reference, or "" when nothing needed pinning.

type RestartCounter

type RestartCounter interface {
	CountSince(resourceID string, since time.Time) int
}

RestartCounter counts container restarts per resource since a time. alerting.RestartTracker satisfies it.

type WatchStore

type WatchStore interface {
	deploy.ImageDeployStore
	ListGateEventsSince(ctx context.Context, phase, status string, since time.Time) ([]store.DeployGateEvent, error)
	ListGateEvents(ctx context.Context, attemptID string) ([]store.DeployGateEvent, error)
	RecordGateEvent(ctx context.Context, e store.DeployGateEvent) error
	GetDesiredService(ctx context.Context, name string) (*store.DesiredService, error)
	GetDeployAttempt(ctx context.Context, id string) (*store.DeployAttempt, error)
	ListDeployAttempts(ctx context.Context, serviceName string) ([]store.DeployAttempt, error)
	GetDeploySafetySettings(ctx context.Context, serviceName string) (store.DeploySafetySettings, error)
	FailDeployAttemptWithReason(ctx context.Context, id, reason, message string) (bool, error)
	SetDeployAttemptReason(ctx context.Context, id, reason string) error
	ListRollbackPins(ctx context.Context, serviceName string) ([]store.RollbackPin, error)
}

WatchStore is the store surface the Watcher needs. *store.DB satisfies it.

type Watcher

type Watcher struct {
	Store    WatchStore
	Defaults deploysafety.Effective
	// Inspectors returns the exit-state inspector for an app's node.
	Inspectors func(nodeID string) (docker.ExitStateInspector, error)
	Restarts   RestartCounter
	Metrics    telemetry.MetricsQuerier
	Resolver   docker.ImageResolver
	Nudger     deploy.ReconcileNudger
	Notify     Notifier
	// SampleInterval is the request sampler's tick; samples within one tick
	// of cutover are left out of the 5xx rate.
	SampleInterval time.Duration
	Logger         *slog.Logger
	// contains filtered or unexported fields
}

Watcher watches each release for its post-deploy window.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context, interval time.Duration)

Run ticks every interval until ctx is done.

func (*Watcher) Tick

func (w *Watcher) Tick(ctx context.Context)

Tick evaluates every release whose watch window may still be open.

Jump to

Keyboard shortcuts

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