deploymentwatcher

package
v0.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2017 License: MPL-2.0 Imports: 8 Imported by: 42

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 commiting 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 DeploymentStateWatchers

type DeploymentStateWatchers interface {
	// Evaluations returns the set of evaluations for the given job
	Evaluations(args *structs.JobSpecificRequest, reply *structs.JobEvaluationsResponse) error

	// Allocations returns the set of allocations that are part of the
	// deployment.
	Allocations(args *structs.DeploymentSpecificRequest, reply *structs.AllocListResponse) error

	// List is used to list all the deployments in the system
	List(args *structs.DeploymentListRequest, reply *structs.DeploymentListResponse) error

	// GetDeployment is used to lookup a particular deployment.
	GetDeployment(args *structs.DeploymentSpecificRequest, reply *structs.SingleDeploymentResponse) error

	// GetJobVersions is used to lookup the versions of a job. This is used when
	// rolling back to find the latest stable job
	GetJobVersions(args *structs.JobVersionsRequest, reply *structs.JobVersionsResponse) error

	// GetJob is used to lookup a particular job.
	GetJob(args *structs.JobSpecificRequest, reply *structs.SingleJobResponse) error
}

DeploymentStateWatchers are the set of functions required to watch objects on behalf of a deployment

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

func NewDeploymentsWatcher

func NewDeploymentsWatcher(logger *log.Logger, watchers DeploymentStateWatchers,
	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) error

SetEnabled is used to control if the watcher is enabled. The watcher should only be enabled on the active leader.

Jump to

Keyboard shortcuts

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