deploymentwatcher

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2018 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LimitStateQueriesPerSecond is the number of state queries allowed per
	// second
	LimitStateQueriesPerSecond = 100.0

	// CrossDeploymentEvalBatchDuration is the duration in which evaluations are
	// batched across all deployment watchers before committing to Raft.
	CrossDeploymentEvalBatchDuration = 250 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentRaftEndpoints

type DeploymentRaftEndpoints interface {
	// UpsertEvals is used to upsert a set of evaluations
	UpsertEvals([]*structs.Evaluation) (uint64, error)

	// 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)
}

DeploymentRaftEndpoints exposes the deployment watcher to a set of functions to apply data transforms via Raft.

type EvalBatcher

type EvalBatcher struct {
	// contains filtered or unexported fields
}

EvalBatcher is used to batch the creation of evaluations

func NewEvalBatcher

func NewEvalBatcher(batchDuration time.Duration, raft DeploymentRaftEndpoints, ctx context.Context) *EvalBatcher

NewEvalBatcher returns an EvalBatcher that uses the passed raft endpoints to create the evaluations and exits the batcher when the passed exit channel is closed.

func (*EvalBatcher) CreateEval

func (b *EvalBatcher) CreateEval(e *structs.Evaluation) *EvalFuture

CreateEval batches the creation of the evaluation and returns a future that tracks the evaluations creation.

type EvalFuture

type EvalFuture struct {
	// contains filtered or unexported fields
}

EvalFuture is a future that can be used to retrieve the index the eval was created at or any error in the creation process

func NewEvalFuture

func NewEvalFuture() *EvalFuture

NewEvalFuture returns a new EvalFuture

func (*EvalFuture) Results

func (f *EvalFuture) Results() (uint64, error)

Results returns the creation index and any error.

func (*EvalFuture) Set

func (f *EvalFuture) Set(index uint64, err error)

Set sets the results of the future, unblocking any client.

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,
	evalBatchDuration time.Duration) *Watcher

NewDeploymentsWatcher returns a deployments watcher that is used to watch deployments and trigger the scheduler as needed.

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) 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.

Jump to

Keyboard shortcuts

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