Documentation

Index

Constants

View Source
const (

	// Prefix based errors that are used to check if the error is of a given
	// type. These errors should be created with the associated constructor.
	ErrUnknownAllocationPrefix = "Unknown allocation"
	ErrUnknownNodePrefix       = "Unknown node"
	ErrUnknownJobPrefix        = "Unknown job"
	ErrUnknownEvaluationPrefix = "Unknown evaluation"
	ErrUnknownDeploymentPrefix = "Unknown deployment"
)
View Source
const (
	// MinDynamicPort is the smallest dynamic port generated
	MinDynamicPort = 20000

	// MaxDynamicPort is the largest dynamic port generated
	MaxDynamicPort = 32000
)
View Source
const (
	EnvoyBootstrapPath = "${NOMAD_SECRETS_DIR}/envoy_bootstrap.json"

	ServiceCheckHTTP   = "http"
	ServiceCheckTCP    = "tcp"
	ServiceCheckScript = "script"
	ServiceCheckGRPC   = "grpc"
)
View Source
const (
	AddressModeAuto   = "auto"
	AddressModeHost   = "host"
	AddressModeDriver = "driver"
)
View Source
const (
	// IgnoreUnknownTypeFlag is set along with a MessageType
	// to indicate that the message type can be safely ignored
	// if it is not recognized. This is for future proofing, so
	// that new commands can be added in a way that won't cause
	// old servers to crash when the FSM attempts to process them.
	IgnoreUnknownTypeFlag MessageType = 128

	// ApiMajorVersion is returned as part of the Status.Version request.
	// It should be incremented anytime the APIs are changed in a way
	// that would break clients for sane client versioning.
	ApiMajorVersion = 1

	// ApiMinorVersion is returned as part of the Status.Version request.
	// It should be incremented anytime the APIs are changed to allow
	// for sane client versioning. Minor changes should be compatible
	// within the major version.
	ApiMinorVersion = 1

	ProtocolVersion = "protocol"
	APIMajorVersion = "api.major"
	APIMinorVersion = "api.minor"

	GetterModeAny  = "any"
	GetterModeFile = "file"
	GetterModeDir  = "dir"

	// ACLClientToken and ACLManagementToken are the only types of tokens
	ACLClientToken     = "client"
	ACLManagementToken = "management"

	// DefaultNamespace is the default namespace.
	DefaultNamespace            = "default"
	DefaultNamespaceDescription = "Default shared namespace"

	// JitterFraction is a the limit to the amount of jitter we apply
	// to a user specified MaxQueryTime. We divide the specified time by
	// the fraction. So 16 == 6.25% limit of jitter. This jitter is also
	// applied to RPCHoldTimeout.
	JitterFraction = 16

	// MaxRetainedNodeEvents is the maximum number of node events that will be
	// retained for a single node
	MaxRetainedNodeEvents = 10

	// MaxRetainedNodeScores is the number of top scoring nodes for which we
	// retain scoring metadata
	MaxRetainedNodeScores = 5

	// Normalized scorer name
	NormScorerName = "normalized-score"
)
View Source
const (
	NodeEventSubsystemDrain     = "Drain"
	NodeEventSubsystemDriver    = "Driver"
	NodeEventSubsystemHeartbeat = "Heartbeat"
	NodeEventSubsystemCluster   = "Cluster"
)
View Source
const (
	NodeStatusInit  = "initializing"
	NodeStatusReady = "ready"
	NodeStatusDown  = "down"
)
View Source
const (
	// NodeSchedulingEligible and Ineligible marks the node as eligible or not,
	// respectively, for receiving allocations. This is orthoginal to the node
	// status being ready.
	NodeSchedulingEligible   = "eligible"
	NodeSchedulingIneligible = "ineligible"
)
View Source
const (
	// JobTypeNomad is reserved for internal system tasks and is
	// always handled by the CoreScheduler.
	JobTypeCore    = "_core"
	JobTypeService = "service"
	JobTypeBatch   = "batch"
	JobTypeSystem  = "system"
)
View Source
const (
	JobStatusPending = "pending" // Pending means the job is waiting on scheduling
	JobStatusRunning = "running" // Running means the job has non-terminal allocations
	JobStatusDead    = "dead"    // Dead means all evaluation's and allocations are terminal
)
View Source
const (
	// JobMinPriority is the minimum allowed priority
	JobMinPriority = 1

	// JobDefaultPriority is the default priority if not
	// not specified.
	JobDefaultPriority = 50

	// JobMaxPriority is the maximum allowed priority
	JobMaxPriority = 100

	// Ensure CoreJobPriority is higher than any user
	// specified job so that it gets priority. This is important
	// for the system to remain healthy.
	CoreJobPriority = JobMaxPriority * 2

	// JobTrackedVersions is the number of historic job versions that are
	// kept.
	JobTrackedVersions = 6
)
View Source
const (
	// Checks uses any registered health check state in combination with task
	// states to determine if a allocation is healthy.
	UpdateStrategyHealthCheck_Checks = "checks"

	// TaskStates uses the task states of an allocation to determine if the
	// allocation is healthy.
	UpdateStrategyHealthCheck_TaskStates = "task_states"

	// Manual allows the operator to manually signal to Nomad when an
	// allocations is healthy. This allows more advanced health checking that is
	// outside of the scope of Nomad.
	UpdateStrategyHealthCheck_Manual = "manual"
)
View Source
const (
	// PeriodicSpecCron is used for a cron spec.
	PeriodicSpecCron = "cron"

	// PeriodicSpecTest is only used by unit tests. It is a sorted, comma
	// separated list of unix timestamps at which to launch.
	PeriodicSpecTest = "_internal_test"
)
View Source
const (
	DispatchPayloadForbidden = "forbidden"
	DispatchPayloadOptional  = "optional"
	DispatchPayloadRequired  = "required"

	// DispatchLaunchSuffix is the string appended to the parameterized job's ID
	// when dispatching instances of it.
	DispatchLaunchSuffix = "/dispatch-"
)
View Source
const (
	// RestartPolicyModeDelay causes an artificial delay till the next interval is
	// reached when the specified attempts have been reached in the interval.
	RestartPolicyModeDelay = "delay"

	// RestartPolicyModeFail causes a job to fail if the specified number of
	// attempts are reached within an interval.
	RestartPolicyModeFail = "fail"

	// RestartPolicyMinInterval is the minimum interval that is accepted for a
	// restart policy.
	RestartPolicyMinInterval = 5 * time.Second

	// ReasonWithinPolicy describes restart events that are within policy
	ReasonWithinPolicy = "Restart within policy"
)
View Source
const (
	MigrateStrategyHealthChecks = "checks"
	MigrateStrategyHealthStates = "task_states"
)
View Source
const (
	// TemplateChangeModeNoop marks that no action should be taken if the
	// template is re-rendered
	TemplateChangeModeNoop = "noop"

	// TemplateChangeModeSignal marks that the task should be signaled if the
	// template is re-rendered
	TemplateChangeModeSignal = "signal"

	// TemplateChangeModeRestart marks that the task should be restarted if the
	// template is re-rendered
	TemplateChangeModeRestart = "restart"
)
View Source
const (
	TaskStatePending = "pending" // The task is waiting to be run.
	TaskStateRunning = "running" // The task is currently running.
	TaskStateDead    = "dead"    // Terminal state of task.
)

Set of possible states for a task.

View Source
const (
	// TaskSetupFailure indicates that the task could not be started due to a
	// a setup failure.
	TaskSetupFailure = "Setup Failure"

	// TaskDriveFailure indicates that the task could not be started due to a
	// failure in the driver. TaskDriverFailure is considered Recoverable.
	TaskDriverFailure = "Driver Failure"

	// TaskReceived signals that the task has been pulled by the client at the
	// given timestamp.
	TaskReceived = "Received"

	// TaskFailedValidation indicates the task was invalid and as such was not run.
	// TaskFailedValidation is not considered Recoverable.
	TaskFailedValidation = "Failed Validation"

	// TaskStarted signals that the task was started and its timestamp can be
	// used to determine the running length of the task.
	TaskStarted = "Started"

	// TaskTerminated indicates that the task was started and exited.
	TaskTerminated = "Terminated"

	// TaskKilling indicates a kill signal has been sent to the task.
	TaskKilling = "Killing"

	// TaskKilled indicates a user has killed the task.
	TaskKilled = "Killed"

	// TaskRestarting indicates that task terminated and is being restarted.
	TaskRestarting = "Restarting"

	// TaskNotRestarting indicates that the task has failed and is not being
	// restarted because it has exceeded its restart policy.
	TaskNotRestarting = "Not Restarting"

	// TaskRestartSignal indicates that the task has been signalled to be
	// restarted
	TaskRestartSignal = "Restart Signaled"

	// TaskSignaling indicates that the task is being signalled.
	TaskSignaling = "Signaling"

	// TaskDownloadingArtifacts means the task is downloading the artifacts
	// specified in the task.
	TaskDownloadingArtifacts = "Downloading Artifacts"

	// TaskArtifactDownloadFailed indicates that downloading the artifacts
	// failed.
	TaskArtifactDownloadFailed = "Failed Artifact Download"

	// TaskBuildingTaskDir indicates that the task directory/chroot is being
	// built.
	TaskBuildingTaskDir = "Building Task Directory"

	// TaskSetup indicates the task runner is setting up the task environment
	TaskSetup = "Task Setup"

	// TaskDiskExceeded indicates that one of the tasks in a taskgroup has
	// exceeded the requested disk resources.
	TaskDiskExceeded = "Disk Resources Exceeded"

	// TaskSiblingFailed indicates that a sibling task in the task group has
	// failed.
	TaskSiblingFailed = "Sibling Task Failed"

	// TaskDriverMessage is an informational event message emitted by
	// drivers such as when they're performing a long running action like
	// downloading an image.
	TaskDriverMessage = "Driver"

	// TaskLeaderDead indicates that the leader task within the has finished.
	TaskLeaderDead = "Leader Task Dead"

	// TaskHookFailed indicates that one of the hooks for a task failed.
	TaskHookFailed = "Task hook failed"

	// TaskRestoreFailed indicates Nomad was unable to reattach to a
	// restored task.
	TaskRestoreFailed = "Failed Restoring Task"
)
View Source
const (
	ConstraintDistinctProperty  = "distinct_property"
	ConstraintDistinctHosts     = "distinct_hosts"
	ConstraintRegex             = "regexp"
	ConstraintVersion           = "version"
	ConstraintSetContains       = "set_contains"
	ConstraintSetContainsAll    = "set_contains_all"
	ConstraintSetContainsAny    = "set_contains_any"
	ConstraintAttributeIsSet    = "is_set"
	ConstraintAttributeIsNotSet = "is_not_set"
)
View Source
const (
	// VaultChangeModeNoop takes no action when a new token is retrieved.
	VaultChangeModeNoop = "noop"

	// VaultChangeModeSignal signals the task when a new token is retrieved.
	VaultChangeModeSignal = "signal"

	// VaultChangeModeRestart restarts the task when a new token is retrieved.
	VaultChangeModeRestart = "restart"
)
View Source
const (
	// DeploymentStatuses are the various states a deployment can be be in
	DeploymentStatusRunning    = "running"
	DeploymentStatusPaused     = "paused"
	DeploymentStatusFailed     = "failed"
	DeploymentStatusSuccessful = "successful"
	DeploymentStatusCancelled  = "cancelled"

	// DeploymentStatusDescriptions are the various descriptions of the states a
	// deployment can be in.
	DeploymentStatusDescriptionRunning               = "Deployment is running"
	DeploymentStatusDescriptionRunningNeedsPromotion = "Deployment is running but requires manual promotion"
	DeploymentStatusDescriptionRunningAutoPromotion  = "Deployment is running pending automatic promotion"
	DeploymentStatusDescriptionPaused                = "Deployment is paused"
	DeploymentStatusDescriptionSuccessful            = "Deployment completed successfully"
	DeploymentStatusDescriptionStoppedJob            = "Cancelled because job is stopped"
	DeploymentStatusDescriptionNewerJob              = "Cancelled due to newer version of job"
	DeploymentStatusDescriptionFailedAllocations     = "Failed due to unhealthy allocations"
	DeploymentStatusDescriptionProgressDeadline      = "Failed due to progress deadline"
	DeploymentStatusDescriptionFailedByUser          = "Deployment marked as failed"
)
View Source
const (
	AllocDesiredStatusRun   = "run"   // Allocation should run
	AllocDesiredStatusStop  = "stop"  // Allocation should stop
	AllocDesiredStatusEvict = "evict" // Allocation should stop, and was evicted
)
View Source
const (
	AllocClientStatusPending  = "pending"
	AllocClientStatusRunning  = "running"
	AllocClientStatusComplete = "complete"
	AllocClientStatusFailed   = "failed"
	AllocClientStatusLost     = "lost"
)
View Source
const (
	EvalStatusBlocked   = "blocked"
	EvalStatusPending   = "pending"
	EvalStatusComplete  = "complete"
	EvalStatusFailed    = "failed"
	EvalStatusCancelled = "canceled"
)
View Source
const (
	EvalTriggerJobRegister       = "job-register"
	EvalTriggerJobDeregister     = "job-deregister"
	EvalTriggerPeriodicJob       = "periodic-job"
	EvalTriggerNodeDrain         = "node-drain"
	EvalTriggerNodeUpdate        = "node-update"
	EvalTriggerAllocStop         = "alloc-stop"
	EvalTriggerScheduled         = "scheduled"
	EvalTriggerRollingUpdate     = "rolling-update"
	EvalTriggerDeploymentWatcher = "deployment-watcher"
	EvalTriggerFailedFollowUp    = "failed-follow-up"
	EvalTriggerMaxPlans          = "max-plan-attempts"
	EvalTriggerRetryFailedAlloc  = "alloc-failure"
	EvalTriggerQueuedAllocs      = "queued-allocs"
	EvalTriggerPreemption        = "preemption"
)
View Source
const (
	// CoreJobEvalGC is used for the garbage collection of evaluations
	// and allocations. We periodically scan evaluations in a terminal state,
	// in which all the corresponding allocations are also terminal. We
	// delete these out of the system to bound the state.
	CoreJobEvalGC = "eval-gc"

	// CoreJobNodeGC is used for the garbage collection of failed nodes.
	// We periodically scan nodes in a terminal state, and if they have no
	// corresponding allocations we delete these out of the system.
	CoreJobNodeGC = "node-gc"

	// CoreJobJobGC is used for the garbage collection of eligible jobs. We
	// periodically scan garbage collectible jobs and check if both their
	// evaluations and allocations are terminal. If so, we delete these out of
	// the system.
	CoreJobJobGC = "job-gc"

	// CoreJobDeploymentGC is used for the garbage collection of eligible
	// deployments. We periodically scan garbage collectible deployments and
	// check if they are terminal. If so, we delete these out of the system.
	CoreJobDeploymentGC = "deployment-gc"

	// CoreJobForceGC is used to force garbage collection of all GCable objects.
	CoreJobForceGC = "force-gc"
)
View Source
const (
	BytesInMegabyte = 1024 * 1024
)
View Source
const ConnectProxyPrefix = "connect-proxy"

ConnectProxyPrefix is the prefix used for fields referencing a Consul Connect Proxy

View Source
const (
	// DefaultKillTimeout is the default timeout between signaling a task it
	// will be killed and killing it.
	DefaultKillTimeout = 5 * time.Second
)
View Source
const (
	// NodeUniqueNamespace is a prefix that can be appended to node meta or
	// attribute keys to mark them for exclusion in computed node class.
	NodeUniqueNamespace = "unique."
)
View Source
const (
	// PeriodicLaunchSuffix is the string appended to the periodic jobs ID
	// when launching derived instances of it.
	PeriodicLaunchSuffix = "/periodic-"
)
View Source
const ReschedulePolicyMinDelay = 5 * time.Second
View Source
const ReschedulePolicyMinInterval = 15 * time.Second
View Source
const (
	VolumeTypeHost = "host"
)

Variables

View Source
var (
	ErrNoLeader                   = errors.New(errNoLeader)
	ErrNotReadyForConsistentReads = errors.New(errNotReadyForConsistentReads)
	ErrNoRegionPath               = errors.New(errNoRegionPath)
	ErrTokenNotFound              = errors.New(errTokenNotFound)
	ErrPermissionDenied           = errors.New(errPermissionDenied)
	ErrNoNodeConn                 = errors.New(errNoNodeConn)
	ErrUnknownMethod              = errors.New(errUnknownMethod)
	ErrUnknownNomadVersion        = errors.New(errUnknownNomadVersion)
	ErrNodeLacksRpc               = errors.New(errNodeLacksRpc)
	ErrMissingAllocID             = errors.New(errMissingAllocID)
)
View Source
var (
	DefaultServiceJobRestartPolicy = RestartPolicy{
		Delay:    15 * time.Second,
		Attempts: 2,
		Interval: 30 * time.Minute,
		Mode:     RestartPolicyModeFail,
	}
	DefaultBatchJobRestartPolicy = RestartPolicy{
		Delay:    15 * time.Second,
		Attempts: 3,
		Interval: 24 * time.Hour,
		Mode:     RestartPolicyModeFail,
	}
)
View Source
var (
	DefaultServiceJobReschedulePolicy = ReschedulePolicy{
		Delay:         30 * time.Second,
		DelayFunction: "exponential",
		MaxDelay:      1 * time.Hour,
		Unlimited:     true,
	}
	DefaultBatchJobReschedulePolicy = ReschedulePolicy{
		Attempts:      1,
		Interval:      24 * time.Hour,
		Delay:         5 * time.Second,
		DelayFunction: "constant",
	}
)
View Source
var (
	// JsonHandle and JsonHandlePretty are the codec handles to JSON encode
	// structs. The pretty handle will add indents for easier human consumption.
	JsonHandle = &codec.JsonHandle{
		HTMLCharsAsIs: true,
	}
	JsonHandlePretty = &codec.JsonHandle{
		HTMLCharsAsIs: true,
		Indent:        4,
	}
)
View Source
var (
	// AnonymousACLToken is used no SecretID is provided, and the
	// request is made anonymously.
	AnonymousACLToken = &ACLToken{
		AccessorID: "anonymous",
		Name:       "Anonymous Token",
		Type:       ACLClientToken,
		Policies:   []string{"anonymous"},
		Global:     false,
	}
)
View Source
var (
	// DefaultUpdateStrategy provides a baseline that can be used to upgrade
	// jobs with the old policy or for populating field defaults.
	DefaultUpdateStrategy = &UpdateStrategy{
		Stagger:          30 * time.Second,
		MaxParallel:      1,
		HealthCheck:      UpdateStrategyHealthCheck_Checks,
		MinHealthyTime:   10 * time.Second,
		HealthyDeadline:  5 * time.Minute,
		ProgressDeadline: 10 * time.Minute,
		AutoRevert:       false,
		AutoPromote:      false,
		Canary:           0,
	}
)
View Source
var HashiMsgpackHandle = func() *hcodec.MsgpackHandle {
	h := &hcodec.MsgpackHandle{}
	h.RawToString = true

	h.BasicHandle.TimeNotBuiltin = true

	h.MapType = reflect.TypeOf(map[string]interface{}(nil))
	return h
}()

TODO Figure out if we can remove this. This is our fork that is just way behind. I feel like its original purpose was to pin at a stable version but now we can accomplish this with vendoring.

View Source
var MsgpackHandle = func() *codec.MsgpackHandle {
	h := &codec.MsgpackHandle{}
	h.RawToString = true

	h.BasicHandle.TimeNotBuiltin = true

	h.MapType = reflect.TypeOf(map[string]interface{}(nil))

	return h
}()

msgpackHandle is a shared handle for encoding/decoding of structs

View Source
var RescheduleDelayFunctions = [...]string{"constant", "exponential", "fibonacci"}
View Source
var (
	// TemplateChangeModeInvalidError is the error for when an invalid change
	// mode is given
	TemplateChangeModeInvalidError = errors.New("Invalid change mode. Must be one of the following: noop, signal, restart")
)
View Source
var (
	// VaultUnrecoverableError matches unrecoverable errors returned by a Vault
	// server
	VaultUnrecoverableError = regexp.MustCompile(`Code:\s+40(0|3|4)`)
)

Functions

func ACLPolicyListHash

func ACLPolicyListHash(policies []*ACLPolicy) string

ACLPolicyListHash returns a consistent hash for a set of policies.

func AllocName

func AllocName(job, group string, idx uint) string

AllocName returns the name of the allocation given the input.

func Bridge

func Bridge(a, b io.ReadWriteCloser)

Bridge is used to just link two connections together and copy traffic

func CompareMigrateToken

func CompareMigrateToken(allocID, nodeSecretID, otherMigrateToken string) bool

CompareMigrateToken returns true if two migration tokens can be computed and are equal.

func CompileACLObject

func CompileACLObject(cache *lru.TwoQueueCache, policies []*ACLPolicy) (*acl.ACL, error)

CompileACLObject compiles a set of ACL policies into an ACL object with a cache

func CopyMapStringClientHostVolumeConfig

func CopyMapStringClientHostVolumeConfig(m map[string]*ClientHostVolumeConfig) map[string]*ClientHostVolumeConfig

func CopyMapVolumeRequest

func CopyMapVolumeRequest(s map[string]*VolumeRequest) map[string]*VolumeRequest

func CronParseNext

func CronParseNext(e *cronexpr.Expression, fromTime time.Time, spec string) (t time.Time, err error)

CronParseNext is a helper that parses the next time for the given expression but captures any panic that may occur in the underlying library.

func Decode

func Decode(buf []byte, out interface{}) error

Decode is used to decode a MsgPack encoded object

func DenormalizeAllocationJobs

func DenormalizeAllocationJobs(job *Job, allocs []*Allocation)

DenormalizeAllocationJobs is used to attach a job to all allocations that are non-terminal and do not have a job already. This is useful in cases where the job is normalized.

func DeploymentStatusDescriptionNoRollbackTarget

func DeploymentStatusDescriptionNoRollbackTarget(baseDescription string) string

DeploymentStatusDescriptionNoRollbackTarget is used to get the status description of a deployment when there is no target to rollback to but autorevert is desired.

func DeploymentStatusDescriptionRollback

func DeploymentStatusDescriptionRollback(baseDescription string, jobVersion uint64) string

DeploymentStatusDescriptionRollback is used to get the status description of a deployment when rolling back to an older job.

func DeploymentStatusDescriptionRollbackNoop

func DeploymentStatusDescriptionRollbackNoop(baseDescription string, jobVersion uint64) string

DeploymentStatusDescriptionRollbackNoop is used to get the status description of a deployment when rolling back is not possible because it has the same specification

func DevicesEquals

func DevicesEquals(d1, d2 []*NodeDeviceResource) bool

DevicesEquals returns true if the two device arrays are set equal

func DispatchedID

func DispatchedID(templateID string, t time.Time) string

DispatchedID returns an ID appropriate for a job dispatched against a particular parameterized job

func Encode

func Encode(t MessageType, msg interface{}) ([]byte, error)

Encode is used to encode a MsgPack object with type prefix

func GenerateMigrateToken

func GenerateMigrateToken(allocID, nodeSecretID string) (string, error)

GenerateMigrateToken will create a token for a client to access an authenticated volume of another client to migrate data for sticky volumes.

func IsErrNoLeader

func IsErrNoLeader(err error) bool

IsErrNoLeader returns whether the error is due to there being no leader.

func IsErrNoNodeConn

func IsErrNoNodeConn(err error) bool

IsErrNoNodeConn returns whether the error is due to there being no path to the given node.

func IsErrNoRegionPath

func IsErrNoRegionPath(err error) bool

IsErrNoRegionPath returns whether the error is due to there being no path to the given region.

func IsErrNodeLacksRpc

func IsErrNodeLacksRpc(err error) bool

IsErrNodeLacksRpc returns whether error is due to a Nomad server being unable to connect to a client node because the client is too old (pre-v0.8).

func IsErrPermissionDenied

func IsErrPermissionDenied(err error) bool

IsErrPermissionDenied returns whether the error is due to the operation not being allowed due to lack of permissions.

func IsErrTokenNotFound

func IsErrTokenNotFound(err error) bool

IsErrTokenNotFound returns whether the error is due to the passed token not being resolvable.

func IsErrUnknownAllocation

func IsErrUnknownAllocation(err error) bool

IsErrUnknownAllocation returns whether the error is due to an unknown allocation.

func IsErrUnknownDeployment

func IsErrUnknownDeployment(err error) bool

IsErrUnknownDeployment returns whether the error is due to an unknown deployment.

func IsErrUnknownEvaluation

func IsErrUnknownEvaluation(err error) bool

IsErrUnknownEvaluation returns whether the error is due to an unknown evaluation.

func IsErrUnknownJob

func IsErrUnknownJob(err error) bool

IsErrUnknownJob returns whether the error is due to an unknown job.

func IsErrUnknownMethod

func IsErrUnknownMethod(err error) bool

IsErrUnknownMethod returns whether the error is due to the operation not being allowed due to lack of permissions.

func IsErrUnknownNode

func IsErrUnknownNode(err error) bool

IsErrUnknownNode returns whether the error is due to an unknown node.

func IsErrUnknownNomadVersion

func IsErrUnknownNomadVersion(err error) bool

IsErrUnknownNomadVersion returns whether the error is due to Nomad being unable to determine the version of a node.

func IsRecoverable

func IsRecoverable(e error) bool

IsRecoverable returns true if error is a RecoverableError with Recoverable=true. Otherwise false is returned.

func IsServerSide

func IsServerSide(e error) bool

IsServerSide returns true if error is a wrapped server side error

func IsUniqueNamespace

func IsUniqueNamespace(key string) bool

IsUniqueNamespace returns whether the key is under the unique namespace.

func MergeMultierrorWarnings

func MergeMultierrorWarnings(warnings ...error) string

MergeMultierrorWarnings takes job warnings and canonicalize warnings and merges them into a returnable string. Both the errors may be nil.

func NewErrUnknownAllocation

func NewErrUnknownAllocation(allocID string) error

NewErrUnknownAllocation returns a new error caused by the allocation being unknown.

func NewErrUnknownDeployment

func NewErrUnknownDeployment(deploymentID string) error

NewErrUnknownDeployment returns a new error caused by the deployment being unknown.

func NewErrUnknownEvaluation

func NewErrUnknownEvaluation(evaluationID string) error

NewErrUnknownEvaluation returns a new error caused by the evaluation being unknown.

func NewErrUnknownJob

func NewErrUnknownJob(jobID string) error

NewErrUnknownJob returns a new error caused by the job being unknown.

func NewErrUnknownNode

func NewErrUnknownNode(nodeID string) error

NewErrUnknownNode returns a new error caused by the node being unknown.

func NewRecoverableError

func NewRecoverableError(e error, recoverable bool) error

NewRecoverableError is used to wrap an error and mark it as recoverable or not.

func NewWrappedServerError

func NewWrappedServerError(e error) error

NewWrappedServerError is used to create a wrapped server side error

func ParsePortRanges

func ParsePortRanges(spec string) ([]uint64, error)

ParsePortRanges parses the passed port range string and returns a list of the ports. The specification is a comma separated list of either port numbers or port ranges. A port number is a single integer and a port range is two integers separated by a hyphen. As an example the following spec would convert to: ParsePortRanges("10,12-14,16") -> []uint64{10, 12, 13, 14, 16}

func PathEscapesAllocDir

func PathEscapesAllocDir(prefix, path string) (bool, error)

PathEscapesAllocDir returns if the given path escapes the allocation directory. The prefix allows adding a prefix if the path will be joined, for example a "task/local" prefix may be provided if the path will be joined against that prefix.

func ScoreFit

func ScoreFit(node *Node, util *ComparableResources) float64

ScoreFit is used to score the fit based on the Google work published here: http://www.columbia.edu/~cs2035/courses/ieor4405.S13/datacenter_scheduling.ppt This is equivalent to their BestFit v3

func ShouldDrainNode

func ShouldDrainNode(status string) bool

ShouldDrainNode checks if a given node status should trigger an evaluation. Some states don't require any further action.

func UniqueNamespace

func UniqueNamespace(key string) string

UniqueNamespace takes a key and returns the key marked under the unique namespace.

func ValidNodeStatus

func ValidNodeStatus(status string) bool

ValidNodeStatus is used to check if a node status is valid

func ValidateConnectProxyService

func ValidateConnectProxyService(serviceName string, tgServices []*Service) error

ValidateConnectProxyService checks that the service that is being proxied by this task exists in the task group and contains valid Connect config.

func VaultPoliciesSet

func VaultPoliciesSet(policies map[string]map[string]*Vault) []string

VaultPoliciesSet takes the structure returned by VaultPolicies and returns the set of required policies

func WrapRecoverable

func WrapRecoverable(msg string, err error) error

WrapRecoverable wraps an existing error in a new RecoverableError with a new message. If the error was recoverable before the returned error is as well; otherwise it is unrecoverable.

Types

type ACLPolicy

type ACLPolicy struct {
	Name        string // Unique name
	Description string // Human readable
	Rules       string // HCL or JSON format
	Hash        []byte
	CreateIndex uint64
	ModifyIndex uint64
}

ACLPolicy is used to represent an ACL policy

func (*ACLPolicy) CodecDecodeSelf

func (x *ACLPolicy) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicy) CodecEncodeSelf

func (x *ACLPolicy) CodecEncodeSelf(e *codec1978.Encoder)

func (*ACLPolicy) SetHash

func (c *ACLPolicy) SetHash() []byte

SetHash is used to compute and set the hash of the ACL policy

func (*ACLPolicy) Stub

func (a *ACLPolicy) Stub() *ACLPolicyListStub

func (*ACLPolicy) Validate

func (a *ACLPolicy) Validate() error

type ACLPolicyDeleteRequest

type ACLPolicyDeleteRequest struct {
	Names []string
	WriteRequest
}

ACLPolicyDeleteRequest is used to delete a set of policies

func (*ACLPolicyDeleteRequest) CodecDecodeSelf

func (x *ACLPolicyDeleteRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicyDeleteRequest) CodecEncodeSelf

func (x *ACLPolicyDeleteRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicyListRequest

type ACLPolicyListRequest struct {
	QueryOptions
}

ACLPolicyListRequest is used to request a list of policies

func (*ACLPolicyListRequest) CodecDecodeSelf

func (x *ACLPolicyListRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicyListRequest) CodecEncodeSelf

func (x *ACLPolicyListRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicyListResponse

type ACLPolicyListResponse struct {
	Policies []*ACLPolicyListStub
	QueryMeta
}

ACLPolicyListResponse is used for a list request

func (*ACLPolicyListResponse) CodecDecodeSelf

func (x *ACLPolicyListResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicyListResponse) CodecEncodeSelf

func (x *ACLPolicyListResponse) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicyListStub

type ACLPolicyListStub struct {
	Name        string
	Description string
	Hash        []byte
	CreateIndex uint64
	ModifyIndex uint64
}

ACLPolicyListStub is used to for listing ACL policies

func (*ACLPolicyListStub) CodecDecodeSelf

func (x *ACLPolicyListStub) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicyListStub) CodecEncodeSelf

func (x *ACLPolicyListStub) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicySetRequest

type ACLPolicySetRequest struct {
	Names []string
	QueryOptions
}

ACLPolicySetRequest is used to query a set of policies

func (*ACLPolicySetRequest) CodecDecodeSelf

func (x *ACLPolicySetRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicySetRequest) CodecEncodeSelf

func (x *ACLPolicySetRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicySetResponse

type ACLPolicySetResponse struct {
	Policies map[string]*ACLPolicy
	QueryMeta
}

ACLPolicySetResponse is used to return a set of policies

func (*ACLPolicySetResponse) CodecDecodeSelf

func (x *ACLPolicySetResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicySetResponse) CodecEncodeSelf

func (x *ACLPolicySetResponse) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicySpecificRequest

type ACLPolicySpecificRequest struct {
	Name string
	QueryOptions
}

ACLPolicySpecificRequest is used to query a specific policy

func (*ACLPolicySpecificRequest) CodecDecodeSelf

func (x *ACLPolicySpecificRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicySpecificRequest) CodecEncodeSelf

func (x *ACLPolicySpecificRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLPolicyUpsertRequest

type ACLPolicyUpsertRequest struct {
	Policies []*ACLPolicy
	WriteRequest
}

ACLPolicyUpsertRequest is used to upsert a set of policies

func (*ACLPolicyUpsertRequest) CodecDecodeSelf

func (x *ACLPolicyUpsertRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLPolicyUpsertRequest) CodecEncodeSelf

func (x *ACLPolicyUpsertRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLToken

type ACLToken struct {
	AccessorID  string   // Public Accessor ID (UUID)
	SecretID    string   // Secret ID, private (UUID)
	Name        string   // Human friendly name
	Type        string   // Client or Management
	Policies    []string // Policies this token ties to
	Global      bool     // Global or Region local
	Hash        []byte
	CreateTime  time.Time // Time of creation
	CreateIndex uint64
	ModifyIndex uint64
}

ACLToken represents a client token which is used to Authenticate

func (*ACLToken) CodecDecodeSelf

func (x *ACLToken) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLToken) CodecEncodeSelf

func (x *ACLToken) CodecEncodeSelf(e *codec1978.Encoder)

func (*ACLToken) PolicySubset

func (a *ACLToken) PolicySubset(policies []string) bool

PolicySubset checks if a given set of policies is a subset of the token

func (*ACLToken) SetHash

func (a *ACLToken) SetHash() []byte

SetHash is used to compute and set the hash of the ACL token

func (*ACLToken) Stub

func (a *ACLToken) Stub() *ACLTokenListStub

func (*ACLToken) Validate

func (a *ACLToken) Validate() error

Validate is used to sanity check a token

type ACLTokenBootstrapRequest

type ACLTokenBootstrapRequest struct {
	Token      *ACLToken // Not client specifiable
	ResetIndex uint64    // Reset index is used to clear the bootstrap token
	WriteRequest
}

ACLTokenBootstrapRequest is used to bootstrap ACLs

func (*ACLTokenBootstrapRequest) CodecDecodeSelf

func (x *ACLTokenBootstrapRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenBootstrapRequest) CodecEncodeSelf

func (x *ACLTokenBootstrapRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenDeleteRequest

type ACLTokenDeleteRequest struct {
	AccessorIDs []string
	WriteRequest
}

ACLTokenDeleteRequest is used to delete a set of tokens

func (*ACLTokenDeleteRequest) CodecDecodeSelf

func (x *ACLTokenDeleteRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenDeleteRequest) CodecEncodeSelf

func (x *ACLTokenDeleteRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenListRequest

type ACLTokenListRequest struct {
	GlobalOnly bool
	QueryOptions
}

ACLTokenListRequest is used to request a list of tokens

func (*ACLTokenListRequest) CodecDecodeSelf

func (x *ACLTokenListRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenListRequest) CodecEncodeSelf

func (x *ACLTokenListRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenListResponse

type ACLTokenListResponse struct {
	Tokens []*ACLTokenListStub
	QueryMeta
}

ACLTokenListResponse is used for a list request

func (*ACLTokenListResponse) CodecDecodeSelf

func (x *ACLTokenListResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenListResponse) CodecEncodeSelf

func (x *ACLTokenListResponse) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenListStub

type ACLTokenListStub struct {
	AccessorID  string
	Name        string
	Type        string
	Policies    []string
	Global      bool
	Hash        []byte
	CreateTime  time.Time
	CreateIndex uint64
	ModifyIndex uint64
}

func (*ACLTokenListStub) CodecDecodeSelf

func (x *ACLTokenListStub) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenListStub) CodecEncodeSelf

func (x *ACLTokenListStub) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenSetRequest

type ACLTokenSetRequest struct {
	AccessorIDS []string
	QueryOptions
}

ACLTokenSetRequest is used to query a set of tokens

func (*ACLTokenSetRequest) CodecDecodeSelf

func (x *ACLTokenSetRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenSetRequest) CodecEncodeSelf

func (x *ACLTokenSetRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenSetResponse

type ACLTokenSetResponse struct {
	Tokens map[string]*ACLToken // Keyed by Accessor ID
	QueryMeta
}

ACLTokenSetResponse is used to return a set of token

func (*ACLTokenSetResponse) CodecDecodeSelf

func (x *ACLTokenSetResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenSetResponse) CodecEncodeSelf

func (x *ACLTokenSetResponse) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenSpecificRequest

type ACLTokenSpecificRequest struct {
	AccessorID string
	QueryOptions
}

ACLTokenSpecificRequest is used to query a specific token

func (*ACLTokenSpecificRequest) CodecDecodeSelf

func (x *ACLTokenSpecificRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenSpecificRequest) CodecEncodeSelf

func (x *ACLTokenSpecificRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenUpsertRequest

type ACLTokenUpsertRequest struct {
	Tokens []*ACLToken
	WriteRequest
}

ACLTokenUpsertRequest is used to upsert a set of tokens

func (*ACLTokenUpsertRequest) CodecDecodeSelf

func (x *ACLTokenUpsertRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenUpsertRequest) CodecEncodeSelf

func (x *ACLTokenUpsertRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ACLTokenUpsertResponse

type ACLTokenUpsertResponse struct {
	Tokens []*ACLToken
	WriteMeta
}

ACLTokenUpsertResponse is used to return from an ACLTokenUpsertRequest

func (*ACLTokenUpsertResponse) CodecDecodeSelf

func (x *ACLTokenUpsertResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*ACLTokenUpsertResponse) CodecEncodeSelf

func (x *ACLTokenUpsertResponse) CodecEncodeSelf(e *codec1978.Encoder)

type Affinities

type Affinities []*Affinity

func (*Affinities) CodecDecodeSelf

func (x *Affinities) CodecDecodeSelf(d *codec1978.Decoder)

func (Affinities) CodecEncodeSelf

func (x Affinities) CodecEncodeSelf(e *codec1978.Encoder)

func (*Affinities) Equals

func (xs *Affinities) Equals(ys *Affinities) bool

Equals compares Affinities as a set

type Affinity

type Affinity struct {
	LTarget string // Left-hand target
	RTarget string // Right-hand target
	Operand string // Affinity operand (<=, <, =, !=, >, >=), set_contains_all, set_contains_any
	Weight  int8   // Weight applied to nodes that match the affinity. Can be negative
	// contains filtered or unexported fields

}

Affinity is used to score placement options based on a weight

func CopySliceAffinities

func CopySliceAffinities(s []*Affinity) []*Affinity

func (*Affinity) CodecDecodeSelf

func (x *Affinity) CodecDecodeSelf(d *codec1978.Decoder)

func (*Affinity) CodecEncodeSelf

func (x *Affinity) CodecEncodeSelf(e *codec1978.Encoder)

func (*Affinity) Copy

func (a *Affinity) Copy() *Affinity

func (*Affinity) Equal

func (a *Affinity) Equal(o *Affinity) bool

func (*Affinity) Equals

func (a *Affinity) Equals(o *Affinity) bool

Equal checks if two affinities are equal

func (*Affinity) String

func (a *Affinity) String() string

func (*Affinity) Validate

func (a *Affinity) Validate() error

type AllocDeploymentStatus

type AllocDeploymentStatus struct {
	// Healthy marks whether the allocation has been marked healthy or unhealthy
	// as part of a deployment. It can be unset if it has neither been marked
	// healthy or unhealthy.
	Healthy *bool

	// Timestamp is the time at which the health status was set.
	Timestamp time.Time

	// Canary marks whether the allocation is a canary or not. A canary that has
	// been promoted will have this field set to false.
	Canary bool

	// ModifyIndex is the raft index in which the deployment status was last
	// changed.
	ModifyIndex uint64
}

AllocDeploymentStatus captures the status of the allocation as part of the deployment. This can include things like if the allocation has been marked as healthy.

func (*AllocDeploymentStatus) CodecDecodeSelf

func (x *AllocDeploymentStatus) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocDeploymentStatus) CodecEncodeSelf

func (x *AllocDeploymentStatus) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocDeploymentStatus) Copy

func (*AllocDeploymentStatus) HasHealth

func (a *AllocDeploymentStatus) HasHealth() bool

HasHealth returns true if the allocation has its health set.

func (*AllocDeploymentStatus) IsCanary

func (a *AllocDeploymentStatus) IsCanary() bool

IsCanary returns if the allocation is marked as a canary

func (*AllocDeploymentStatus) IsHealthy

func (a *AllocDeploymentStatus) IsHealthy() bool

IsHealthy returns if the allocation is marked as healthy as part of a deployment

func (*AllocDeploymentStatus) IsUnhealthy

func (a *AllocDeploymentStatus) IsUnhealthy() bool

IsUnhealthy returns if the allocation is marked as unhealthy as part of a deployment

type AllocListRequest

type AllocListRequest struct {
	QueryOptions
}

AllocListRequest is used to request a list of allocations

func (*AllocListRequest) CodecDecodeSelf

func (x *AllocListRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocListRequest) CodecEncodeSelf

func (x *AllocListRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocListResponse

type AllocListResponse struct {
	Allocations []*AllocListStub
	QueryMeta
}

AllocListResponse is used for a list request

func (*AllocListResponse) CodecDecodeSelf

func (x *AllocListResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocListResponse) CodecEncodeSelf

func (x *AllocListResponse) CodecEncodeSelf(e *codec1978.Encoder)

type AllocListStub

type AllocListStub struct {
	ID                    string
	EvalID                string
	Name                  string
	Namespace             string
	NodeID                string
	NodeName              string
	JobID                 string
	JobType               string
	JobVersion            uint64
	TaskGroup             string
	DesiredStatus         string
	DesiredDescription    string
	ClientStatus          string
	ClientDescription     string
	DesiredTransition     DesiredTransition
	TaskStates            map[string]*TaskState
	DeploymentStatus      *AllocDeploymentStatus
	FollowupEvalID        string
	RescheduleTracker     *RescheduleTracker
	PreemptedAllocations  []string
	PreemptedByAllocation string
	CreateIndex           uint64
	ModifyIndex           uint64
	CreateTime            int64
	ModifyTime            int64
}

AllocListStub is used to return a subset of alloc information

func (*AllocListStub) CodecDecodeSelf

func (x *AllocListStub) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocListStub) CodecEncodeSelf

func (x *AllocListStub) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocListStub) SetEventDisplayMessages

func (a *AllocListStub) SetEventDisplayMessages()

SetEventDisplayMessage populates the display message if its not already set, a temporary fix to handle old allocations that don't have it. This method will be removed in a future release.

type AllocMetric

type AllocMetric struct {
	// NodesEvaluated is the number of nodes that were evaluated
	NodesEvaluated int

	// NodesFiltered is the number of nodes filtered due to a constraint
	NodesFiltered int

	// NodesAvailable is the number of nodes available for evaluation per DC.
	NodesAvailable map[string]int

	// ClassFiltered is the number of nodes filtered by class
	ClassFiltered map[string]int

	// ConstraintFiltered is the number of failures caused by constraint
	ConstraintFiltered map[string]int

	// NodesExhausted is the number of nodes skipped due to being
	// exhausted of at least one resource
	NodesExhausted int

	// ClassExhausted is the number of nodes exhausted by class
	ClassExhausted map[string]int

	// DimensionExhausted provides the count by dimension or reason
	DimensionExhausted map[string]int

	// QuotaExhausted provides the exhausted dimensions
	QuotaExhausted []string

	// Scores is the scores of the final few nodes remaining
	// for placement. The top score is typically selected.
	// Deprecated: Replaced by ScoreMetaData in Nomad 0.9
	Scores map[string]float64

	// ScoreMetaData is a slice of top scoring nodes displayed in the CLI
	ScoreMetaData []*NodeScoreMeta

	// AllocationTime is a measure of how long the allocation
	// attempt took. This can affect performance and SLAs.
	AllocationTime time.Duration

	// CoalescedFailures indicates the number of other
	// allocations that were coalesced into this failed allocation.
	// This is to prevent creating many failed allocations for a
	// single task group.
	CoalescedFailures int // contains filtered or unexported fields

}

AllocMetric is used to track various metrics while attempting to make an allocation. These are used to debug a job, or to better understand the pressure within the system.

func (*AllocMetric) CodecDecodeSelf

func (x *AllocMetric) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocMetric) CodecEncodeSelf

func (x *AllocMetric) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocMetric) Copy

func (a *AllocMetric) Copy() *AllocMetric

func (*AllocMetric) EvaluateNode

func (a *AllocMetric) EvaluateNode()

func (*AllocMetric) ExhaustQuota

func (a *AllocMetric) ExhaustQuota(dimensions []string)

func (*AllocMetric) ExhaustedNode

func (a *AllocMetric) ExhaustedNode(node *Node, dimension string)

func (*AllocMetric) FilterNode

func (a *AllocMetric) FilterNode(node *Node, constraint string)

func (*AllocMetric) PopulateScoreMetaData

func (a *AllocMetric) PopulateScoreMetaData()

PopulateScoreMetaData populates a map of scorer to scoring metadata The map is populated by popping elements from a heap of top K scores maintained per scorer

func (*AllocMetric) ScoreNode

func (a *AllocMetric) ScoreNode(node *Node, name string, score float64)

ScoreNode is used to gather top K scoring nodes in a heap

type AllocRestartRequest

type AllocRestartRequest struct {
	AllocID  string
	TaskName string

	QueryOptions
}

AllocRestartRequest is used to restart a specific allocations tasks.

func (*AllocRestartRequest) CodecDecodeSelf

func (x *AllocRestartRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocRestartRequest) CodecEncodeSelf

func (x *AllocRestartRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocSignalRequest

type AllocSignalRequest struct {
	AllocID string
	Task    string
	Signal  string
	QueryOptions
}

AllocSignalRequest is used to signal a specific allocation

func (*AllocSignalRequest) CodecDecodeSelf

func (x *AllocSignalRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocSignalRequest) CodecEncodeSelf

func (x *AllocSignalRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocSpecificRequest

type AllocSpecificRequest struct {
	AllocID string
	QueryOptions
}

AllocSpecificRequest is used to query a specific allocation

func (*AllocSpecificRequest) CodecDecodeSelf

func (x *AllocSpecificRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocSpecificRequest) CodecEncodeSelf

func (x *AllocSpecificRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocStopRequest

type AllocStopRequest struct {
	AllocID string

	WriteRequest
}

AllocStopRequest is used to stop and reschedule a running Allocation.

func (*AllocStopRequest) CodecDecodeSelf

func (x *AllocStopRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocStopRequest) CodecEncodeSelf

func (x *AllocStopRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocStopResponse

type AllocStopResponse struct {
	// EvalID is the id of the follow up evalution for the rescheduled alloc.
	EvalID string

	WriteMeta
}

AllocStopResponse is the response to an `AllocStopRequest`

func (*AllocStopResponse) CodecDecodeSelf

func (x *AllocStopResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocStopResponse) CodecEncodeSelf

func (x *AllocStopResponse) CodecEncodeSelf(e *codec1978.Encoder)

type AllocUpdateDesiredTransitionRequest

type AllocUpdateDesiredTransitionRequest struct {
	// Allocs is the mapping of allocation ids to their desired state
	// transition
	Allocs map[string]*DesiredTransition

	// Evals is the set of evaluations to create
	Evals []*Evaluation

	WriteRequest
}

AllocUpdateDesiredTransitionRequest is used to submit changes to allocations desired transition state.

func (*AllocUpdateDesiredTransitionRequest) CodecDecodeSelf

func (x *AllocUpdateDesiredTransitionRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocUpdateDesiredTransitionRequest) CodecEncodeSelf

func (x *AllocUpdateDesiredTransitionRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocUpdateRequest

type AllocUpdateRequest struct {
	// COMPAT 0.11
	// Alloc is the list of new allocations to assign
	// Deprecated: Replaced with two separate slices, one containing stopped allocations
	// and another containing updated allocations
	Alloc []*Allocation

	// Allocations to stop. Contains only the diff, not the entire allocation
	AllocsStopped []*AllocationDiff

	// New or updated allocations
	AllocsUpdated []*Allocation

	// Evals is the list of new evaluations to create
	// Evals are valid only when used in the Raft RPC
	Evals []*Evaluation

	// Job is the shared parent job of the allocations.
	// It is pulled out since it is common to reduce payload size.
	Job *Job

	WriteRequest
}

AllocUpdateRequest is used to submit changes to allocations, either to cause evictions or to assign new allocations. Both can be done within a single transaction

func (*AllocUpdateRequest) CodecDecodeSelf

func (x *AllocUpdateRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocUpdateRequest) CodecEncodeSelf

func (x *AllocUpdateRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocatedCpuResources

type AllocatedCpuResources struct {
	CpuShares int64
}

AllocatedCpuResources captures the allocated CPU resources.

func (*AllocatedCpuResources) Add

func (*AllocatedCpuResources) CodecDecodeSelf

func (x *AllocatedCpuResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedCpuResources) CodecEncodeSelf

func (x *AllocatedCpuResources) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocatedCpuResources) Subtract

func (a *AllocatedCpuResources) Subtract(delta *AllocatedCpuResources)

type AllocatedDeviceResource

type AllocatedDeviceResource struct {
	// Vendor, Type, and Name are used to select the plugin to request the
	// device IDs from.
	Vendor string
	Type   string
	Name   string

	// DeviceIDs is the set of allocated devices
	DeviceIDs []string
}

AllocatedDeviceResource captures a set of allocated devices.

func (*AllocatedDeviceResource) Add

func (*AllocatedDeviceResource) CodecDecodeSelf

func (x *AllocatedDeviceResource) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedDeviceResource) CodecEncodeSelf

func (x *AllocatedDeviceResource) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocatedDeviceResource) Copy

func (*AllocatedDeviceResource) ID

type AllocatedDevices

type AllocatedDevices []*AllocatedDeviceResource

func (*AllocatedDevices) CodecDecodeSelf

func (x *AllocatedDevices) CodecDecodeSelf(d *codec1978.Decoder)

func (AllocatedDevices) CodecEncodeSelf

func (x AllocatedDevices) CodecEncodeSelf(e *codec1978.Encoder)

func (AllocatedDevices) Index

Index finds the matching index using the passed device. If not found, -1 is returned.

type AllocatedMemoryResources

type AllocatedMemoryResources struct {
	MemoryMB int64
}

AllocatedMemoryResources captures the allocated memory resources.

func (*AllocatedMemoryResources) Add

func (*AllocatedMemoryResources) CodecDecodeSelf

func (x *AllocatedMemoryResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedMemoryResources) CodecEncodeSelf

func (x *AllocatedMemoryResources) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocatedMemoryResources) Subtract

type AllocatedResources

type AllocatedResources struct {
	// Tasks is a mapping of task name to the resources for the task.
	Tasks map[string]*AllocatedTaskResources

	// Shared is the set of resource that are shared by all tasks in the group.
	Shared AllocatedSharedResources
}

AllocatedResources is the set of resources to be used by an allocation.

func NodeResourcesToAllocatedResources

func NodeResourcesToAllocatedResources(n *NodeResources) *AllocatedResources

NodeResourcesToAllocatedResources converts a node resources to an allocated resources. The task name used is "web" and network is omitted. This is useful when trying to make an allocation fill an entire node.

func (*AllocatedResources) CodecDecodeSelf

func (x *AllocatedResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedResources) CodecEncodeSelf

func (x *AllocatedResources) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocatedResources) Comparable

func (a *AllocatedResources) Comparable() *ComparableResources

Comparable returns a comparable version of the allocations allocated resources. This conversion can be lossy so care must be taken when using it.

func (*AllocatedResources) Copy

func (*AllocatedResources) OldTaskResources

func (a *AllocatedResources) OldTaskResources() map[string]*Resources

OldTaskResources returns the pre-0.9.0 map of task resources

type AllocatedSharedResources

type AllocatedSharedResources struct {
	Networks Networks
	DiskMB   int64
}

AllocatedSharedResources are the set of resources allocated to a task group.

func (*AllocatedSharedResources) Add

func (*AllocatedSharedResources) CodecDecodeSelf

func (x *AllocatedSharedResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedSharedResources) CodecEncodeSelf

func (x *AllocatedSharedResources) CodecEncodeSelf(e *codec1978.Encoder)

func (AllocatedSharedResources) Copy

func (*AllocatedSharedResources) Subtract

type AllocatedTaskResources

type AllocatedTaskResources struct {
	Cpu      AllocatedCpuResources
	Memory   AllocatedMemoryResources
	Networks Networks
	Devices  []*AllocatedDeviceResource
}

AllocatedTaskResources are the set of resources allocated to a task.

func (*AllocatedTaskResources) Add

func (*AllocatedTaskResources) CodecDecodeSelf

func (x *AllocatedTaskResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocatedTaskResources) CodecEncodeSelf

func (x *AllocatedTaskResources) CodecEncodeSelf(e *codec1978.Encoder)

func (*AllocatedTaskResources) Comparable

Comparable turns AllocatedTaskResources into ComparableResources as a helper step in preemption

func (*AllocatedTaskResources) Copy

func (*AllocatedTaskResources) NetIndex

func (a *AllocatedTaskResources) NetIndex(n *NetworkResource) int

NetIndex finds the matching net index using device name

func (*AllocatedTaskResources) Subtract

func (a *AllocatedTaskResources) Subtract(delta *AllocatedTaskResources)

Subtract only subtracts CPU and Memory resources. Network utilization is managed separately in NetworkIndex

type Allocation

type Allocation struct {

	// ID of the allocation (UUID)
	ID string

	// Namespace is the namespace the allocation is created in
	Namespace string

	// ID of the evaluation that generated this allocation
	EvalID string

	// Name is a logical name of the allocation.
	Name string

	// NodeID is the node this is being placed on
	NodeID string

	// NodeName is the name of the node this is being placed on.
	NodeName string

	// Job is the parent job of the task group being allocated.
	// This is copied at allocation time to avoid issues if the job
	// definition is updated.
	JobID string
	Job   *Job

	// TaskGroup is the name of the task group that should be run
	TaskGroup string

	// COMPAT(0.11): Remove in 0.11
	// Resources is the total set of resources allocated as part
	// of this allocation of the task group. Dynamic ports will be set by
	// the scheduler.
	Resources *Resources

	// COMPAT(0.11): Remove in 0.11
	// SharedResources are the resources that are shared by all the tasks in an
	// allocation
	SharedResources *Resources

	// COMPAT(0.11): Remove in 0.11
	// TaskResources is the set of resources allocated to each
	// task. These should sum to the total Resources. Dynamic ports will be
	// set by the scheduler.
	TaskResources map[string]*Resources

	// AllocatedResources is the total resources allocated for the task group.
	AllocatedResources *AllocatedResources

	// Metrics associated with this allocation
	Metrics *AllocMetric

	// Desired Status of the allocation on the client
	DesiredStatus string

	// DesiredStatusDescription is meant to provide more human useful information
	DesiredDescription string

	// DesiredTransition is used to indicate that a state transition
	// is desired for a given reason.
	DesiredTransition DesiredTransition

	// Status of the allocation on the client
	ClientStatus string

	// ClientStatusDescription is meant to provide more human useful information
	ClientDescription string

	// TaskStates stores the state of each task,
	TaskStates map[string]*TaskState

	// PreviousAllocation is the allocation that this allocation is replacing
	PreviousAllocation string

	// NextAllocation is the allocation that this allocation is being replaced by
	NextAllocation string

	// DeploymentID identifies an allocation as being created from a
	// particular deployment
	DeploymentID string

	// DeploymentStatus captures the status of the allocation as part of the
	// given deployment
	DeploymentStatus *AllocDeploymentStatus

	// RescheduleTrackers captures details of previous reschedule attempts of the allocation
	RescheduleTracker *RescheduleTracker

	// FollowupEvalID captures a follow up evaluation created to handle a failed allocation
	// that can be rescheduled in the future
	FollowupEvalID string

	// PreemptedAllocations captures IDs of any allocations that were preempted
	// in order to place this allocation
	PreemptedAllocations []string

	// PreemptedByAllocation tracks the alloc ID of the allocation that caused this allocation
	// to stop running because it got preempted
	PreemptedByAllocation string

	// Raft Indexes
	CreateIndex uint64
	ModifyIndex uint64

	// AllocModifyIndex is not updated when the client updates allocations. This
	// lets the client pull only the allocs updated by the server.
	AllocModifyIndex uint64

	// CreateTime is the time the allocation has finished scheduling and been
	// verified by the plan applier.
	CreateTime int64

	// ModifyTime is the time the allocation was last updated.
	ModifyTime int64 // contains filtered or unexported fields

}

Allocation is used to allocate the placement of a task group to a node.

func FilterTerminalAllocs

func FilterTerminalAllocs(allocs []*Allocation) ([]*Allocation, map[string]*Allocation)

FilterTerminalAllocs filters out all allocations in a terminal state and returns the latest terminal allocations

func MockAlloc

func MockAlloc() *Allocation

func RemoveAllocs

func RemoveAllocs(alloc []*Allocation, remove []*Allocation) []*Allocation

RemoveAllocs is used to remove any allocs with the given IDs from the list of allocations

func (*Allocation) AllocationDiff

func (a *Allocation) AllocationDiff() *AllocationDiff

AllocationDiff converts an Allocation type to an AllocationDiff type If at any time, modification are made to AllocationDiff so that an Allocation can no longer be safely converted to AllocationDiff, this method should be changed accordingly.

func (*Allocation) ClientTerminalStatus

func (a *Allocation) ClientTerminalStatus() bool

ClientTerminalStatus returns if the client status is terminal and will no longer transition

func (*Allocation) CodecDecodeSelf

func (x *Allocation) CodecDecodeSelf(d *codec1978.Decoder)

func (*Allocation) CodecEncodeSelf

func (x *Allocation) CodecEncodeSelf(e *codec1978.Encoder)

func (*Allocation) ComparableResources

func (a *Allocation) ComparableResources() *ComparableResources

COMPAT(0.11): Remove in 0.11 ComparableResources returns the resources on the allocation handling upgrade paths. After 0.11 calls to this should be replaced with: alloc.AllocatedResources.Comparable()

func (*Allocation) Copy

func (a *Allocation) Copy() *Allocation

Copy provides a copy of the allocation and deep copies the job

func (*Allocation) CopySkipJob

func (a *Allocation) CopySkipJob() *Allocation

CopySkipJob provides a copy of the allocation but doesn't deep copy the job

func (*Allocation) Index

func (a *Allocation) Index() uint

Index returns the index of the allocation. If the allocation is from a task group with count greater than 1, there will be multiple allocations for it.

func (*Allocation) LastEventTime

func (a *Allocation) LastEventTime() time.Time

LastEventTime is the time of the last task event in the allocation. It is used to determine allocation failure time. If the FinishedAt field is not set, the alloc's modify time is used

func (*Allocation) LookupTask

func (a *Allocation) LookupTask(name string) *Task

LookupTask by name from the Allocation. Returns nil if the Job is not set, the TaskGroup does not exist, or the task name cannot be found.

func (*Allocation) NextDelay

func (a *Allocation) NextDelay() time.Duration

NextDelay returns a duration after which the allocation can be rescheduled. It is calculated according to the delay function and previous reschedule attempts.

func (*Allocation) NextRescheduleTime

func (a *Allocation) NextRescheduleTime() (time.Time, bool)

NextRescheduleTime returns a time on or after which the allocation is eligible to be rescheduled, and whether the next reschedule time is within policy's interval if the policy doesn't allow unlimited reschedules

func (*Allocation) RanSuccessfully

func (a *Allocation) RanSuccessfully() bool

RanSuccessfully returns whether the client has ran the allocation and all tasks finished successfully. Critically this function returns whether the allocation has ran to completion and not just that the alloc has converged to its desired state. That is to say that a batch allocation must have finished with exit code 0 on all task groups. This doesn't really have meaning on a non-batch allocation because a service and system allocation should not finish.

func (*Allocation) RescheduleEligible

func (a *Allocation) RescheduleEligible(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool

RescheduleEligible returns if the allocation is eligible to be rescheduled according to its ReschedulePolicy and the current state of its reschedule trackers

func (*Allocation) ReschedulePolicy

func (a *Allocation) ReschedulePolicy() *ReschedulePolicy

ReschedulePolicy returns the reschedule policy based on the task group

func (*Allocation) ServerTerminalStatus

func (a *Allocation) ServerTerminalStatus() bool

ServerTerminalStatus returns true if the desired state of the allocation is terminal

func (*Allocation) SetEventDisplayMessages

func (a *Allocation) SetEventDisplayMessages()

SetEventDisplayMessage populates the display message if its not already set, a temporary fix to handle old allocations that don't have it. This method will be removed in a future release.

func (*Allocation) ShouldMigrate

func (a *Allocation) ShouldMigrate() bool

ShouldMigrate returns if the allocation needs data migration

func (*Allocation) ShouldReschedule

func (a *Allocation) ShouldReschedule(reschedulePolicy *ReschedulePolicy, failTime time.Time) bool

ShouldReschedule returns if the allocation is eligible to be rescheduled according to its status and ReschedulePolicy given its failure time

func (*Allocation) Stub

func (a *Allocation) Stub() *AllocListStub

Stub returns a list stub for the allocation

func (*Allocation) TerminalStatus

func (a *Allocation) TerminalStatus() bool

TerminalStatus returns if the desired or actual status is terminal and will no longer transition.

func (*Allocation) Terminated

func (a *Allocation) Terminated() bool

Terminated returns if the allocation is in a terminal state on a client.

type AllocationDiff

type AllocationDiff Allocation

AllocationDiff is another named type for Allocation (to use the same fields), which is used to represent the delta for an Allocation. If you need a method defined on the al

func (*AllocationDiff) CodecDecodeSelf

func (x *AllocationDiff) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocationDiff) CodecEncodeSelf

func (x *AllocationDiff) CodecEncodeSelf(e *codec1978.Encoder)

type AllocsGetRequest

type AllocsGetRequest struct {
	AllocIDs []string
	QueryOptions
}

AllocsGetRequest is used to query a set of allocations

func (*AllocsGetRequest) CodecDecodeSelf

func (x *AllocsGetRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocsGetRequest) CodecEncodeSelf

func (x *AllocsGetRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AllocsGetResponse

type AllocsGetResponse struct {
	Allocs []*Allocation
	QueryMeta
}

AllocsGetResponse is used to return a set of allocations

func (*AllocsGetResponse) CodecDecodeSelf

func (x *AllocsGetResponse) CodecDecodeSelf(d *codec1978.Decoder)

func (*AllocsGetResponse) CodecEncodeSelf

func (x *AllocsGetResponse) CodecEncodeSelf(e *codec1978.Encoder)

type ApplyDeploymentAllocHealthRequest

type ApplyDeploymentAllocHealthRequest struct {
	DeploymentAllocHealthRequest

	// Timestamp is the timestamp to use when setting the allocations health.
	Timestamp time.Time

	// An optional field to update the status of a deployment
	DeploymentUpdate *DeploymentStatusUpdate

	// Job is used to optionally upsert a job. This is used when setting the
	// allocation health results in a deployment failure and the deployment
	// auto-reverts to the latest stable job.
	Job *Job

	// An optional evaluation to create after promoting the canaries
	Eval *Evaluation
}

ApplyDeploymentAllocHealthRequest is used to apply an alloc health request via Raft

func (*ApplyDeploymentAllocHealthRequest) CodecDecodeSelf

func (x *ApplyDeploymentAllocHealthRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ApplyDeploymentAllocHealthRequest) CodecEncodeSelf

func (x *ApplyDeploymentAllocHealthRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ApplyDeploymentPromoteRequest

type ApplyDeploymentPromoteRequest struct {
	DeploymentPromoteRequest

	// An optional evaluation to create after promoting the canaries
	Eval *Evaluation
}

ApplyDeploymentPromoteRequest is used to apply a promotion request via Raft

func (*ApplyDeploymentPromoteRequest) CodecDecodeSelf

func (x *ApplyDeploymentPromoteRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ApplyDeploymentPromoteRequest) CodecEncodeSelf

func (x *ApplyDeploymentPromoteRequest) CodecEncodeSelf(e *codec1978.Encoder)

type ApplyPlanResultsRequest

type ApplyPlanResultsRequest struct {
	// AllocUpdateRequest holds the allocation updates to be made by the
	// scheduler.
	AllocUpdateRequest

	// Deployment is the deployment created or updated as a result of a
	// scheduling event.
	Deployment *Deployment

	// DeploymentUpdates is a set of status updates to apply to the given
	// deployments. This allows the scheduler to cancel any unneeded deployment
	// because the job is stopped or the update block is removed.
	DeploymentUpdates []*DeploymentStatusUpdate

	// EvalID is the eval ID of the plan being applied. The modify index of the
	// evaluation is updated as part of applying the plan to ensure that subsequent
	// scheduling events for the same job will wait for the index that last produced
	// state changes. This is necessary for blocked evaluations since they can be
	// processed many times, potentially making state updates, without the state of
	// the evaluation itself being updated.
	EvalID string

	// COMPAT 0.11
	// NodePreemptions is a slice of allocations from other lower priority jobs
	// that are preempted. Preempted allocations are marked as evicted.
	// Deprecated: Replaced with AllocsPreempted which contains only the diff
	NodePreemptions []*Allocation

	// AllocsPreempted is a slice of allocation diffs from other lower priority jobs
	// that are preempted. Preempted allocations are marked as evicted.
	AllocsPreempted []*AllocationDiff

	// PreemptionEvals is a slice of follow up evals for jobs whose allocations
	// have been preempted to place allocs in this plan
	PreemptionEvals []*Evaluation
}

ApplyPlanResultsRequest is used by the planner to apply a Raft transaction committing the result of a plan.

func (*ApplyPlanResultsRequest) CodecDecodeSelf

func (x *ApplyPlanResultsRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*ApplyPlanResultsRequest) CodecEncodeSelf

func (x *ApplyPlanResultsRequest) CodecEncodeSelf(e *codec1978.Encoder)

type AutopilotConfig

type AutopilotConfig struct {
	// CleanupDeadServers controls whether to remove dead servers when a new
	// server is added to the Raft peers.
	CleanupDeadServers bool

	// ServerStabilizationTime is the minimum amount of time a server must be
	// in a stable, healthy state before it can be added to the cluster. Only
	// applicable with Raft protocol version 3 or higher.
	ServerStabilizationTime time.Duration

	// LastContactThreshold is the limit on the amount of time a server can go
	// without leader contact before being considered unhealthy.
	LastContactThreshold time.Duration

	// MaxTrailingLogs is the amount of entries in the Raft Log that a server can
	// be behind before being considered unhealthy.
	MaxTrailingLogs uint64

	// (Enterprise-only) EnableRedundancyZones specifies whether to enable redundancy zones.
	EnableRedundancyZones bool

	// (Enterprise-only) DisableUpgradeMigration will disable Autopilot's upgrade migration
	// strategy of waiting until enough newer-versioned servers have been added to the
	// cluster before promoting them to voters.
	DisableUpgradeMigration bool

	// (Enterprise-only) EnableCustomUpgrades specifies whether to enable using custom
	// upgrade versions when performing migrations.
	EnableCustomUpgrades bool

	// CreateIndex/ModifyIndex store the create/modify indexes of this configuration.
	CreateIndex uint64
	ModifyIndex uint64
}

AutopilotConfig is the internal config for the Autopilot mechanism.

func (*AutopilotConfig) CodecDecodeSelf

func (x *AutopilotConfig) CodecDecodeSelf(d *codec1978.Decoder)

func (*AutopilotConfig) CodecEncodeSelf

func (x *AutopilotConfig) CodecEncodeSelf(e *codec1978.Encoder)

type AutopilotSetConfigRequest

type AutopilotSetConfigRequest struct {
	// Datacenter is the target this request is intended for.
	Datacenter string

	// Config is the new Autopilot configuration to use.
	Config AutopilotConfig

	// CAS controls whether to use check-and-set semantics for this request.
	CAS bool

	// WriteRequest holds the ACL token to go along with this request.
	WriteRequest
}

AutopilotSetConfigRequest is used by the Operator endpoint to update the current Autopilot configuration of the cluster.

func (*AutopilotSetConfigRequest) CodecDecodeSelf

func (x *AutopilotSetConfigRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*AutopilotSetConfigRequest) CodecEncodeSelf

func (x *AutopilotSetConfigRequest) CodecEncodeSelf(e *codec1978.Encoder)

func (*AutopilotSetConfigRequest) RequestDatacenter

func (op *AutopilotSetConfigRequest) RequestDatacenter() string

RequestDatacenter returns the datacenter for a given request.

type BatchFuture

type BatchFuture struct {

	// contains filtered or unexported fields

}

BatchFuture is used to wait on a batch update to complete

func NewBatchFuture

func NewBatchFuture() *BatchFuture

NewBatchFuture creates a new batch future

func (*BatchFuture) CodecDecodeSelf

func (x *BatchFuture) CodecDecodeSelf(d *codec1978.Decoder)

func (*BatchFuture) CodecEncodeSelf

func (x *BatchFuture) CodecEncodeSelf(e *codec1978.Encoder)

func (*BatchFuture) Error

func (b *BatchFuture) Error() error

Error is used to return the error of the batch, only after Wait()

func (*BatchFuture) Index

func (b *BatchFuture) Index() uint64

Index is used to return the index of the batch, only after Wait()

func (*BatchFuture) Respond

func (b *BatchFuture) Respond(index uint64, err error)

Respond is used to unblock the future

func (*BatchFuture) Wait

func (b *BatchFuture) Wait() error

Wait is used to block for the future to complete and returns the error

func (*BatchFuture) WaitCh

func (b *BatchFuture) WaitCh() <-chan struct{}

WaitCh is used to block for the future to complete

type BatchNodeUpdateDrainRequest

type BatchNodeUpdateDrainRequest struct {
	// Updates is a mapping of nodes to their updated drain strategy
	Updates map[string]*DrainUpdate

	// NodeEvents is a mapping of the node to the event to add to the node
	NodeEvents map[string]*NodeEvent

	// UpdatedAt represents server time of receiving request
	UpdatedAt int64

	WriteRequest
}

BatchNodeUpdateDrainRequest is used for updating the drain strategy for a batch of nodes

func (*BatchNodeUpdateDrainRequest) CodecDecodeSelf

func (x *BatchNodeUpdateDrainRequest) CodecDecodeSelf(d *codec1978.Decoder)

func (*BatchNodeUpdateDrainRequest) CodecEncodeSelf

func (x *BatchNodeUpdateDrainRequest) CodecEncodeSelf(e *codec1978.Encoder)

type Bitmap

type Bitmap []byte

Bitmap is a simple uncompressed bitmap

func NewBitmap

func NewBitmap(size uint) (Bitmap, error)

NewBitmap returns a bitmap with up to size indexes

func (Bitmap) Check

func (b Bitmap) Check(idx uint) bool

Check is used to check the given index of the bitmap

func (Bitmap) Clear

func (b Bitmap) Clear()

Clear is used to efficiently clear the bitmap

func (*Bitmap) CodecDecodeSelf

func (x *Bitmap) CodecDecodeSelf(d *codec1978.Decoder)

func (Bitmap) CodecEncodeSelf

func (x Bitmap) CodecEncodeSelf(e *codec1978.Encoder)

func (Bitmap) Copy

func (b Bitmap) Copy() (Bitmap, error)

Copy returns a copy of the Bitmap

func (Bitmap) IndexesInRange

func (b Bitmap) IndexesInRange(set bool, from, to uint) []int

IndexesInRange returns the indexes in which the values are either set or unset based on the passed parameter in the passed range

func (Bitmap) Set

func (b Bitmap) Set(idx uint)

Set is used to set the given index of the bitmap

func (Bitmap) Size

func (b Bitmap) Size() uint

Size returns the size of the bitmap

func (Bitmap) Unset

func (b Bitmap) Unset(idx uint)

Unset is used to unset the given index of the bitmap

type CheckRestart

type CheckRestart struct {
	Limit          int           // Restart task after this many unhealthy intervals
	Grace          time.Duration // Grace time to give tasks after starting to get healthy
	IgnoreWarnings bool          // If true treat checks in `warning` as passing
}

CheckRestart describes if and when a task should be restarted based on failing health checks.

func (*CheckRestart) CodecDecodeSelf

func (x *CheckRestart) CodecDecodeSelf(d *codec1978.Decoder)

func (*CheckRestart) CodecEncodeSelf

func (x *CheckRestart) CodecEncodeSelf(e *codec1978.Encoder)

func (*CheckRestart) Copy

func (c *CheckRestart) Copy() *CheckRestart

func (*CheckRestart) Equals

func (c *CheckRestart) Equals(o *CheckRestart) bool

func (*CheckRestart) Validate

func (c *CheckRestart) Validate() error

type ClientHostVolumeConfig

type ClientHostVolumeConfig struct {
	Name     string `hcl:",key"`
	Path     string `hcl:"path"`
	ReadOnly bool   `hcl:"read_only"`
}

ClientHostVolumeConfig is used to configure access to host paths on a Nomad Client

func CopySliceClientHostVolumeConfig

func CopySliceClientHostVolumeConfig(s []*ClientHostVolumeConfig) []*ClientHostVolumeConfig

func HostVolumeSliceMerge

func HostVolumeSliceMerge(a, b []*ClientHostVolumeConfig) []*ClientHostVolumeConfig

func (*ClientHostVolumeConfig) CodecDecodeSelf

func (x *ClientHostVolumeConfig) CodecDecodeSelf(d *codec1978.Decoder)

func (*ClientHostVolumeConfig) CodecEncodeSelf

func (x *ClientHostVolumeConfig) CodecEncodeSelf(e *codec1978.Encoder)

func (*ClientHostVolumeConfig) Copy

type ComparableResources

type ComparableResources struct {
	Flattened AllocatedTaskResources
	Shared    AllocatedSharedResources
}

ComparableResources is the set of resources allocated to a task group but not keyed by Task, making it easier to compare.

func AllocsFit

func AllocsFit(node *Node, allocs []*Allocation, netIdx *NetworkIndex, checkDevices bool) (bool, string, *ComparableResources, error)

AllocsFit checks if a given set of allocations will fit on a node. The netIdx can optionally be provided if its already been computed. If the netIdx is provided, it is assumed that the client has already ensured there are no collisions. If checkDevices is set to true, we check if there is a device oversubscription.

func (*ComparableResources) Add

func (*ComparableResources) CodecDecodeSelf

func (x *ComparableResources) CodecDecodeSelf(d *codec1978.Decoder)

func (*ComparableResources) CodecEncodeSelf

func (x *ComparableResources) CodecEncodeSelf(e *codec1978.Encoder)

func (*ComparableResources) Copy

func (*ComparableResources) NetIndex

func (c *ComparableResources) NetIndex(n *NetworkResource) int

allocated finds the matching net index using device name

func (*ComparableResources) Subtract

func (c *ComparableResources) Subtract(delta *ComparableResources)

func (*ComparableResources) Superset

func (c *ComparableResources) Superset(other *ComparableResources) (bool, string)

Superset checks if one set of resources is a superset of another. This ignores network resources, and the NetworkIndex should be used for that.

type Constraint

type Constraint struct {
	LTarget string // Left-hand target
	RTarget string // Right-hand target
	Operand string // Constraint operand (<=, <, =, !=, >, >=), contains, near
	// contains filtered or unexported fields

}

Constraints are used to restrict placement options.

func CopySliceConstraints

func CopySliceConstraints(s []*Constraint) []*Constraint

func EscapedConstraints

func EscapedConstraints(constraints []*Constraint) []*Constraint

EscapedConstraints takes a set of constraints and returns the set that escapes computed node classes.

func (*Constraint) CodecDecodeSelf

func (x *Constraint) CodecDecodeSelf(d *codec1978.Decoder)

func (*Constraint) CodecEncodeSelf

func (x *Constraint) CodecEncodeSelf(e *codec1978.Encoder)

func (*Constraint) Copy

func (c *Constraint) Copy() *Constraint

func (*Constraint) Equal

func (c *Constraint) Equal(o *Constraint) bool

func (*Constraint) Equals

func (c *Constraint) Equals(o *Constraint) bool

Equal checks if two constraints are equal

func (*Constraint) String

func (c *Constraint) String() string

func (*Constraint) Validate

func (c *Constraint) Validate() error

type Constraints

type Constraints []*Constraint

func (*Constraints) CodecDecodeSelf

func (x *Constraints) CodecDecodeSelf(d *codec1978.Decoder)

func (Constraints) CodecEncodeSelf

func (x Constraints) CodecEncodeSelf(e *codec1978.Encoder)

func (*Constraints) Equals

func (xs *Constraints) Equals(ys *Constraints) bool

Equals compares Constraints as a set

type ConsulConnect

type ConsulConnect struct {
	// Native is true if a service implements Connect directly and does not
	// need a sidecar.
	Native bool

	// SidecarService is non-nil if a service requires a sidecar.
	SidecarService *ConsulSidecarService

	// SidecarTask is non-nil if sidecar overrides are set
	SidecarTask *SidecarTask
}

ConsulConnect represents a Consul Connect jobspec stanza.

func (*ConsulConnect) CodecDecodeSelf

func (x *ConsulConnect) CodecDecodeSelf(d *codec1978.Decoder)

func (*ConsulConnect) CodecEncodeSelf

func (x *ConsulConnect) CodecEncodeSelf(e *codec1978.Encoder)

func (*ConsulConnect) Copy

func (c *ConsulConnect) Copy() *ConsulConnect

Copy the stanza recursively. Returns nil if nil.

func (*ConsulConnect) Equals

func (c *ConsulConnect) Equals(o *ConsulConnect) bool

Equals returns true if the structs are recursively equal.

func (*ConsulConnect) HasSidecar

func (c *ConsulConnect) HasSidecar() bool

HasSidecar checks if a sidecar task is needed

func (*ConsulConnect) Validate

func (c *ConsulConnect) Validate() error

Validate that the Connect stanza has exactly one of Native or sidecar.

type ConsulProxy

type ConsulProxy struct {

	// LocalServiceAddress is the address the local service binds to.
	// Usually 127.0.0.1 it is useful to customize in clusters with mixed
	// Connect and non-Connect services.
	LocalServiceAddress string

	// LocalServicePort is the port the local service binds to. Usually
	// the same as the parent service's port, it is useful to customize
	// in clusters with mixed Connect and non-Connect services
	LocalServicePort int

	// Upstreams configures the upstream services this service intends to
	// connect to.
	Upstreams []ConsulUpstream

	// Config is a proxy configuration. It is opaque to Nomad and passed
	// directly to Consul.
	Config map[string]interface{}
}

ConsulProxy represents a Consul Connect sidecar proxy jobspec stanza.

func (*ConsulProxy) CodecDecodeSelf

func (x *ConsulProxy) CodecDecodeSelf(d *codec1978.Decoder)

func (*ConsulProxy) CodecEncodeSelf

func (x *ConsulProxy) CodecEncodeSelf(e *codec1978.Encoder)

func (*ConsulProxy) Copy

func (p *ConsulProxy) Copy() *ConsulProxy

Copy the stanza recursively. Returns nil if nil.

func (*ConsulProxy) Equals

func (p *ConsulProxy) Equals(o *ConsulProxy) bool

Equals returns true if the structs are recursively equal.

type ConsulSidecarService

type ConsulSidecarService struct {
	// Port is the service's port that the sidecar will connect to. May be
	// a port label or a literal port number.
	Port string

	// Proxy stanza defining the sidecar proxy configuration.
	Proxy *ConsulProxy
}

ConsulSidecarService represents a Consul Connect SidecarService jobspec stanza.

func (*ConsulSidecarService) CodecDecodeSelf

func (x *ConsulSidecarService) CodecDecodeSelf(d *codec1978.Decoder)

func (*ConsulSidecarService) CodecEncodeSelf

func (x *ConsulSidecarService) CodecEncodeSelf(e *codec1978.Encoder)

func (*ConsulSidecarService) Copy

Copy the stanza recursively. Returns nil if nil.

func (*ConsulSidecarService) Equals

Equals returns true if the structs are recursively equal.

func (*ConsulSidecarService) HasUpstreams

func (s *ConsulSidecarService) HasUpstreams() bool

HasUpstreams checks if the sidecar service has any upstreams configured

type ConsulUpstream

type ConsulUpstream struct {
	// DestinationName is the name of the upstream service.
	DestinationName string

	// LocalBindPort is the port the proxy will receive connections for the
	// upstream on.
	LocalBindPort int
}

ConsulUpstream represents a Consul Connect upstream jobspec stanza.

func (*ConsulUpstream) CodecDecodeSelf

func (x *ConsulUpstream) CodecDecodeSelf(d *codec1978.Decoder)

func (*ConsulUpstream) CodecEncodeSelf

func (x *ConsulUpstream) CodecEncodeSelf(e *codec1978.Encoder)

func (*ConsulUpstream) Copy

func (u *ConsulUpstream) Copy() *ConsulUpstream

Copy the stanza recursively. Returns nil if nil.

func (*ConsulUpstream) Equals

func (u *ConsulUpstream) Equals(o *ConsulUpstream) bool

Equals returns true if the structs are recursively equal.

type Context

type Context string

Context defines the scope in which a search for Nomad object operates, and is also used to query the matching index value for this context

const (
	Allocs      Context = "allocs"
	Deployments Context = "deployment"
	Evals       Context = "evals"
	Jobs        Context = "jobs"
	Nodes       Context = "nodes"
	Namespaces  Context = "namespaces"
	Quotas      Context = "quotas"
	All         Context = "all"
)

func (*Context) CodecDecodeSelf

func (x *Context) CodecDecodeSelf(d *codec1978.Decoder)

func (Context) CodecEncodeSelf

func (x Context) CodecEncodeSelf(e *codec1978.Encoder)

type Deployment

type Deployment struct {
	// ID is a generated UUID for the deployment
	ID string

	// Namespace is the namespace the deployment is created in
	Namespace string

	// JobID is the job the deployment is created for
	JobID string

	// JobVersion is the version of the job at which the deployment is tracking
	JobVersion uint64

	// JobModifyIndex is the ModifyIndex of the job which the deployment is
	// tracking.
	JobModifyIndex uint64

	// JobSpecModifyIndex is the JobModifyIndex of the job which the
	// deployment is tracking.