Documentation ¶
Overview ¶
deploymentwatcher creates and tracks Deployments, which hold meta data describing the process of upgrading a running job to a new set of Allocations. This encompasses settings for canary deployments and blue/green rollouts.
- The watcher is only enabled on the active raft leader. - func (w *deploymentWatcher) watch() is the main deploymentWatcher process
Index ¶
- Constants
- type AllocUpdateBatcher
- type BatchFuture
- type DeploymentRaftEndpoints
- type Watcher
- func (w *Watcher) FailDeployment(req *structs.DeploymentFailRequest, resp *structs.DeploymentUpdateResponse) error
- func (w *Watcher) PauseDeployment(req *structs.DeploymentPauseRequest, resp *structs.DeploymentUpdateResponse) error
- func (w *Watcher) PromoteDeployment(req *structs.DeploymentPromoteRequest, resp *structs.DeploymentUpdateResponse) error
- func (w *Watcher) SetAllocHealth(req *structs.DeploymentAllocHealthRequest, ...) error
- func (w *Watcher) SetEnabled(enabled bool, state *state.StateStore)
Constants ¶
const ( // LimitStateQueriesPerSecond is the number of state queries allowed per // second LimitStateQueriesPerSecond = 100.0 // CrossDeploymentUpdateBatchDuration is the duration in which allocation // desired transition and evaluation creation updates are batched across // all deployment watchers before committing to Raft. CrossDeploymentUpdateBatchDuration = 250 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllocUpdateBatcher ¶ added in v0.8.4
type AllocUpdateBatcher struct {
// contains filtered or unexported fields
}
AllocUpdateBatcher is used to batch the updates to the desired transitions of allocations and the creation of evals.
func NewAllocUpdateBatcher ¶ added in v0.8.4
func NewAllocUpdateBatcher(ctx context.Context, batchDuration time.Duration, raft DeploymentRaftEndpoints) *AllocUpdateBatcher
NewAllocUpdateBatcher returns an AllocUpdateBatcher that uses the passed raft endpoints to create the allocation desired transition updates and new evaluations and exits the batcher when the passed exit channel is closed.
func (*AllocUpdateBatcher) CreateUpdate ¶ added in v0.8.4
func (b *AllocUpdateBatcher) CreateUpdate(allocs map[string]*structs.DesiredTransition, eval *structs.Evaluation) *BatchFuture
CreateUpdate batches the allocation desired transition update and returns a future that tracks the completion of the request.
type BatchFuture ¶ added in v0.8.4
type BatchFuture struct {
// contains filtered or unexported fields
}
BatchFuture is a future that can be used to retrieve the index the eval was created at or any error in the creation process
func NewBatchFuture ¶ added in v0.8.4
func NewBatchFuture() *BatchFuture
NewBatchFuture returns a new BatchFuture
func (*BatchFuture) Results ¶ added in v0.8.4
func (f *BatchFuture) Results() (uint64, error)
Results returns the creation index and any error.
func (*BatchFuture) Set ¶ added in v0.8.4
func (f *BatchFuture) Set(index uint64, err error)
Set sets the results of the future, unblocking any client.
type DeploymentRaftEndpoints ¶
type DeploymentRaftEndpoints interface { // UpsertJob is used to upsert a job UpsertJob(job *structs.Job) (uint64, error) // UpdateDeploymentStatus is used to make a deployment status update // and potentially create an evaluation. UpdateDeploymentStatus(u *structs.DeploymentStatusUpdateRequest) (uint64, error) // UpdateDeploymentPromotion is used to promote canaries in a deployment UpdateDeploymentPromotion(req *structs.ApplyDeploymentPromoteRequest) (uint64, error) // UpdateDeploymentAllocHealth is used to set the health of allocations in a // deployment UpdateDeploymentAllocHealth(req *structs.ApplyDeploymentAllocHealthRequest) (uint64, error) // UpdateAllocDesiredTransition is used to update the desired transition // for allocations. UpdateAllocDesiredTransition(req *structs.AllocUpdateDesiredTransitionRequest) (uint64, error) }
DeploymentRaftEndpoints exposes the deployment watcher to a set of functions to apply data transforms via Raft.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher is used to watch deployments and their allocations created by the scheduler and trigger the scheduler when allocation health transitions.
func NewDeploymentsWatcher ¶
func NewDeploymentsWatcher(logger log.Logger, raft DeploymentRaftEndpoints, stateQueriesPerSecond float64, updateBatchDuration time.Duration) *Watcher
NewDeploymentsWatcher returns a deployments watcher that is used to watch deployments and trigger the scheduler as needed.
func (*Watcher) FailDeployment ¶
func (w *Watcher) FailDeployment(req *structs.DeploymentFailRequest, resp *structs.DeploymentUpdateResponse) error
FailDeployment is used to fail the deployment.
func (*Watcher) PauseDeployment ¶
func (w *Watcher) PauseDeployment(req *structs.DeploymentPauseRequest, resp *structs.DeploymentUpdateResponse) error
PauseDeployment is used to toggle the pause state on a deployment. If the deployment is being unpaused, an evaluation is created.
func (*Watcher) PromoteDeployment ¶
func (w *Watcher) PromoteDeployment(req *structs.DeploymentPromoteRequest, resp *structs.DeploymentUpdateResponse) error
PromoteDeployment is used to promote a deployment. If promote is false, deployment is marked as failed. Otherwise the deployment is updated and an evaluation is created.
func (*Watcher) SetAllocHealth ¶
func (w *Watcher) SetAllocHealth(req *structs.DeploymentAllocHealthRequest, resp *structs.DeploymentUpdateResponse) error
SetAllocHealth is used to set the health of allocations for a deployment. If there are any unhealthy allocations, the deployment is updated to be failed. Otherwise the allocations are updated and an evaluation is created.
func (*Watcher) SetEnabled ¶
func (w *Watcher) SetEnabled(enabled bool, state *state.StateStore)
SetEnabled is used to control if the watcher is enabled. The watcher should only be enabled on the active leader. When being enabled the state is passed in as it is no longer valid once a leader election has taken place.