deploymentwatcher

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MPL-2.0 Imports: 11 Imported by: 42

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

View Source
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 DeploymentRPC added in v0.12.0

type DeploymentRPC interface{}

DeploymentRPC and JobRPC hold methods for interacting with peer regions in enterprise edition.

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 JobRPC added in v0.12.0

type JobRPC interface{}

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,
	deploymentRPC DeploymentRPC, jobRPC JobRPC,
	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) CancelDeployment added in v0.12.0

CancelDeployment is used to cancel a multiregion deployment. In single-region deployments, the deploymentwatcher has sole responsibility to cancel deployments so this RPC is never used.

func (*Watcher) FailDeployment

FailDeployment is used to fail the deployment.

func (*Watcher) PauseDeployment

PauseDeployment is used to toggle the pause state on a deployment. If the deployment is being unpaused, an evaluation is created.

func (*Watcher) PromoteDeployment

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) RunDeployment added in v0.12.0

RunDeployment is used to run a pending multiregion deployment. In single-region deployments, the pending state is unused.

func (*Watcher) SetAllocHealth

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.

func (*Watcher) UnblockDeployment added in v0.12.0

UnblockDeployment is used to unblock a multiregion deployment. In single-region deployments, the blocked state is unused.

Jump to

Keyboard shortcuts

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