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 ¶
const AuditActionAutoRollback = "deploy.auto_rollback"
AuditActionAutoRollback is the audit action for a rollback the watch started.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditSink ¶
type AuditSink interface {
SaveAuditEntry(ctx context.Context, e store.AuditEntry) error
}
AuditSink writes audit log rows. *store.DB satisfies it.
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 ¶
RestartCounter counts restarts of the named containers 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
// Audit, when set, records automatic rollbacks in the audit log.
Audit AuditSink
Logger *slog.Logger
// contains filtered or unexported fields
}
Watcher watches each release for its post-deploy window.