api

package
v0.9.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

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 (
	// OriginStart and OriginEnd are the available parameters for the origin
	// argument when streaming a file. They respectively offset from the start
	// and end of a file.
	OriginStart = "start"
	OriginEnd   = "end"
)
View Source
const (
	// JobTypeService indicates a long-running processes
	JobTypeService = "service"

	// JobTypeBatch indicates a short-lived process
	JobTypeBatch = "batch"

	// JobTypeSystem indicates a system process that should run on all clients
	JobTypeSystem = "system"

	// PeriodicSpecCron is used for a cron spec.
	PeriodicSpecCron = "cron"

	// DefaultNamespace is the default namespace.
	DefaultNamespace = "default"
)
View Source
const (
	NodeStatusInit  = "initializing"
	NodeStatusReady = "ready"
	NodeStatusDown  = "down"

	// 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 (
	NodeEventSubsystemDrain     = "Drain"
	NodeEventSubsystemDriver    = "Driver"
	NodeEventSubsystemHeartbeat = "Heartbeat"
	NodeEventSubsystemCluster   = "Cluster"
)
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"
)
View Source
const (
	TaskSetup                  = "Task Setup"
	TaskSetupFailure           = "Setup Failure"
	TaskDriverFailure          = "Driver Failure"
	TaskDriverMessage          = "Driver"
	TaskReceived               = "Received"
	TaskFailedValidation       = "Failed Validation"
	TaskStarted                = "Started"
	TaskTerminated             = "Terminated"
	TaskKilling                = "Killing"
	TaskKilled                 = "Killed"
	TaskRestarting             = "Restarting"
	TaskNotRestarting          = "Not Restarting"
	TaskDownloadingArtifacts   = "Downloading Artifacts"
	TaskArtifactDownloadFailed = "Failed Artifact Download"
	TaskSiblingFailed          = "Sibling Task Failed"
	TaskSignaling              = "Signaling"
	TaskRestartSignal          = "Restart Signaled"
	TaskLeaderDead             = "Leader Task Dead"
	TaskBuildingTaskDir        = "Building Task Directory"
)
View Source
const (
	// RegisterEnforceIndexErrPrefix is the prefix to use in errors caused by
	// enforcing the job modify index during registers.
	RegisterEnforceIndexErrPrefix = "Enforcing job modify index"
)

Variables

View Source
var (
	// ClientConnTimeout is the timeout applied when attempting to contact a
	// client directly before switching to a connection through the Nomad
	// server.
	ClientConnTimeout = 1 * time.Second
)
View Source
var (
	// NodeDownErr marks an operation as not able to complete since the node is
	// down.
	NodeDownErr = fmt.Errorf("node down")
)

Functions

This section is empty.

Types

type ACLPolicies added in v0.7.0

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

ACLPolicies is used to query the ACL Policy endpoints.

func (*ACLPolicies) Delete added in v0.7.0

func (a *ACLPolicies) Delete(policyName string, q *WriteOptions) (*WriteMeta, error)

Delete is used to delete a policy

func (*ACLPolicies) Info added in v0.7.0

func (a *ACLPolicies) Info(policyName string, q *QueryOptions) (*ACLPolicy, *QueryMeta, error)

Info is used to query a specific policy

func (*ACLPolicies) List added in v0.7.0

List is used to dump all of the policies.

func (*ACLPolicies) Upsert added in v0.7.0

func (a *ACLPolicies) Upsert(policy *ACLPolicy, q *WriteOptions) (*WriteMeta, error)

Upsert is used to create or update a policy

type ACLPolicy added in v0.7.0

type ACLPolicy struct {
	Name        string
	Description string
	Rules       string
	CreateIndex uint64
	ModifyIndex uint64
}

ACLPolicy is used to represent an ACL policy

type ACLPolicyListStub added in v0.7.0

type ACLPolicyListStub struct {
	Name        string
	Description string
	CreateIndex uint64
	ModifyIndex uint64
}

ACLPolicyListStub is used to for listing ACL policies

type ACLToken added in v0.7.0

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

ACLToken represents a client token which is used to Authenticate

type ACLTokenListStub added in v0.7.0

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

type ACLTokens added in v0.7.0

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

ACLTokens is used to query the ACL token endpoints.

func (*ACLTokens) Bootstrap added in v0.7.0

func (a *ACLTokens) Bootstrap(q *WriteOptions) (*ACLToken, *WriteMeta, error)

Bootstrap is used to get the initial bootstrap token

func (*ACLTokens) Create added in v0.7.0

func (a *ACLTokens) Create(token *ACLToken, q *WriteOptions) (*ACLToken, *WriteMeta, error)

Create is used to create a token

func (*ACLTokens) Delete added in v0.7.0

func (a *ACLTokens) Delete(accessorID string, q *WriteOptions) (*WriteMeta, error)

Delete is used to delete a token

func (*ACLTokens) Info added in v0.7.0

func (a *ACLTokens) Info(accessorID string, q *QueryOptions) (*ACLToken, *QueryMeta, error)

Info is used to query a token

func (*ACLTokens) List added in v0.7.0

List is used to dump all of the tokens.

func (*ACLTokens) Self added in v0.7.0

func (a *ACLTokens) Self(q *QueryOptions) (*ACLToken, *QueryMeta, error)

Self is used to query our own token

func (*ACLTokens) Update added in v0.7.0

func (a *ACLTokens) Update(token *ACLToken, q *WriteOptions) (*ACLToken, *WriteMeta, error)

Update is used to update an existing token

type Affinity

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

Affinity is used to serialize task group affinities

func NewAffinity

func NewAffinity(LTarget string, Operand string, RTarget string, Weight int8) *Affinity

func (*Affinity) Canonicalize

func (a *Affinity) Canonicalize()

type Agent

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

Agent encapsulates an API client which talks to Nomad's agent endpoints for a specific node.

func (*Agent) Datacenter

func (a *Agent) Datacenter() (string, error)

Datacenter is used to return the name of the datacenter which the agent is a member of.

func (*Agent) ForceLeave

func (a *Agent) ForceLeave(node string) error

ForceLeave is used to eject an existing node from the cluster.

func (*Agent) Health added in v0.7.0

func (a *Agent) Health() (*AgentHealthResponse, error)

Health queries the agent's health

func (*Agent) InstallKey added in v0.5.0

func (a *Agent) InstallKey(key string) (*KeyringResponse, error)

InstallKey installs a key in the keyrings of all the serf members

func (*Agent) Join

func (a *Agent) Join(addrs ...string) (int, error)

Join is used to instruct a server node to join another server via the gossip protocol. Multiple addresses may be specified. We attempt to join all of the hosts in the list. Returns the number of nodes successfully joined and any error. If one or more nodes have a successful result, no error is returned.

func (*Agent) ListKeys added in v0.5.0

func (a *Agent) ListKeys() (*KeyringResponse, error)

ListKeys returns the list of installed keys

func (*Agent) Members

func (a *Agent) Members() (*ServerMembers, error)

Members is used to query all of the known server members

func (*Agent) NodeName

func (a *Agent) NodeName() (string, error)

NodeName is used to query the Nomad agent for its node name.

func (*Agent) Region

func (a *Agent) Region() (string, error)

Region is used to look up the region the agent is in.

func (*Agent) RemoveKey added in v0.5.0

func (a *Agent) RemoveKey(key string) (*KeyringResponse, error)

RemoveKey removes a particular key from keyrings of serf members

func (*Agent) Self

func (a *Agent) Self() (*AgentSelf, error)

Self is used to query the /v1/agent/self endpoint and returns information specific to the running agent.

func (*Agent) Servers

func (a *Agent) Servers() ([]string, error)

Servers is used to query the list of servers on a client node.

func (*Agent) SetServers

func (a *Agent) SetServers(addrs []string) error

SetServers is used to update the list of servers on a client node.

func (*Agent) UseKey added in v0.5.0

func (a *Agent) UseKey(key string) (*KeyringResponse, error)

UseKey uses a key from the keyring of serf members

type AgentHealth added in v0.7.0

type AgentHealth struct {
	// Ok is false if the agent is unhealthy
	Ok bool `json:"ok"`

	// Message describes why the agent is unhealthy
	Message string `json:"message"`
}

AgentHealth describes the Client or Server's health in a Health request.

type AgentHealthResponse added in v0.7.0

type AgentHealthResponse struct {
	Client *AgentHealth `json:"client,omitempty"`
	Server *AgentHealth `json:"server,omitempty"`
}

AgentHealthResponse is the response from the Health endpoint describing an agent's health.

type AgentMember

type AgentMember struct {
	Name        string
	Addr        string
	Port        uint16
	Tags        map[string]string
	Status      string
	ProtocolMin uint8
	ProtocolMax uint8
	ProtocolCur uint8
	DelegateMin uint8
	DelegateMax uint8
	DelegateCur uint8
}

AgentMember represents a cluster member known to the agent

type AgentMembersNameSort added in v0.2.0

type AgentMembersNameSort []*AgentMember

AgentMembersNameSort implements sort.Interface for []*AgentMembersNameSort based on the Name, DC and Region

func (AgentMembersNameSort) Len added in v0.2.0

func (a AgentMembersNameSort) Len() int

func (AgentMembersNameSort) Less added in v0.2.0

func (a AgentMembersNameSort) Less(i, j int) bool

func (AgentMembersNameSort) Swap added in v0.2.0

func (a AgentMembersNameSort) Swap(i, j int)

type AgentSelf added in v0.5.5

type AgentSelf struct {
	Config map[string]interface{}       `json:"config"`
	Member AgentMember                  `json:"member"`
	Stats  map[string]map[string]string `json:"stats"`
}

type AllocDeploymentStatus added in v0.6.0

type AllocDeploymentStatus struct {
	Healthy     *bool
	Timestamp   time.Time
	Canary      bool
	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.

type AllocFS added in v0.3.0

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

AllocFS is used to introspect an allocation directory on a Nomad client

func (*AllocFS) Cat added in v0.3.2

func (a *AllocFS) Cat(alloc *Allocation, path string, q *QueryOptions) (io.ReadCloser, error)

Cat is used to read contents of a file at the given path in an allocation directory

func (*AllocFS) List added in v0.3.0

func (a *AllocFS) List(alloc *Allocation, path string, q *QueryOptions) ([]*AllocFileInfo, *QueryMeta, error)

List is used to list the files at a given path of an allocation directory

func (*AllocFS) Logs added in v0.4.1

func (a *AllocFS) Logs(alloc *Allocation, follow bool, task, logType, origin string,
	offset int64, cancel <-chan struct{}, q *QueryOptions) (<-chan *StreamFrame, <-chan error)

Logs streams the content of a tasks logs blocking on EOF. The parameters are: * allocation: the allocation to stream from. * follow: Whether the logs should be followed. * task: the tasks name to stream logs for. * logType: Either "stdout" or "stderr" * origin: Either "start" or "end" and defines from where the offset is applied. * offset: The offset to start streaming data at. * cancel: A channel that when closed, streaming will end.

The return value is a channel that will emit StreamFrames as they are read. The chan will be closed when follow=false and the end of the file is reached.

Unexpected (non-EOF) errors will be sent on the error chan.

func (*AllocFS) ReadAt added in v0.3.0

func (a *AllocFS) ReadAt(alloc *Allocation, path string, offset int64, limit int64, q *QueryOptions) (io.ReadCloser, error)

ReadAt is used to read bytes at a given offset until limit at the given path in an allocation directory. If limit is <= 0, there is no limit.

func (*AllocFS) Stat added in v0.3.0

func (a *AllocFS) Stat(alloc *Allocation, path string, q *QueryOptions) (*AllocFileInfo, *QueryMeta, error)

Stat is used to stat a file at a given path of an allocation directory

func (*AllocFS) Stream added in v0.4.1

func (a *AllocFS) Stream(alloc *Allocation, path, origin string, offset int64,
	cancel <-chan struct{}, q *QueryOptions) (<-chan *StreamFrame, <-chan error)

Stream streams the content of a file blocking on EOF. The parameters are: * path: path to file to stream. * offset: The offset to start streaming data at. * origin: Either "start" or "end" and defines from where the offset is applied. * cancel: A channel that when closed, streaming will end.

The return value is a channel that will emit StreamFrames as they are read.

type AllocFileInfo added in v0.3.0

type AllocFileInfo struct {
	Name     string
	IsDir    bool
	Size     int64
	FileMode string
	ModTime  time.Time
}

AllocFileInfo holds information about a file inside the AllocDir

type AllocIndexSort

type AllocIndexSort []*AllocationListStub

AllocIndexSort reverse sorts allocs by CreateIndex.

func (AllocIndexSort) Len

func (a AllocIndexSort) Len() int

func (AllocIndexSort) Less

func (a AllocIndexSort) Less(i, j int) bool

func (AllocIndexSort) Swap

func (a AllocIndexSort) Swap(i, j int)

type AllocResourceUsage added in v0.4.0

type AllocResourceUsage struct {
	ResourceUsage *ResourceUsage
	Tasks         map[string]*TaskResourceUsage
	Timestamp     int64
}

AllocResourceUsage holds the aggregated task resource usage of the allocation.

type AllocatedCpuResources

type AllocatedCpuResources struct {
	CpuShares int64
}

type AllocatedMemoryResources

type AllocatedMemoryResources struct {
	MemoryMB int64
}

type AllocatedResources

type AllocatedResources struct {
	Tasks  map[string]*AllocatedTaskResources
	Shared AllocatedSharedResources
}

type AllocatedSharedResources

type AllocatedSharedResources struct {
	DiskMB int64
}

type AllocatedTaskResources

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

type Allocation

type Allocation struct {
	ID                    string
	Namespace             string
	EvalID                string
	Name                  string
	NodeID                string
	JobID                 string
	Job                   *Job
	TaskGroup             string
	Resources             *Resources
	TaskResources         map[string]*Resources
	AllocatedResources    *AllocatedResources
	Services              map[string]string
	Metrics               *AllocationMetric
	DesiredStatus         string
	DesiredDescription    string
	DesiredTransition     DesiredTransition
	ClientStatus          string
	ClientDescription     string
	TaskStates            map[string]*TaskState
	DeploymentID          string
	DeploymentStatus      *AllocDeploymentStatus
	FollowupEvalID        string
	PreviousAllocation    string
	NextAllocation        string
	RescheduleTracker     *RescheduleTracker
	PreemptedAllocations  []string
	PreemptedByAllocation string
	CreateIndex           uint64
	ModifyIndex           uint64
	AllocModifyIndex      uint64
	CreateTime            int64
	ModifyTime            int64
}

Allocation is used for serialization of allocations.

func (Allocation) RescheduleInfo added in v0.8.0

func (a Allocation) RescheduleInfo(t time.Time) (int, int)

RescheduleInfo is used to calculate remaining reschedule attempts according to the given time and the task groups reschedule policy

type AllocationListStub

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

AllocationListStub is used to return a subset of an allocation during list operations.

type AllocationMetric

type AllocationMetric struct {
	NodesEvaluated     int
	NodesFiltered      int
	NodesAvailable     map[string]int
	ClassFiltered      map[string]int
	ConstraintFiltered map[string]int
	NodesExhausted     int
	ClassExhausted     map[string]int
	DimensionExhausted map[string]int
	QuotaExhausted     []string
	// Deprecated, replaced with ScoreMetaData
	Scores            map[string]float64
	AllocationTime    time.Duration
	CoalescedFailures int
	ScoreMetaData     []*NodeScoreMeta
}

AllocationMetric is used to deserialize allocation metrics.

type AllocationSort added in v0.2.0

type AllocationSort []*Allocation

AllocationSort reverse sorts allocs by CreateIndex.

func (AllocationSort) Len added in v0.2.0

func (a AllocationSort) Len() int

func (AllocationSort) Less added in v0.2.0

func (a AllocationSort) Less(i, j int) bool

func (AllocationSort) Swap added in v0.2.0

func (a AllocationSort) Swap(i, j int)

type Allocations

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

Allocations is used to query the alloc-related endpoints.

func (*Allocations) GC added in v0.5.3

func (a *Allocations) GC(alloc *Allocation, q *QueryOptions) error

func (*Allocations) Info

func (a *Allocations) Info(allocID string, q *QueryOptions) (*Allocation, *QueryMeta, error)

Info is used to retrieve a single allocation.

func (*Allocations) List

List returns a list of all of the allocations.

func (*Allocations) PrefixList added in v0.3.0

func (a *Allocations) PrefixList(prefix string) ([]*AllocationListStub, *QueryMeta, error)

func (*Allocations) Stats added in v0.4.0

func (a *Allocations) Stats(alloc *Allocation, q *QueryOptions) (*AllocResourceUsage, error)

type Attribute

type Attribute struct {
	// Float is the float value for the attribute
	FloatVal *float64 `json:"Float,omitempty"`

	// Int is the int value for the attribute
	IntVal *int64 `json:"Int,omitempty"`

	// String is the string value for the attribute
	StringVal *string `json:"String,omitempty"`

	// Bool is the bool value for the attribute
	BoolVal *bool `json:"Bool,omitempty"`

	// Unit is the optional unit for the set int or float value
	Unit string
}

Attribute is used to describe the value of an attribute, optionally specifying units

func (Attribute) String

func (a Attribute) String() string

type AutopilotConfiguration added in v0.8.0

type AutopilotConfiguration struct {
	// CleanupDeadServers controls whether to remove dead servers from the Raft
	// peer list when a new server joins
	CleanupDeadServers bool

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

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

	// (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 holds the index corresponding the creation of this configuration.
	// This is a read-only field.
	CreateIndex uint64

	// ModifyIndex will be set to the index of the last update when retrieving the
	// Autopilot configuration. Resubmitting a configuration with
	// AutopilotCASConfiguration will perform a check-and-set operation which ensures
	// there hasn't been a subsequent update since the configuration was retrieved.
	ModifyIndex uint64
}

AutopilotConfiguration is used for querying/setting the Autopilot configuration. Autopilot helps manage operator tasks related to Nomad servers like removing failed servers from the Raft quorum.

func (*AutopilotConfiguration) MarshalJSON added in v0.8.0

func (u *AutopilotConfiguration) MarshalJSON() ([]byte, error)

func (*AutopilotConfiguration) UnmarshalJSON added in v0.8.0

func (u *AutopilotConfiguration) UnmarshalJSON(data []byte) error

type CheckRestart added in v0.7.0

type CheckRestart struct {
	Limit          int            `mapstructure:"limit"`
	Grace          *time.Duration `mapstructure:"grace"`
	IgnoreWarnings bool           `mapstructure:"ignore_warnings"`
}

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

func (*CheckRestart) Canonicalize added in v0.7.0

func (c *CheckRestart) Canonicalize()

Canonicalize CheckRestart fields if not nil.

func (*CheckRestart) Copy added in v0.7.0

func (c *CheckRestart) Copy() *CheckRestart

Copy returns a copy of CheckRestart or nil if unset.

func (*CheckRestart) Merge added in v0.7.0

func (c *CheckRestart) Merge(o *CheckRestart) *CheckRestart

Merge values from other CheckRestart over default values on this CheckRestart and return merged copy.

type Client

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

Client provides a client to the Nomad API

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient returns a new client

func (*Client) ACLPolicies added in v0.7.0

func (c *Client) ACLPolicies() *ACLPolicies

ACLPolicies returns a new handle on the ACL policies.

func (*Client) ACLTokens added in v0.7.0

func (c *Client) ACLTokens() *ACLTokens

ACLTokens returns a new handle on the ACL tokens.

func (*Client) Address added in v0.7.0

func (c *Client) Address() string

Address return the address of the Nomad agent

func (*Client) Agent

func (c *Client) Agent() *Agent

Agent returns a new agent which can be used to query the agent-specific endpoints.

func (*Client) AllocFS added in v0.3.0

func (c *Client) AllocFS() *AllocFS

AllocFS returns an handle to the AllocFS endpoints

func (*Client) Allocations

func (c *Client) Allocations() *Allocations

Allocations returns a handle on the allocs endpoints.

func (*Client) Deployments added in v0.6.0

func (c *Client) Deployments() *Deployments

Deployments returns a new handle on the deployments.

func (*Client) Evaluations

func (c *Client) Evaluations() *Evaluations

Evaluations returns a new handle on the evaluations.

func (*Client) GetNodeClient added in v0.6.1

func (c *Client) GetNodeClient(nodeID string, q *QueryOptions) (*Client, error)

GetNodeClient returns a new Client that will dial the specified node. If the QueryOptions is set, its region will be used.

func (*Client) GetNodeClientWithTimeout added in v0.8.0

func (c *Client) GetNodeClientWithTimeout(
	nodeID string, timeout time.Duration, q *QueryOptions) (*Client, error)

GetNodeClientWithTimeout returns a new Client that will dial the specified node using the specified timeout. If the QueryOptions is set, its region will be used.

func (*Client) Jobs

func (c *Client) Jobs() *Jobs

Jobs returns a handle on the jobs endpoints.

func (*Client) Namespaces added in v0.7.0

func (c *Client) Namespaces() *Namespaces

Namespaces returns a new handle on the namespaces.

func (*Client) Nodes

func (c *Client) Nodes() *Nodes

Nodes returns a handle on the node endpoints.

func (*Client) Operator added in v0.5.5

func (c *Client) Operator() *Operator

Operator returns a handle to the operator endpoints.

func (*Client) Quotas added in v0.7.0

func (c *Client) Quotas() *Quotas

Quotas returns a new handle on the quotas.

func (*Client) Raw

func (c *Client) Raw() *Raw

Raw returns a handle to query endpoints

func (*Client) Regions added in v0.2.1

func (c *Client) Regions() *Regions

Regions returns a handle on the regions endpoints.

func (*Client) Search added in v0.6.1

func (c *Client) Search() *Search

Search returns a handle on the Search endpoints

func (*Client) SentinelPolicies added in v0.7.0

func (c *Client) SentinelPolicies() *SentinelPolicies

SentinelPolicies returns a new handle on the Sentinel policies.

func (*Client) SetNamespace added in v0.7.0

func (c *Client) SetNamespace(namespace string)

SetNamespace sets the namespace to forward API requests to.

func (*Client) SetRegion added in v0.4.0

func (c *Client) SetRegion(region string)

SetRegion sets the region to forward API requests to.

func (*Client) SetSecretID added in v0.7.0

func (c *Client) SetSecretID(secretID string)

SetSecretID sets the ACL token secret for API requests.

func (*Client) Status

func (c *Client) Status() *Status

Status returns a handle on the status endpoints.

func (*Client) System added in v0.3.0

func (c *Client) System() *System

System returns a handle on the system endpoints.

type Config

type Config struct {
	// Address is the address of the Nomad agent
	Address string

	// Region to use. If not provided, the default agent region is used.
	Region string

	// SecretID to use. This can be overwritten per request.
	SecretID string

	// Namespace to use. If not provided the default namespace is used.
	Namespace string

	// HttpAuth is the auth info to use for http access.
	HttpAuth *HttpBasicAuth

	// WaitTime limits how long a Watch will block. If not provided,
	// the agent default values will be used.
	WaitTime time.Duration

	// TLSConfig provides the various TLS related configurations for the http
	// client
	TLSConfig *TLSConfig
	// contains filtered or unexported fields
}

Config is used to configure the creation of a client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration for the client

func (*Config) ClientConfig added in v0.6.1

func (c *Config) ClientConfig(region, address string, tlsEnabled bool) *Config

ClientConfig copies the configuration with a new client address, region, and whether the client has TLS enabled.

func (*Config) ConfigureTLS added in v0.5.0

func (c *Config) ConfigureTLS() error

ConfigureTLS applies a set of TLS configurations to the the HTTP client.

func (*Config) SetTimeout added in v0.8.0

func (c *Config) SetTimeout(t time.Duration) error

SetTimeout is used to place a timeout for connecting to Nomad. A negative duration is ignored, a duration of zero means no timeout, and any other value will add a timeout.

type Constraint

type Constraint struct {
	LTarget string
	RTarget string
	Operand string
}

Constraint is used to serialize a job placement constraint.

func NewConstraint added in v0.2.0

func NewConstraint(left, operand, right string) *Constraint

NewConstraint generates a new job placement constraint.

type CpuStats added in v0.4.0

type CpuStats struct {
	SystemMode       float64
	UserMode         float64
	TotalTicks       float64
	ThrottledPeriods uint64
	ThrottledTime    uint64
	Percent          float64
	Measured         []string
}

CpuStats holds cpu usage related stats

type Deployment added in v0.6.0

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.
	JobSpecModifyIndex uint64

	// JobCreateIndex is the create index of the job which the deployment is
	// tracking. It is needed so that if the job gets stopped and reran we can
	// present the correct list of deployments for the job and not old ones.
	JobCreateIndex uint64

	// TaskGroups is the set of task groups effected by the deployment and their
	// current deployment status.
	TaskGroups map[string]*DeploymentState

	// The status of the deployment
	Status string

	// StatusDescription allows a human readable description of the deployment
	// status.
	StatusDescription string

	CreateIndex uint64
	ModifyIndex uint64
}

Deployment is used to serialize an deployment.

type DeploymentAllocHealthRequest added in v0.6.0

type DeploymentAllocHealthRequest struct {
	DeploymentID string

	// Marks these allocations as healthy, allow further allocations
	// to be rolled.
	HealthyAllocationIDs []string

	// Any unhealthy allocations fail the deployment
	UnhealthyAllocationIDs []string

	WriteRequest
}

DeploymentAllocHealthRequest is used to set the health of a set of allocations as part of a deployment.

type DeploymentFailRequest added in v0.6.0

type DeploymentFailRequest struct {
	DeploymentID string
	WriteRequest
}

DeploymentFailRequest is used to fail a particular deployment

type DeploymentIndexSort added in v0.6.0

type DeploymentIndexSort []*Deployment

DeploymentIndexSort is a wrapper to sort deployments by CreateIndex. We reverse the test so that we get the highest index first.

func (DeploymentIndexSort) Len added in v0.6.0

func (d DeploymentIndexSort) Len() int

func (DeploymentIndexSort) Less added in v0.6.0

func (d DeploymentIndexSort) Less(i, j int) bool

func (DeploymentIndexSort) Swap added in v0.6.0

func (d DeploymentIndexSort) Swap(i, j int)

type DeploymentPauseRequest added in v0.6.0

type DeploymentPauseRequest struct {
	DeploymentID string

	// Pause sets the pause status
	Pause bool

	WriteRequest
}

DeploymentPauseRequest is used to pause a deployment

type DeploymentPromoteRequest added in v0.6.0

type DeploymentPromoteRequest struct {
	DeploymentID string

	// All is to promote all task groups
	All bool

	// Groups is used to set the promotion status per task group
	Groups []string

	WriteRequest
}

DeploymentPromoteRequest is used to promote task groups in a deployment

type DeploymentSpecificRequest added in v0.6.0

type DeploymentSpecificRequest struct {
	DeploymentID string
	QueryOptions
}

DeploymentSpecificRequest is used to make a request specific to a particular deployment

type DeploymentState added in v0.6.0

type DeploymentState struct {
	PlacedCanaries    []string
	AutoRevert        bool
	ProgressDeadline  time.Duration
	RequireProgressBy time.Time
	Promoted          bool
	DesiredCanaries   int
	DesiredTotal      int
	PlacedAllocs      int
	HealthyAllocs     int
	UnhealthyAllocs   int
}

DeploymentState tracks the state of a deployment for a given task group.

type DeploymentUpdateResponse added in v0.6.0

type DeploymentUpdateResponse struct {
	EvalID                string
	EvalCreateIndex       uint64
	DeploymentModifyIndex uint64
	RevertedJobVersion    *uint64
	WriteMeta
}

DeploymentUpdateResponse is used to respond to a deployment change. The response will include the modify index of the deployment as well as details of any triggered evaluation.

type Deployments added in v0.6.0

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

Deployments is used to query the deployments endpoints.

func (*Deployments) Allocations added in v0.6.0

func (d *Deployments) Allocations(deploymentID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error)

Allocations is used to retrieve a set of allocations that are part of the deployment

func (*Deployments) Fail added in v0.6.0

func (d *Deployments) Fail(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error)

Fail is used to fail the given deployment.

func (*Deployments) Info added in v0.6.0

func (d *Deployments) Info(deploymentID string, q *QueryOptions) (*Deployment, *QueryMeta, error)

Info is used to query a single deployment by its ID.

func (*Deployments) List added in v0.6.0

func (d *Deployments) List(q *QueryOptions) ([]*Deployment, *QueryMeta, error)

List is used to dump all of the deployments.

func (*Deployments) Pause added in v0.6.0

func (d *Deployments) Pause(deploymentID string, pause bool, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error)

Pause is used to pause or unpause the given deployment.

func (*Deployments) PrefixList added in v0.6.0

func (d *Deployments) PrefixList(prefix string) ([]*Deployment, *QueryMeta, error)

func (*Deployments) PromoteAll added in v0.6.0

func (d *Deployments) PromoteAll(deploymentID string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error)

PromoteAll is used to promote all canaries in the given deployment

func (*Deployments) PromoteGroups added in v0.6.0

func (d *Deployments) PromoteGroups(deploymentID string, groups []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error)

PromoteGroups is used to promote canaries in the passed groups in the given deployment

func (*Deployments) SetAllocHealth added in v0.6.0

func (d *Deployments) SetAllocHealth(deploymentID string, healthy, unhealthy []string, q *WriteOptions) (*DeploymentUpdateResponse, *WriteMeta, error)

SetAllocHealth is used to set allocation health for allocs that are part of the given deployment

type DesiredTransition added in v0.8.0

type DesiredTransition struct {
	// Migrate is used to indicate that this allocation should be stopped and
	// migrated to another node.
	Migrate *bool

	// Reschedule is used to indicate that this allocation is eligible to be
	// rescheduled.
	Reschedule *bool
}

DesiredTransition is used to mark an allocation as having a desired state transition. This information can be used by the scheduler to make the correct decision.

func (DesiredTransition) ShouldMigrate added in v0.8.0

func (d DesiredTransition) ShouldMigrate() bool

ShouldMigrate returns whether the transition object dictates a migration.

type DesiredUpdates added in v0.4.0

type DesiredUpdates struct {
	Ignore            uint64
	Place             uint64
	Migrate           uint64
	Stop              uint64
	InPlaceUpdate     uint64
	DestructiveUpdate uint64
	Canary            uint64
	Preemptions       uint64
}

type DeviceGroupStats

type DeviceGroupStats struct {
	Vendor string
	Type   string
	Name   string

	// InstanceStats is a mapping of each device ID to its statistics.
	InstanceStats map[string]*DeviceStats
}

DeviceGroupStats contains statistics for each device of a particular device group, identified by the vendor, type and name of the device.

type DeviceStats

type DeviceStats struct {
	// Summary exposes a single summary metric that should be the most
	// informative to users.
	Summary *StatValue

	// Stats contains the verbose statistics for the device.
	Stats *StatObject

	// Timestamp is the time the statistics were collected.
	Timestamp time.Time
}

DeviceStats is the statistics for an individual device

type DispatchPayloadConfig added in v0.5.3

type DispatchPayloadConfig struct {
	File string
}

DispatchPayloadConfig configures how a task gets its input from a job dispatch

type DrainSpec added in v0.8.0

type DrainSpec struct {
	// Deadline is the duration after StartTime when the remaining
	// allocations on a draining Node should be told to stop.
	Deadline time.Duration

	// IgnoreSystemJobs allows systems jobs to remain on the node even though it
	// has been marked for draining.
	IgnoreSystemJobs bool
}

DrainSpec describes a Node's drain behavior.

type DrainStrategy added in v0.8.0

type DrainStrategy struct {
	// DrainSpec is the user declared drain specification
	DrainSpec

	// ForceDeadline is the deadline time for the drain after which drains will
	// be forced
	ForceDeadline time.Time
}

DrainStrategy describes a Node's drain behavior.

func (*DrainStrategy) Equal added in v0.8.0

func (d *DrainStrategy) Equal(o *DrainStrategy) bool

func (*DrainStrategy) String added in v0.8.0

func (d *DrainStrategy) String() string

String returns a human readable version of the drain strategy.

type DriverInfo added in v0.8.0

type DriverInfo struct {
	Attributes        map[string]string
	Detected          bool
	Healthy           bool
	HealthDescription string
	UpdateTime        time.Time
}

DriverInfo is used to deserialize a DriverInfo entry

type EphemeralDisk added in v0.5.0

type EphemeralDisk struct {
	Sticky  *bool
	Migrate *bool
	SizeMB  *int `mapstructure:"size"`
}

EphemeralDisk is an ephemeral disk object

func DefaultEphemeralDisk added in v0.5.5

func DefaultEphemeralDisk() *EphemeralDisk

func (*EphemeralDisk) Canonicalize added in v0.5.5

func (e *EphemeralDisk) Canonicalize()

type EvalIndexSort

type EvalIndexSort []*Evaluation

EvalIndexSort is a wrapper to sort evaluations by CreateIndex. We reverse the test so that we get the highest index first.

func (EvalIndexSort) Len

func (e EvalIndexSort) Len() int

func (EvalIndexSort) Less

func (e EvalIndexSort) Less(i, j int) bool

func (EvalIndexSort) Swap

func (e EvalIndexSort) Swap(i, j int)

type EvalOptions added in v0.8.4

type EvalOptions struct {
	ForceReschedule bool
}

EvalOptions is used to encapsulate options when forcing a job evaluation

type Evaluation

type Evaluation struct {
	ID                   string
	Priority             int
	Type                 string
	TriggeredBy          string
	Namespace            string
	JobID                string
	JobModifyIndex       uint64
	NodeID               string
	NodeModifyIndex      uint64
	DeploymentID         string
	Status               string
	StatusDescription    string
	Wait                 time.Duration
	WaitUntil            time.Time
	NextEval             string
	PreviousEval         string
	BlockedEval          string
	FailedTGAllocs       map[string]*AllocationMetric
	ClassEligibility     map[string]bool
	EscapedComputedClass bool
	QuotaLimitReached    string
	AnnotatePlan         bool
	QueuedAllocations    map[string]int
	SnapshotIndex        uint64
	CreateIndex          uint64
	ModifyIndex          uint64
}

Evaluation is used to serialize an evaluation.

type Evaluations

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

Evaluations is used to query the evaluation endpoints.

func (*Evaluations) Allocations

func (e *Evaluations) Allocations(evalID string, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error)

Allocations is used to retrieve a set of allocations given an evaluation ID.

func (*Evaluations) Info

func (e *Evaluations) Info(evalID string, q *QueryOptions) (*Evaluation, *QueryMeta, error)

Info is used to query a single evaluation by its ID.

func (*Evaluations) List

func (e *Evaluations) List(q *QueryOptions) ([]*Evaluation, *QueryMeta, error)

List is used to dump all of the evaluations.

func (*Evaluations) PrefixList added in v0.3.0

func (e *Evaluations) PrefixList(prefix string) ([]*Evaluation, *QueryMeta, error)

type FieldDiff added in v0.4.0

type FieldDiff struct {
	Type        string
	Name        string
	Old, New    string
	Annotations []string
}

type FrameReader added in v0.4.1

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

FrameReader is used to convert a stream of frames into a read closer.

func NewFrameReader added in v0.4.1

func NewFrameReader(frames <-chan *StreamFrame, errCh <-chan error, cancelCh chan struct{}) *FrameReader

NewFrameReader takes a channel of frames and returns a FrameReader which implements io.ReadCloser

func (*FrameReader) Close added in v0.4.1

func (f *FrameReader) Close() error

Close cancels the stream of frames

func (*FrameReader) Offset added in v0.4.1

func (f *FrameReader) Offset() int

Offset returns the offset into the stream.

func (*FrameReader) Read added in v0.4.1

func (f *FrameReader) Read(p []byte) (n int, err error)

Read reads the data of the incoming frames into the bytes buffer. Returns EOF when there are no more frames.

func (*FrameReader) SetUnblockTime added in v0.4.1

func (f *FrameReader) SetUnblockTime(d time.Duration)

SetUnblockTime sets the time to unblock and return zero bytes read. If the duration is unset or is zero or less, the read will block until data is read.

type HostCPUStats added in v0.4.0

type HostCPUStats struct {
	CPU    string
	User   float64
	System float64
	Idle   float64
}

type HostDiskStats added in v0.4.0

type HostDiskStats struct {
	Device            string
	Mountpoint        string
	Size              uint64
	Used              uint64
	Available         uint64
	UsedPercent       float64
	InodesUsedPercent float64
}

type HostMemoryStats added in v0.4.0

type HostMemoryStats struct {
	Total     uint64
	Available uint64
	Used      uint64
	Free      uint64
}

type HostStats added in v0.4.0

type HostStats struct {
	Memory           *HostMemoryStats
	CPU              []*HostCPUStats
	DiskStats        []*HostDiskStats
	DeviceStats      []*DeviceGroupStats
	Uptime           uint64
	CPUTicksConsumed float64
}

HostStats represents resource usage stats of the host running a Nomad client

type HttpBasicAuth added in v0.4.1

type HttpBasicAuth struct {
	// Username to use for HTTP Basic Authentication
	Username string

	// Password to use for HTTP Basic Authentication
	Password string
}

HttpBasicAuth is used to authenticate http client with HTTP Basic Authentication

type Job

type Job struct {
	Stop              *bool
	Region            *string
	Namespace         *string
	ID                *string
	ParentID          *string
	Name              *string
	Type              *string
	Priority          *int
	AllAtOnce         *bool `mapstructure:"all_at_once"`
	Datacenters       []string
	Constraints       []*Constraint
	Affinities        []*Affinity
	TaskGroups        []*TaskGroup
	Update            *UpdateStrategy
	Spreads           []*Spread
	Periodic          *PeriodicConfig
	ParameterizedJob  *ParameterizedJobConfig
	Dispatched        bool
	Payload           []byte
	Reschedule        *ReschedulePolicy
	Migrate           *MigrateStrategy
	Meta              map[string]string
	VaultToken        *string `mapstructure:"vault_token"`
	Status            *string
	StatusDescription *string
	Stable            *bool
	Version           *uint64
	SubmitTime        *int64
	CreateIndex       *uint64
	ModifyIndex       *uint64
	JobModifyIndex    *uint64
}

Job is used to serialize a job.

func NewBatchJob

func NewBatchJob(id, name, region string, pri int) *Job

NewBatchJob creates and returns a new batch-style job for short-lived processes using the provided name and ID along with the relative job priority.

func NewServiceJob

func NewServiceJob(id, name, region string, pri int) *Job

NewServiceJob creates and returns a new service-style job for long-lived processes using the provided name, ID, and relative job priority.

func (*Job) AddAffinity

func (j *Job) AddAffinity(a *Affinity) *Job

AddAffinity is used to add an affinity to a job.

func (*Job) AddDatacenter

func (j *Job) AddDatacenter(dc string) *Job

AddDatacenter is used to add a datacenter to a job.

func (*Job) AddPeriodicConfig added in v0.3.0

func (j *Job) AddPeriodicConfig(cfg *PeriodicConfig) *Job

AddPeriodicConfig adds a periodic config to an existing job.

func (*Job) AddSpread

func (j *Job) AddSpread(s *Spread) *Job

func (*Job) AddTaskGroup

func (j *Job) AddTaskGroup(grp *TaskGroup) *Job

AddTaskGroup adds a task group to an existing job.

func (*Job) Canonicalize added in v0.5.5

func (j *Job) Canonicalize()

func (*Job) Constrain

func (j *Job) Constrain(c *Constraint) *Job

Constrain is used to add a constraint to a job.

func (*Job) IsParameterized added in v0.5.5

func (j *Job) IsParameterized() bool

IsParameterized returns whether a job is parameterized job.

func (*Job) IsPeriodic added in v0.5.5

func (j *Job) IsPeriodic() bool

IsPeriodic returns whether a job is periodic.

func (*Job) LookupTaskGroup added in v0.8.0

func (j *Job) LookupTaskGroup(name string) *TaskGroup

LookupTaskGroup finds a task group by name

func (*Job) SetMeta

func (j *Job) SetMeta(key, val string) *Job

SetMeta is used to set arbitrary k/v pairs of metadata on a job.

type JobChildrenSummary added in v0.5.3

type JobChildrenSummary struct {
	Pending int64
	Running int64
	Dead    int64
}

JobChildrenSummary contains the summary of children job status

func (*JobChildrenSummary) Sum added in v0.5.3

func (jc *JobChildrenSummary) Sum() int

type JobDeregisterResponse added in v0.6.0

type JobDeregisterResponse struct {
	EvalID          string
	EvalCreateIndex uint64
	JobModifyIndex  uint64
	QueryMeta
}

JobDeregisterResponse is used to respond to a job deregistration

type JobDiff added in v0.4.0

type JobDiff struct {
	Type       string
	ID         string
	Fields     []*FieldDiff
	Objects    []*ObjectDiff
	TaskGroups []*TaskGroupDiff
}

type JobDispatchRequest added in v0.5.3

type JobDispatchRequest struct {
	JobID   string
	Payload []byte
	Meta    map[string]string
}

type JobDispatchResponse added in v0.5.3

type JobDispatchResponse struct {
	DispatchedJobID string
	EvalID          string
	EvalCreateIndex uint64
	JobCreateIndex  uint64
	WriteMeta
}

type JobEvaluateRequest added in v0.8.4

type JobEvaluateRequest struct {
	JobID       string
	EvalOptions EvalOptions
	WriteRequest
}

JobEvaluateRequest is used when we just need to re-evaluate a target job

type JobIDSort

type JobIDSort []*JobListStub

JobIDSort is used to sort jobs by their job ID's.

func (JobIDSort) Len

func (j JobIDSort) Len() int

func (JobIDSort) Less

func (j JobIDSort) Less(a, b int) bool

func (JobIDSort) Swap

func (j JobIDSort) Swap(a, b int)

type JobListStub

type JobListStub struct {
	ID                string
	ParentID          string
	Name              string
	Datacenters       []string
	Type              string
	Priority          int
	Periodic          bool
	ParameterizedJob  bool
	Stop              bool
	Status            string
	StatusDescription string
	JobSummary        *JobSummary
	CreateIndex       uint64
	ModifyIndex       uint64
	JobModifyIndex    uint64
	SubmitTime        int64
}

JobListStub is used to return a subset of information about jobs during list operations.

type JobPlanRequest added in v0.4.0

type JobPlanRequest struct {
	Job            *Job
	Diff           bool
	PolicyOverride bool
	WriteRequest
}

type JobPlanResponse added in v0.4.0

type JobPlanResponse struct {
	JobModifyIndex     uint64
	CreatedEvals       []*Evaluation
	Diff               *JobDiff
	Annotations        *PlanAnnotations
	FailedTGAllocs     map[string]*AllocationMetric
	NextPeriodicLaunch time.Time

	// Warnings contains any warnings about the given job. These may include
	// deprecation warnings.
	Warnings string
}

type JobRegisterRequest added in v0.5.5

type JobRegisterRequest struct {
	Job *Job
	// If EnforceIndex is set then the job will only be registered if the passed
	// JobModifyIndex matches the current Jobs index. If the index is zero, the
	// register only occurs if the job is new.
	EnforceIndex   bool
	JobModifyIndex uint64
	PolicyOverride bool

	WriteRequest
}

JobUpdateRequest is used to update a job

type JobRegisterResponse added in v0.6.0

type JobRegisterResponse struct {
	EvalID          string
	EvalCreateIndex uint64
	JobModifyIndex  uint64

	// Warnings contains any warnings about the given job. These may include
	// deprecation warnings.
	Warnings string

	QueryMeta
}

JobRegisterResponse is used to respond to a job registration

type JobRevertRequest added in v0.6.0

type JobRevertRequest struct {
	// JobID is the ID of the job  being reverted
	JobID string

	// JobVersion the version to revert to.
	JobVersion uint64

	// EnforcePriorVersion if set will enforce that the job is at the given
	// version before reverting.
	EnforcePriorVersion *uint64

	WriteRequest
}

JobRevertRequest is used to revert a job to a prior version.

type JobStabilityRequest added in v0.6.0

type JobStabilityRequest struct {
	// Job to set the stability on
	JobID      string
	JobVersion uint64

	// Set the stability
	Stable bool
	WriteRequest
}

JobStabilityRequest is used to marked a job as stable.

type JobStabilityResponse added in v0.6.0

type JobStabilityResponse struct {
	JobModifyIndex uint64
	WriteMeta
}

JobStabilityResponse is the response when marking a job as stable.

type JobSummary added in v0.4.1

type JobSummary struct {
	JobID     string
	Namespace string
	Summary   map[string]TaskGroupSummary
	Children  *JobChildrenSummary

	// Raft Indexes
	CreateIndex uint64
	ModifyIndex uint64
}

JobSummary summarizes the state of the allocations of a job

type JobValidateRequest added in v0.5.5

type JobValidateRequest struct {
	Job *Job
	WriteRequest
}

JobValidateRequest is used to validate a job

type JobValidateResponse added in v0.5.5

type JobValidateResponse struct {
	// DriverConfigValidated indicates whether the agent validated the driver
	// config
	DriverConfigValidated bool

	// ValidationErrors is a list of validation errors
	ValidationErrors []string

	// Error is a string version of any error that may have occurred
	Error string

	// Warnings contains any warnings about the given job. These may include
	// deprecation warnings.
	Warnings string
}

JobValidateResponse is the response from validate request

type JobVersionsResponse added in v0.6.0

type JobVersionsResponse struct {
	Versions []*Job
	Diffs    []*JobDiff
	QueryMeta
}

JobVersionsResponse is used for a job get versions request

type Jobs

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

Jobs is used to access the job-specific endpoints.

func (*Jobs) Allocations

func (j *Jobs) Allocations(jobID string, allAllocs bool, q *QueryOptions) ([]*AllocationListStub, *QueryMeta, error)

Allocations is used to return the allocs for a given job ID.

func (*Jobs) Deployments added in v0.6.0

func (j *Jobs) Deployments(jobID string, q *QueryOptions) ([]*Deployment, *QueryMeta, error)

Deployments is used to query the deployments associated with the given job ID.

func (*Jobs) Deregister

func (j *Jobs) Deregister(jobID string, purge bool, q *WriteOptions) (string, *WriteMeta, error)

Deregister is used to remove an existing job. If purge is set to true, the job is deregistered and purged from the system versus still being queryable and eventually GC'ed from the system. Most callers should not specify purge.

func (*Jobs) Dispatch added in v0.5.3

func (j *Jobs) Dispatch(jobID string, meta map[string]string,
	payload []byte, q *WriteOptions) (*JobDispatchResponse, *WriteMeta, error)

func (*Jobs) EnforceRegister added in v0.4.0

func (j *Jobs) EnforceRegister(job *Job, modifyIndex uint64, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error)

EnforceRegister is used to register a job enforcing its job modify index.

func (*Jobs) EvaluateWithOpts added in v0.8.4

func (j *Jobs) EvaluateWithOpts(jobID string, opts EvalOptions, q *WriteOptions) (string, *WriteMeta, error)

EvaluateWithOpts is used to force-evaluate an existing job and takes additional options for whether to force reschedule failed allocations

func (*Jobs) Evaluations

func (j *Jobs) Evaluations(jobID string, q *QueryOptions) ([]*Evaluation, *QueryMeta, error)

Evaluations is used to query the evaluations associated with the given job ID.

func (*Jobs) ForceEvaluate

func (j *Jobs) ForceEvaluate(jobID string, q *WriteOptions) (string, *WriteMeta, error)

ForceEvaluate is used to force-evaluate an existing job.

func (*Jobs) Info

func (j *Jobs) Info(jobID string, q *QueryOptions) (*Job, *QueryMeta, error)

Info is used to retrieve information about a particular job given its unique ID.

func (*Jobs) LatestDeployment added in v0.6.0

func (j *Jobs) LatestDeployment(jobID string, q *QueryOptions) (*Deployment, *QueryMeta, error)

LatestDeployment is used to query for the latest deployment associated with the given job ID.

func (*Jobs) List

func (j *Jobs) List(q *QueryOptions) ([]*JobListStub, *QueryMeta, error)

List is used to list all of the existing jobs.

func (*Jobs) ParseHCL added in v0.8.2

func (j *Jobs) ParseHCL(jobHCL string, canonicalize bool) (*Job, error)

Parse is used to convert the HCL repesentation of a Job to JSON server side. To parse the HCL client side see package github.com/hashicorp/nomad/jobspec

func (*Jobs) PeriodicForce added in v0.3.0

func (j *Jobs) PeriodicForce(jobID string, q *WriteOptions) (string, *WriteMeta, error)

PeriodicForce spawns a new instance of the periodic job and returns the eval ID

func (*Jobs) Plan added in v0.4.0

func (j *Jobs) Plan(job *Job, diff bool, q *WriteOptions) (*JobPlanResponse, *WriteMeta, error)

func (*Jobs) PlanOpts added in v0.7.0

func (j *Jobs) PlanOpts(job *Job, opts *PlanOptions, q *WriteOptions) (*JobPlanResponse, *WriteMeta, error)

func (*Jobs) PrefixList added in v0.3.0

func (j *Jobs) PrefixList(prefix string) ([]*JobListStub, *QueryMeta, error)

PrefixList is used to list all existing jobs that match the prefix.

func (*Jobs) Register

func (j *Jobs) Register(job *Job, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error)

Register is used to register a new job. It returns the ID of the evaluation, along with any errors encountered.

func (*Jobs) RegisterOpts added in v0.7.0

func (j *Jobs) RegisterOpts(job *Job, opts *RegisterOptions, q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error)

Register is used to register a new job. It returns the ID of the evaluation, along with any errors encountered.

func (*Jobs) Revert added in v0.6.0

func (j *Jobs) Revert(jobID string, version uint64, enforcePriorVersion *uint64,
	q *WriteOptions) (*JobRegisterResponse, *WriteMeta, error)

Revert is used to revert the given job to the passed version. If enforceVersion is set, the job is only reverted if the current version is at the passed version.

func (*Jobs) Stable added in v0.6.0

func (j *Jobs) Stable(jobID string, version uint64, stable bool,
	q *WriteOptions) (*JobStabilityResponse, *WriteMeta, error)

Stable is used to mark a job version's stability.

func (*Jobs) Summary added in v0.4.1

func (j *Jobs) Summary(jobID string, q *QueryOptions) (*JobSummary, *QueryMeta, error)

func (*Jobs) Validate added in v0.5.5

func (j *Jobs) Validate(job *Job, q *WriteOptions) (*JobValidateResponse, *WriteMeta, error)

func (*Jobs) Versions added in v0.6.0

func (j *Jobs) Versions(jobID string, diffs bool, q *QueryOptions) ([]*Job, []*JobDiff, *QueryMeta, error)

Versions is used to retrieve all versions of a particular job given its unique ID.

type JobsParseRequest added in v0.8.2

type JobsParseRequest struct {
	// JobHCL is an hcl jobspec
	JobHCL string

	// Canonicalize is a flag as to if the server should return default values
	// for unset fields
	Canonicalize bool
}

JobsParseRequest is used for arguments of the /vi/jobs/parse endpoint

type KeyringRequest added in v0.5.0

type KeyringRequest struct {
	Key string
}

KeyringRequest is request objects for serf key operations.

type KeyringResponse added in v0.5.0

type KeyringResponse struct {
	Messages map[string]string
	Keys     map[string]int
	NumNodes int
}

KeyringResponse is a unified key response and can be used for install, remove, use, as well as listing key queries.

type LogConfig added in v0.3.0

type LogConfig struct {
	MaxFiles      *int `mapstructure:"max_files"`
	MaxFileSizeMB *int `mapstructure:"max_file_size"`
}

LogConfig provides configuration for log rotation

func DefaultLogConfig added in v0.5.5

func DefaultLogConfig() *LogConfig

func (*LogConfig) Canonicalize added in v0.5.5

func (l *LogConfig) Canonicalize()

type MemoryStats added in v0.4.0

type MemoryStats struct {
	RSS            uint64
	Cache          uint64
	Swap           uint64
	Usage          uint64
	MaxUsage       uint64
	KernelUsage    uint64
	KernelMaxUsage uint64
	Measured       []string
}

MemoryStats holds memory usage related stats

type MigrateStrategy added in v0.8.0

type MigrateStrategy struct {
	MaxParallel     *int           `mapstructure:"max_parallel"`
	HealthCheck     *string        `mapstructure:"health_check"`
	MinHealthyTime  *time.Duration `mapstructure:"min_healthy_time"`
	HealthyDeadline *time.Duration `mapstructure:"healthy_deadline"`
}

MigrateStrategy describes how allocations for a task group should be migrated between nodes (eg when draining).

func DefaultMigrateStrategy added in v0.8.0

func DefaultMigrateStrategy() *MigrateStrategy

func (*MigrateStrategy) Canonicalize added in v0.8.0

func (m *MigrateStrategy) Canonicalize()

func (*MigrateStrategy) Copy added in v0.8.0

func (m *MigrateStrategy) Copy() *MigrateStrategy

func (*MigrateStrategy) Merge added in v0.8.0

func (m *MigrateStrategy) Merge(o *MigrateStrategy)

type MonitorMessage added in v0.8.0

type MonitorMessage struct {
	Level   MonitorMsgLevel
	Message string
}

MonitorMessage contains a message and log level.

func Messagef added in v0.8.0

func Messagef(lvl MonitorMsgLevel, msg string, args ...interface{}) *MonitorMessage

Messagef formats a new MonitorMessage.

func (*MonitorMessage) String added in v0.8.0

func (m *MonitorMessage) String() string

type MonitorMsgLevel added in v0.8.0

type MonitorMsgLevel int

MonitorMsgLevels represents the severity log level of a MonitorMessage.

const (
	MonitorMsgLevelNormal MonitorMsgLevel = 0
	MonitorMsgLevelInfo   MonitorMsgLevel = 1
	MonitorMsgLevelWarn   MonitorMsgLevel = 2
	MonitorMsgLevelError  MonitorMsgLevel = 3
)

type Namespace added in v0.7.0

type Namespace struct {
	Name        string
	Description string
	Quota       string
	CreateIndex uint64
	ModifyIndex uint64
}

Namespace is used to serialize a namespace.

type NamespaceIndexSort added in v0.7.0

type NamespaceIndexSort []*Namespace

NamespaceIndexSort is a wrapper to sort Namespaces by CreateIndex. We reverse the test so that we get the highest index first.

func (NamespaceIndexSort) Len added in v0.7.0

func (n NamespaceIndexSort) Len() int

func (NamespaceIndexSort) Less added in v0.7.0

func (n NamespaceIndexSort) Less(i, j int) bool

func (NamespaceIndexSort) Swap added in v0.7.0

func (n NamespaceIndexSort) Swap(i, j int)

type Namespaces added in v0.7.0

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

Namespaces is used to query the namespace endpoints.

func (*Namespaces) Delete added in v0.7.0

func (n *Namespaces) Delete(namespace string, q *WriteOptions) (*WriteMeta, error)

Delete is used to delete a namespace

func (*Namespaces) Info added in v0.7.0

func (n *Namespaces) Info(name string, q *QueryOptions) (*Namespace, *QueryMeta, error)

Info is used to query a single namespace by its name.

func (*Namespaces) List added in v0.7.0

func (n *Namespaces) List(q *QueryOptions) ([]*Namespace, *QueryMeta, error)

List is used to dump all of the namespaces.

func (*Namespaces) PrefixList added in v0.7.0

func (n *Namespaces) PrefixList(prefix string, q *QueryOptions) ([]*Namespace, *QueryMeta, error)

PrefixList is used to do a PrefixList search over namespaces

func (*Namespaces) Register added in v0.7.0

func (n *Namespaces) Register(namespace *Namespace, q *WriteOptions) (*WriteMeta, error)

Register is used to register a namespace.

type NetworkResource

type NetworkResource struct {
	Device        string
	CIDR          string
	IP            string
	MBits         *int
	ReservedPorts []Port
	DynamicPorts  []Port
}

NetworkResource is used to describe required network resources of a given task.

func (*NetworkResource) Canonicalize added in v0.5.5

func (n *NetworkResource) Canonicalize()

type Node

type Node struct {
	ID                    string
	Datacenter            string
	Name                  string
	HTTPAddr              string
	TLSEnabled            bool
	Attributes            map[string]string
	Resources             *Resources
	Reserved              *Resources
	NodeResources         *NodeResources
	ReservedResources     *NodeReservedResources
	Links                 map[string]string
	Meta                  map[string]string
	NodeClass             string
	Drain                 bool
	DrainStrategy         *DrainStrategy
	SchedulingEligibility string
	Status                string
	StatusDescription     string
	StatusUpdatedAt       int64
	Events                []*NodeEvent
	Drivers               map[string]*DriverInfo
	CreateIndex           uint64
	ModifyIndex           uint64
}

Node is used to deserialize a node entry.

type NodeCpuResources

type NodeCpuResources struct {
	CpuShares int64
}

type NodeDevice

type NodeDevice struct {
	// ID is the ID of the device.
	ID string

	// Healthy captures whether the device is healthy.
	Healthy bool

	// HealthDescription is used to provide a human readable description of why
	// the device may be unhealthy.
	HealthDescription string

	// Locality stores HW locality information for the node to optionally be
	// used when making placement decisions.
	Locality *NodeDeviceLocality
}

NodeDevice is an instance of a particular device.

type NodeDeviceLocality

type NodeDeviceLocality struct {
	// PciBusID is the PCI Bus ID for the device.
	PciBusID string
}

NodeDeviceLocality stores information about the devices hardware locality on the node.

type NodeDeviceResource

type NodeDeviceResource struct {

	// Vendor specifies the vendor of device
	Vendor string

	// Type specifies the type of the device
	Type string

	// Name specifies the specific model of the device
	Name string

	// Instances are list of the devices matching the vendor/type/name
	Instances []*NodeDevice

	Attributes map[string]*Attribute
}

NodeDeviceResource captures a set of devices sharing a common vendor/type/device_name tuple.

func (NodeDeviceResource) ID

func (r NodeDeviceResource) ID() string

type NodeDiskResources

type NodeDiskResources struct {
	DiskMB int64
}

type NodeDrainUpdateResponse added in v0.8.0

type NodeDrainUpdateResponse struct {
	NodeModifyIndex uint64
	EvalIDs         []string
	EvalCreateIndex uint64
	WriteMeta
}

NodeDrainUpdateResponse is used to respond to a node drain update

type NodeEligibilityUpdateResponse added in v0.8.0

type NodeEligibilityUpdateResponse struct {
	NodeModifyIndex uint64
	EvalIDs         []string
	EvalCreateIndex uint64
	WriteMeta
}

NodeEligibilityUpdateResponse is used to respond to a node eligibility update

type NodeEvent added in v0.8.0

type NodeEvent struct {
	Message     string
	Subsystem   string
	Details     map[string]string
	Timestamp   time.Time
	CreateIndex uint64
}

NodeEvent is a single unit representing a node’s state change

type NodeIndexSort

type NodeIndexSort []*NodeListStub

NodeIndexSort reverse sorts nodes by CreateIndex

func (NodeIndexSort) Len

func (n NodeIndexSort) Len() int

func (NodeIndexSort) Less

func (n NodeIndexSort) Less(i, j int) bool

func (NodeIndexSort) Swap

func (n NodeIndexSort) Swap(i, j int)

type NodeListStub

type NodeListStub struct {
	Address               string
	ID                    string
	Datacenter            string
	Name                  string
	NodeClass             string
	Version               string
	Drain                 bool
	SchedulingEligibility string
	Status                string
	StatusDescription     string
	Drivers               map[string]*DriverInfo
	CreateIndex           uint64
	ModifyIndex           uint64
}

NodeListStub is a subset of information returned during node list operations.

type NodeMemoryResources

type NodeMemoryResources struct {
	MemoryMB int64
}

type NodeReservedCpuResources

type NodeReservedCpuResources struct {
	CpuShares uint64
}

type NodeReservedDiskResources

type NodeReservedDiskResources struct {
	DiskMB uint64
}

type NodeReservedMemoryResources

type NodeReservedMemoryResources struct {
	MemoryMB uint64
}

type NodeReservedNetworkResources

type NodeReservedNetworkResources struct {
	ReservedHostPorts string
}

type NodeResources

type NodeResources struct {
	Cpu      NodeCpuResources
	Memory   NodeMemoryResources
	Disk     NodeDiskResources
	Networks []*NetworkResource
	Devices  []*NodeDeviceResource
}

type NodeScoreMeta

type NodeScoreMeta struct {
	NodeID    string
	Scores    map[string]float64
	NormScore float64
}

NodeScoreMeta is used to serialize node scoring metadata displayed in the CLI during verbose mode

type NodeUpdateDrainRequest added in v0.8.0

type NodeUpdateDrainRequest struct {
	// NodeID is the node to update the drain specification for.
	NodeID string

	// DrainSpec is the drain specification to set for the node. A nil DrainSpec
	// will disable draining.
	DrainSpec *DrainSpec

	// MarkEligible marks the node as eligible for scheduling if removing
	// the drain strategy.
	MarkEligible bool
}

NodeUpdateDrainRequest is used to update the drain specification for a node.

type NodeUpdateEligibilityRequest added in v0.8.0

type NodeUpdateEligibilityRequest struct {
	// NodeID is the node to update the drain specification for.
	NodeID      string
	Eligibility string
}

NodeUpdateEligibilityRequest is used to update the drain specification for a node.

type Nodes

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

Nodes is used to query node-related API endpoints

func (*Nodes) Allocations

func (n *Nodes) Allocations(nodeID string, q *QueryOptions) ([]*Allocation, *QueryMeta, error)

Allocations is used to return the allocations associated with a node.

func (*Nodes) ForceEvaluate

func (n *Nodes) ForceEvaluate(nodeID string, q *WriteOptions) (string, *WriteMeta, error)

ForceEvaluate is used to force-evaluate an existing node.

func (*Nodes) GC added in v0.5.3

func (n *Nodes) GC(nodeID string, q *QueryOptions) error

func (*Nodes) GcAlloc added in v0.8.0

func (n *Nodes) GcAlloc(allocID string, q *QueryOptions) error

TODO Add tests

func (*Nodes) Info

func (n *Nodes) Info(nodeID string, q *QueryOptions) (*Node, *QueryMeta, error)

Info is used to query a specific node by its ID.

func (*Nodes) List

func (n *Nodes) List(q *QueryOptions) ([]*NodeListStub, *QueryMeta, error)

List is used to list out all of the nodes

func (*Nodes) MonitorDrain added in v0.8.0

func (n *Nodes) MonitorDrain(ctx context.Context, nodeID string, index uint64, ignoreSys bool) <-chan *MonitorMessage

MonitorDrain emits drain related events on the returned string channel. The channel will be closed when all allocations on the draining node have stopped or the context is canceled.

func (*Nodes) PrefixList added in v0.3.0

func (n *Nodes) PrefixList(prefix string) ([]*NodeListStub, *QueryMeta, error)

func (*Nodes) Stats added in v0.4.0

func (n *Nodes) Stats(nodeID string, q *QueryOptions) (*HostStats, error)

func (*Nodes) ToggleEligibility added in v0.8.0

func (n *Nodes) ToggleEligibility(nodeID string, eligible bool, q *WriteOptions) (*NodeEligibilityUpdateResponse, error)

ToggleEligibility is used to update the scheduling eligibility of the node

func (*Nodes) UpdateDrain added in v0.8.0

func (n *Nodes) UpdateDrain(nodeID string, spec *DrainSpec, markEligible bool, q *WriteOptions) (*NodeDrainUpdateResponse, error)

UpdateDrain is used to update the drain strategy for a given node. If markEligible is true and the drain is being removed, the node will be marked as having its scheduling being eligible

type ObjectDiff added in v0.4.0

type ObjectDiff struct {
	Type    string
	Name    string
	Fields  []*FieldDiff
	Objects []*ObjectDiff
}

type Operator added in v0.5.5

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

Operator can be used to perform low-level operator tasks for Nomad.

func (*Operator) AutopilotCASConfiguration added in v0.8.0

func (op *Operator) AutopilotCASConfiguration(conf *AutopilotConfiguration, q *WriteOptions) (bool, *WriteMeta, error)

AutopilotCASConfiguration is used to perform a Check-And-Set update on the Autopilot configuration. The ModifyIndex value will be respected. Returns true on success or false on failures.

func (*Operator) AutopilotGetConfiguration added in v0.8.0

func (op *Operator) AutopilotGetConfiguration(q *QueryOptions) (*AutopilotConfiguration, *QueryMeta, error)

AutopilotGetConfiguration is used to query the current Autopilot configuration.

func (*Operator) AutopilotServerHealth added in v0.8.0

func (op *Operator) AutopilotServerHealth(q *QueryOptions) (*OperatorHealthReply, *QueryMeta, error)

AutopilotServerHealth is used to query Autopilot's top-level view of the health of each Nomad server.

func (*Operator) AutopilotSetConfiguration added in v0.8.0

func (op *Operator) AutopilotSetConfiguration(conf *AutopilotConfiguration, q *WriteOptions) (*WriteMeta, error)

AutopilotSetConfiguration is used to set the current Autopilot configuration.

func (*Operator) RaftGetConfiguration added in v0.5.5

func (op *Operator) RaftGetConfiguration(q *QueryOptions) (*RaftConfiguration, error)

RaftGetConfiguration is used to query the current Raft peer set.

func (*Operator) RaftRemovePeerByAddress added in v0.5.5

func (op *Operator) RaftRemovePeerByAddress(address string, q *WriteOptions) error

RaftRemovePeerByAddress is used to kick a stale peer (one that it in the Raft quorum but no longer known to Serf or the catalog) by address in the form of "IP:port".

func (*Operator) RaftRemovePeerByID added in v0.8.0

func (op *Operator) RaftRemovePeerByID(id string, q *WriteOptions) error

RaftRemovePeerByID is used to kick a stale peer (one that is in the Raft quorum but no longer known to Serf or the catalog) by ID.

func (*Operator) SchedulerCASConfiguration

func (op *Operator) SchedulerCASConfiguration(conf *SchedulerConfiguration, q *WriteOptions) (*SchedulerSetConfigurationResponse, *WriteMeta, error)

SchedulerCASConfiguration is used to perform a Check-And-Set update on the Scheduler configuration. The ModifyIndex value will be respected. Returns true on success or false on failures.

func (*Operator) SchedulerGetConfiguration

func (op *Operator) SchedulerGetConfiguration(q *QueryOptions) (*SchedulerConfigurationResponse, *QueryMeta, error)

SchedulerGetConfiguration is used to query the current Scheduler configuration.

func (*Operator) SchedulerSetConfiguration

func (op *Operator) SchedulerSetConfiguration(conf *SchedulerConfiguration, q *WriteOptions) (*SchedulerSetConfigurationResponse, *WriteMeta, error)

SchedulerSetConfiguration is used to set the current Scheduler configuration.

type OperatorHealthReply added in v0.8.0

type OperatorHealthReply struct {
	// Healthy is true if all the servers in the cluster are healthy.
	Healthy bool

	// FailureTolerance is the number of healthy servers that could be lost without
	// an outage occurring.
	FailureTolerance int

	// Servers holds the health of each server.
	Servers []ServerHealth
}

OperatorHealthReply is a representation of the overall health of the cluster

type ParameterizedJobConfig added in v0.5.3

type ParameterizedJobConfig struct {
	Payload      string
	MetaRequired []string `mapstructure:"meta_required"`
	MetaOptional []string `mapstructure:"meta_optional"`
}

ParameterizedJobConfig is used to configure the parameterized job.

type PeriodicConfig added in v0.3.0

type PeriodicConfig struct {
	Enabled         *bool
	Spec            *string
	SpecType        *string
	ProhibitOverlap *bool   `mapstructure:"prohibit_overlap"`
	TimeZone        *string `mapstructure:"time_zone"`
}

PeriodicConfig is for serializing periodic config for a job.

func (*PeriodicConfig) Canonicalize added in v0.5.5

func (p *PeriodicConfig) Canonicalize()

func (*PeriodicConfig) GetLocation added in v0.5.5

func (p *PeriodicConfig) GetLocation() (*time.Location, error)

func (*PeriodicConfig) Next added in v0.5.5

func (p *PeriodicConfig) Next(fromTime time.Time) (time.Time, error)

Next returns the closest time instant matching the spec that is after the passed time. If no matching instance exists, the zero value of time.Time is returned. The `time.Location` of the returned value matches that of the passed time.

type PlanAnnotations added in v0.4.0

type PlanAnnotations struct {
	DesiredTGUpdates map[string]*DesiredUpdates
	PreemptedAllocs  []*AllocationListStub
}

type PlanOptions added in v0.7.0

type PlanOptions struct {
	Diff           bool
	PolicyOverride bool
}

PlanOptions is used to pass through job planning parameters

type Port added in v0.2.0

type Port struct {
	Label string
	Value int `mapstructure:"static"`
}

type PreemptionConfig

type PreemptionConfig struct {
	SystemSchedulerEnabled bool
}

PreemptionConfig specifies whether preemption is enabled based on scheduler type

type QueryMeta

type QueryMeta struct {
	// LastIndex. This can be used as a WaitIndex to perform
	// a blocking query
	LastIndex uint64

	// Time of last contact from the leader for the
	// server servicing the request
	LastContact time.Duration

	// Is there a known leader
	KnownLeader bool

	// How long did the request take
	RequestTime time.Duration
}

QueryMeta is used to return meta data about a query

type QueryOptions

type QueryOptions struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the query.
	Namespace string

	// AllowStale allows any Nomad server (non-leader) to service
	// a read. This allows for lower latency and higher throughput
	AllowStale bool

	// WaitIndex is used to enable a blocking query. Waits
	// until the timeout or the next index is reached
	WaitIndex uint64

	// WaitTime is used to bound the duration of a wait.
	// Defaults to that of the Config, but can be overridden.
	WaitTime time.Duration

	// If set, used as prefix for resource list searches
	Prefix string

	// Set HTTP parameters on the query.
	Params map[string]string

	// AuthToken is the secret ID of an ACL token
	AuthToken string
}

QueryOptions are used to parameterize a query

type QuotaLimit added in v0.7.0

type QuotaLimit struct {
	// Region is the region in which this limit has affect
	Region string

	// RegionLimit is the quota limit that applies to any allocation within a
	// referencing namespace in the region. A value of zero is treated as
	// unlimited and a negative value is treated as fully disallowed. This is
	// useful for once we support GPUs
	RegionLimit *Resources

	// Hash is the hash of the object and is used to make replication efficient.
	Hash []byte
}

QuotaLimit describes the resource limit in a particular region.

type QuotaLimitSort added in v0.7.0

type QuotaLimitSort []*QuotaLimit

QuotaLimitSort is a wrapper to sort QuotaLimits

func (QuotaLimitSort) Len added in v0.7.0

func (q QuotaLimitSort) Len() int

func (QuotaLimitSort) Less added in v0.7.0

func (q QuotaLimitSort) Less(i, j int) bool

func (QuotaLimitSort) Swap added in v0.7.0

func (q QuotaLimitSort) Swap(i, j int)

type QuotaSpec added in v0.7.0

type QuotaSpec struct {
	// Name is the name for the quota object
	Name string

	// Description is an optional description for the quota object
	Description string

	// Limits is the set of quota limits encapsulated by this quota object. Each
	// limit applies quota in a particular region and in the future over a
	// particular priority range and datacenter set.
	Limits []*QuotaLimit

	// Raft indexes to track creation and modification
	CreateIndex uint64
	ModifyIndex uint64
}

QuotaSpec specifies the allowed resource usage across regions.

type QuotaSpecIndexSort added in v0.7.0

type QuotaSpecIndexSort []*QuotaSpec

QuotaSpecIndexSort is a wrapper to sort QuotaSpecs by CreateIndex. We reverse the test so that we get the highest index first.

func (QuotaSpecIndexSort) Len added in v0.7.0

func (q QuotaSpecIndexSort) Len() int

func (QuotaSpecIndexSort) Less added in v0.7.0

func (q QuotaSpecIndexSort) Less(i, j int) bool

func (QuotaSpecIndexSort) Swap added in v0.7.0

func (q QuotaSpecIndexSort) Swap(i, j int)

type QuotaUsage added in v0.7.0

type QuotaUsage struct {
	Name        string
	Used        map[string]*QuotaLimit
	CreateIndex uint64
	ModifyIndex uint64
}

QuotaUsage is the resource usage of a Quota

type QuotaUsageIndexSort added in v0.7.0

type QuotaUsageIndexSort []*QuotaUsage

QuotaUsageIndexSort is a wrapper to sort QuotaUsages by CreateIndex. We reverse the test so that we get the highest index first.

func (QuotaUsageIndexSort) Len added in v0.7.0

func (q QuotaUsageIndexSort) Len() int

func (QuotaUsageIndexSort) Less added in v0.7.0

func (q QuotaUsageIndexSort) Less(i, j int) bool

func (QuotaUsageIndexSort) Swap added in v0.7.0

func (q QuotaUsageIndexSort) Swap(i, j int)

type Quotas added in v0.7.0

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

Quotas is used to query the quotas endpoints.

func (*Quotas) Delete added in v0.7.0

func (q *Quotas) Delete(quota string, qo *WriteOptions) (*WriteMeta, error)

Delete is used to delete a quota spec

func (*Quotas) Info added in v0.7.0

func (q *Quotas) Info(name string, qo *QueryOptions) (*QuotaSpec, *QueryMeta, error)

Info is used to query a single quota spec by its name.

func (*Quotas) List added in v0.7.0

func (q *Quotas) List(qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error)

List is used to dump all of the quota specs

func (*Quotas) ListUsage added in v0.7.0

func (q *Quotas) ListUsage(qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error)

ListUsage is used to dump all of the quota usages

func (*Quotas) PrefixList added in v0.7.0

func (q *Quotas) PrefixList(prefix string, qo *QueryOptions) ([]*QuotaSpec, *QueryMeta, error)

PrefixList is used to do a PrefixList search over quota specs

func (*Quotas) PrefixListUsage added in v0.7.0

func (q *Quotas) PrefixListUsage(prefix string, qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error)

PrefixList is used to do a PrefixList search over quota usages

func (*Quotas) Register added in v0.7.0

func (q *Quotas) Register(spec *QuotaSpec, qo *WriteOptions) (*WriteMeta, error)

Register is used to register a quota spec.

func (*Quotas) Usage added in v0.7.0

func (q *Quotas) Usage(name string, qo *QueryOptions) (*QuotaUsage, *QueryMeta, error)

Usage is used to query a single quota usage by its name.

type RaftConfiguration added in v0.5.5

type RaftConfiguration struct {
	// Servers has the list of servers in the Raft configuration.
	Servers []*RaftServer

	// Index has the Raft index of this configuration.
	Index uint64
}

RaftConfiguration is returned when querying for the current Raft configuration.

type RaftServer added in v0.5.5

type RaftServer struct {
	// ID is the unique ID for the server. These are currently the same
	// as the address, but they will be changed to a real GUID in a future
	// release of Nomad.
	ID string

	// Node is the node name of the server, as known by Nomad, or this
	// will be set to "(unknown)" otherwise.
	Node string

	// Address is the IP:port of the server, used for Raft communications.
	Address string

	// Leader is true if this server is the current cluster leader.
	Leader bool

	// Voter is true if this server has a vote in the cluster. This might
	// be false if the server is staging and still coming online, or if
	// it's a non-voting server, which will be added in a future release of
	// Nomad.
	Voter bool

	// RaftProtocol is the version of the Raft protocol spoken by this server.
	RaftProtocol string
}

RaftServer has information about a server in the Raft configuration.

type Raw

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

Raw can be used to do raw queries against custom endpoints

func (*Raw) Delete

func (raw *Raw) Delete(endpoint string, out interface{}, q *WriteOptions) (*WriteMeta, error)

Delete is used to do a DELETE request against an endpoint and serialize/deserialized using the standard Nomad conventions.

func (*Raw) Query

func (raw *Raw) Query(endpoint string, out interface{}, q *QueryOptions) (*QueryMeta, error)

Query is used to do a GET request against an endpoint and deserialize the response into an interface using standard Nomad conventions.

func (*Raw) Response added in v0.5.0

func (raw *Raw) Response(endpoint string, q *QueryOptions) (io.ReadCloser, error)

Response is used to make a GET request against an endpoint and returns the response body

func (*Raw) Write

func (raw *Raw) Write(endpoint string, in, out interface{}, q *WriteOptions) (*WriteMeta, error)

Write is used to do a PUT request against an endpoint and serialize/deserialized using the standard Nomad conventions.

type Regions added in v0.2.1

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

Regions is used to query the regions in the cluster.

func (*Regions) List added in v0.2.1

func (r *Regions) List() ([]string, error)

List returns a list of all of the regions.

type RegisterJobRequest added in v0.3.2

type RegisterJobRequest struct {
	Job            *Job
	EnforceIndex   bool   `json:",omitempty"`
	JobModifyIndex uint64 `json:",omitempty"`
	PolicyOverride bool   `json:",omitempty"`
}

RegisterJobRequest is used to serialize a job registration

type RegisterOptions added in v0.7.0

type RegisterOptions struct {
	EnforceIndex   bool
	ModifyIndex    uint64
	PolicyOverride bool
}

RegisterOptions is used to pass through job registration parameters

type RequestedDevice

type RequestedDevice struct {
	// Name is the request name. The possible values are as follows:
	// * <type>: A single value only specifies the type of request.
	// * <vendor>/<type>: A single slash delimiter assumes the vendor and type of device is specified.
	// * <vendor>/<type>/<name>: Two slash delimiters assume vendor, type and specific model are specified.
	//
	// Examples are as follows:
	// * "gpu"
	// * "nvidia/gpu"
	// * "nvidia/gpu/GTX2080Ti"
	Name string

	// Count is the number of requested devices
	Count *uint64

	// Constraints are a set of constraints to apply when selecting the device
	// to use.
	Constraints []*Constraint

	// Affinities are a set of affinites to apply when selecting the device
	// to use.
	Affinities []*Affinity
}

RequestedDevice is used to request a device for a task.

func (*RequestedDevice) Canonicalize

func (d *RequestedDevice) Canonicalize()

type RescheduleEvent added in v0.8.0

type RescheduleEvent struct {
	// RescheduleTime is the timestamp of a reschedule attempt
	RescheduleTime int64

	// PrevAllocID is the ID of the previous allocation being restarted
	PrevAllocID string

	// PrevNodeID is the node ID of the previous allocation
	PrevNodeID string
}

RescheduleEvent is used to keep track of previous attempts at rescheduling an allocation

type ReschedulePolicy added in v0.8.0

type ReschedulePolicy struct {
	// Attempts limits the number of rescheduling attempts that can occur in an interval.
	Attempts *int `mapstructure:"attempts"`

	// Interval is a duration in which we can limit the number of reschedule attempts.
	Interval *time.Duration `mapstructure:"interval"`

	// Delay is a minimum duration to wait between reschedule attempts.
	// The delay function determines how much subsequent reschedule attempts are delayed by.
	Delay *time.Duration `mapstructure:"delay"`

	// DelayFunction determines how the delay progressively changes on subsequent reschedule
	// attempts. Valid values are "exponential", "constant", and "fibonacci".
	DelayFunction *string `mapstructure:"delay_function"`

	// MaxDelay is an upper bound on the delay.
	MaxDelay *time.Duration `mapstructure:"max_delay"`

	// Unlimited allows rescheduling attempts until they succeed
	Unlimited *bool `mapstructure:"unlimited"`
}

Reschedule configures how Tasks are rescheduled when they crash or fail.

func NewDefaultReschedulePolicy added in v0.8.0

func NewDefaultReschedulePolicy(jobType string) *ReschedulePolicy

func (*ReschedulePolicy) Canonicalize added in v0.8.0

func (r *ReschedulePolicy) Canonicalize(jobType string)

func (*ReschedulePolicy) Copy added in v0.8.0

func (*ReschedulePolicy) Merge added in v0.8.0

func (r *ReschedulePolicy) Merge(rp *ReschedulePolicy)

func (*ReschedulePolicy) String added in v0.8.0

func (p *ReschedulePolicy) String() string

type RescheduleTracker added in v0.8.0

type RescheduleTracker struct {
	Events []*RescheduleEvent
}

RescheduleTracker encapsulates previous reschedule events

type ResourceUsage added in v0.4.0

type ResourceUsage struct {
	MemoryStats *MemoryStats
	CpuStats    *CpuStats
	DeviceStats []*DeviceGroupStats
}

ResourceUsage holds information related to cpu and memory stats

type Resources

type Resources struct {
	CPU      *int
	MemoryMB *int `mapstructure:"memory"`
	DiskMB   *int `mapstructure:"disk"`
	Networks []*NetworkResource
	Devices  []*RequestedDevice

	// COMPAT(0.10)
	// XXX Deprecated. Please do not use. The field will be removed in Nomad
	// 0.10 and is only being kept to allow any references to be removed before
	// then.
	IOPS *int
}

Resources encapsulates the required resources of a given task or task group.

func DefaultResources added in v0.7.1

func DefaultResources() *Resources

DefaultResources is a small resources object that contains the default resources requests that we will provide to an object. --- THIS FUNCTION IS REPLICATED IN nomad/structs/structs.go and should be kept in sync.

func MinResources added in v0.5.5

func MinResources() *Resources

MinResources is a small resources object that contains the absolute minimum resources that we will provide to an object. This should not be confused with the defaults which are provided in DefaultResources() --- THIS LOGIC IS REPLICATED IN nomad/structs/structs.go and should be kept in sync.

func (*Resources) Canonicalize added in v0.5.5

func (r *Resources) Canonicalize()

Canonicalize will supply missing values in the cases where they are not provided.

func (*Resources) Merge added in v0.5.5

func (r *Resources) Merge(other *Resources)

Merge merges this resource with another resource.

type RestartPolicy added in v0.2.0

type RestartPolicy struct {
	Interval *time.Duration
	Attempts *int
	Delay    *time.Duration
	Mode     *string
}

RestartPolicy defines how the Nomad client restarts tasks in a taskgroup when they fail

func (*RestartPolicy) Merge added in v0.5.5

func (r *RestartPolicy) Merge(rp *RestartPolicy)

type SchedulerConfiguration

type SchedulerConfiguration struct {
	// PreemptionConfig specifies whether to enable eviction of lower
	// priority jobs to place higher priority jobs.
	PreemptionConfig PreemptionConfig

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

type SchedulerConfigurationResponse

type SchedulerConfigurationResponse struct {
	// SchedulerConfig contains scheduler config options
	SchedulerConfig *SchedulerConfiguration

	QueryMeta
}

SchedulerConfigurationResponse is the response object that wraps SchedulerConfiguration

type SchedulerSetConfigurationResponse

type SchedulerSetConfigurationResponse struct {
	// Updated returns whether the config was actually updated
	// Only set when the request uses CAS
	Updated bool

	WriteMeta
}

SchedulerSetConfigurationResponse is the response object used when updating scheduler configuration

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

func (*Search) PrefixSearch added in v0.6.1

func (s *Search) PrefixSearch(prefix string, context contexts.Context, q *QueryOptions) (*SearchResponse, *QueryMeta, error)

PrefixSearch returns a list of matches for a particular context and prefix.

type SearchRequest added in v0.6.1

type SearchRequest struct {
	Prefix  string
	Context contexts.Context
	QueryOptions
}

type SearchResponse added in v0.6.1

type SearchResponse struct {
	Matches     map[contexts.Context][]string
	Truncations map[contexts.Context]bool
	QueryMeta
}

type SentinelPolicies added in v0.7.0

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

SentinelPolicies is used to query the Sentinel Policy endpoints.

func (*SentinelPolicies) Delete added in v0.7.0

func (a *SentinelPolicies) Delete(policyName string, q *WriteOptions) (*WriteMeta, error)

Delete is used to delete a policy

func (*SentinelPolicies) Info added in v0.7.0

func (a *SentinelPolicies) Info(policyName string, q *QueryOptions) (*SentinelPolicy, *QueryMeta, error)

Info is used to query a specific policy

func (*SentinelPolicies) List added in v0.7.0

List is used to dump all of the policies.

func (*SentinelPolicies) Upsert added in v0.7.0

func (a *SentinelPolicies) Upsert(policy *SentinelPolicy, q *WriteOptions) (*WriteMeta, error)

Upsert is used to create or update a policy

type SentinelPolicy added in v0.7.0

type SentinelPolicy struct {
	Name             string
	Description      string
	Scope            string
	EnforcementLevel string
	Policy           string
	CreateIndex      uint64
	ModifyIndex      uint64
}

type SentinelPolicyListStub added in v0.7.0

type SentinelPolicyListStub struct {
	Name             string
	Description      string
	Scope            string
	EnforcementLevel string
	CreateIndex      uint64
	ModifyIndex      uint64
}

type ServerHealth added in v0.8.0

type ServerHealth struct {
	// ID is the raft ID of the server.
	ID string

	// Name is the node name of the server.
	Name string

	// Address is the address of the server.
	Address string

	// The status of the SerfHealth check for the server.
	SerfStatus string

	// Version is the Nomad version of the server.
	Version string

	// Leader is whether this server is currently the leader.
	Leader bool

	// LastContact is the time since this node's last contact with the leader.
	LastContact time.Duration

	// LastTerm is the highest leader term this server has a record of in its Raft log.
	LastTerm uint64

	// LastIndex is the last log index this server has a record of in its Raft log.
	LastIndex uint64

	// Healthy is whether or not the server is healthy according to the current
	// Autopilot config.
	Healthy bool

	// Voter is whether this is a voting server.
	Voter bool

	// StableSince is the last time this server's Healthy value changed.
	StableSince time.Time
}

ServerHealth is the health (from the leader's point of view) of a server.

func (*ServerHealth) MarshalJSON added in v0.8.0

func (u *ServerHealth) MarshalJSON() ([]byte, error)

func (*ServerHealth) UnmarshalJSON added in v0.8.0

func (u *ServerHealth) UnmarshalJSON(data []byte) error

type ServerMembers added in v0.5.0

type ServerMembers struct {
	ServerName   string
	ServerRegion string
	ServerDC     string
	Members      []*AgentMember
}

type Service added in v0.2.0

type Service struct {
	Id           string
	Name         string
	Tags         []string
	CanaryTags   []string `mapstructure:"canary_tags"`
	PortLabel    string   `mapstructure:"port"`
	AddressMode  string   `mapstructure:"address_mode"`
	Checks       []ServiceCheck
	CheckRestart *CheckRestart `mapstructure:"check_restart"`
}

The Service model represents a Consul service definition

func (*Service) Canonicalize added in v0.5.5

func (s *Service) Canonicalize(t *Task, tg *TaskGroup, job *Job)

type ServiceCheck added in v0.2.0

type ServiceCheck struct {
	Id            string
	Name          string
	Type          string
	Command       string
	Args          []string
	Path          string
	Protocol      string
	PortLabel     string `mapstructure:"port"`
	AddressMode   string `mapstructure:"address_mode"`
	Interval      time.Duration
	Timeout       time.Duration
	InitialStatus string `mapstructure:"initial_status"`
	TLSSkipVerify bool   `mapstructure:"tls_skip_verify"`
	Header        map[string][]string
	Method        string
	CheckRestart  *CheckRestart `mapstructure:"check_restart"`
	GRPCService   string        `mapstructure:"grpc_service"`
	GRPCUseTLS    bool          `mapstructure:"grpc_use_tls"`
}

The ServiceCheck data model represents the consul health check that Nomad registers for a Task

type SingleDeploymentResponse added in v0.6.0

type SingleDeploymentResponse struct {
	Deployment *Deployment
	QueryMeta
}

SingleDeploymentResponse is used to respond with a single deployment

type Spread

type Spread struct {
	Attribute    string
	Weight       *int8
	SpreadTarget []*SpreadTarget
}

Spread is used to serialize task group allocation spread preferences

func NewSpread

func NewSpread(attribute string, weight int8, spreadTargets []*SpreadTarget) *Spread

func (*Spread) Canonicalize

func (s *Spread) Canonicalize()

type SpreadTarget

type SpreadTarget struct {
	Value   string
	Percent uint8
}

SpreadTarget is used to serialize target allocation spread percentages

func NewSpreadTarget

func NewSpreadTarget(value string, percent uint8) *SpreadTarget

type StatObject

type StatObject struct {
	// Nested is a mapping of object name to a nested stats object.
	Nested map[string]*StatObject

	// Attributes is a mapping of statistic name to its value.
	Attributes map[string]*StatValue
}

StatObject is a collection of statistics either exposed at the top level or via nested StatObjects.

type StatValue

type StatValue struct {
	// FloatNumeratorVal exposes a floating point value. If denominator is set
	// it is assumed to be a fractional value, otherwise it is a scalar.
	FloatNumeratorVal   *float64 `json:",omitempty"`
	FloatDenominatorVal *float64 `json:",omitempty"`

	// IntNumeratorVal exposes a int value. If denominator is set it is assumed
	// to be a fractional value, otherwise it is a scalar.
	IntNumeratorVal   *int64 `json:",omitempty"`
	IntDenominatorVal *int64 `json:",omitempty"`

	// StringVal exposes a string value. These are likely annotations.
	StringVal *string `json:",omitempty"`

	// BoolVal exposes a boolean statistic.
	BoolVal *bool `json:",omitempty"`

	// Unit gives the unit type: °F, %, MHz, MB, etc.
	Unit string `json:",omitempty"`

	// Desc provides a human readable description of the statistic.
	Desc string `json:",omitempty"`
}

StatValue exposes the values of a particular statistic. The value may be of type float, integer, string or boolean. Numeric types can be exposed as a single value or as a fraction.

func (*StatValue) String

func (v *StatValue) String() string

type Status

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

Status is used to query the status-related endpoints.

func (*Status) Leader

func (s *Status) Leader() (string, error)

Leader is used to query for the current cluster leader.

func (*Status) Peers

func (s *Status) Peers() ([]string, error)

Peers is used to query the addresses of the server peers in the cluster.

func (*Status) RegionLeader added in v0.3.2

func (s *Status) RegionLeader(region string) (string, error)

RegionLeader is used to query for the leader in the passed region.

type StreamFrame added in v0.4.1

type StreamFrame struct {
	Offset    int64  `json:",omitempty"`
	Data      []byte `json:",omitempty"`
	File      string `json:",omitempty"`
	FileEvent string `json:",omitempty"`
}

StreamFrame is used to frame data of a file when streaming

func (*StreamFrame) IsHeartbeat added in v0.4.1

func (s *StreamFrame) IsHeartbeat() bool

IsHeartbeat returns if the frame is a heartbeat frame

type System added in v0.3.0

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

Status is used to query the status-related endpoints.

func (*System) GarbageCollect added in v0.3.0

func (s *System) GarbageCollect() error

func (*System) ReconcileSummaries added in v0.6.1

func (s *System) ReconcileSummaries() error

type TLSConfig added in v0.5.0

type TLSConfig struct {
	// CACert is the path to a PEM-encoded CA cert file to use to verify the
	// Nomad server SSL certificate.
	CACert string

	// CAPath is the path to a directory of PEM-encoded CA cert files to verify
	// the Nomad server SSL certificate.
	CAPath string

	// ClientCert is the path to the certificate for Nomad communication
	ClientCert string

	// ClientKey is the path to the private key for Nomad communication
	ClientKey string

	// TLSServerName, if set, is used to set the SNI host when connecting via
	// TLS.
	TLSServerName string

	// Insecure enables or disables SSL verification
	Insecure bool
}

TLSConfig contains the parameters needed to configure TLS on the HTTP client used to communicate with Nomad.

func (*TLSConfig) Copy added in v0.6.1

func (t *TLSConfig) Copy() *TLSConfig

type Task

type Task struct {
	Name            string
	Driver          string
	User            string
	Config          map[string]interface{}
	Constraints     []*Constraint
	Affinities      []*Affinity
	Env             map[string]string
	Services        []*Service
	Resources       *Resources
	Meta            map[string]string
	KillTimeout     *time.Duration `mapstructure:"kill_timeout"`
	LogConfig       *LogConfig     `mapstructure:"logs"`
	Artifacts       []*TaskArtifact
	Vault           *Vault
	Templates       []*Template
	DispatchPayload *DispatchPayloadConfig
	Leader          bool
	ShutdownDelay   time.Duration `mapstructure:"shutdown_delay"`
	KillSignal      string        `mapstructure:"kill_signal"`
}

Task is a single process in a task group.

func NewTask

func NewTask(name, driver string) *Task

NewTask creates and initializes a new Task.

func (*Task) AddAffinity

func (t *Task) AddAffinity(a *Affinity) *Task

AddAffinity adds a new affinity to a single task.

func (*Task) Canonicalize added in v0.5.5

func (t *Task) Canonicalize(tg *TaskGroup, job *Job)

func (*Task) Constrain

func (t *Task) Constrain(c *Constraint) *Task

Constraint adds a new constraints to a single task.

func (*Task) Require

func (t *Task) Require(r *Resources) *Task

Require is used to add resource requirements to a task.

func (*Task) SetConfig

func (t *Task) SetConfig(key string, val interface{}) *Task

Configure is used to configure a single k/v pair on the task.

func (*Task) SetLogConfig added in v0.3.0

func (t *Task) SetLogConfig(l *LogConfig) *Task

SetLogConfig sets a log config to a task

func (*Task) SetMeta

func (t *Task) SetMeta(key, val string) *Task

SetMeta is used to add metadata k/v pairs to the task.

type TaskArtifact added in v0.3.1

type TaskArtifact struct {
	GetterSource  *string           `mapstructure:"source"`
	GetterOptions map[string]string `mapstructure:"options"`
	GetterMode    *string           `mapstructure:"mode"`
	RelativeDest  *string           `mapstructure:"destination"`
}

TaskArtifact is used to download artifacts before running a task.

func (*TaskArtifact) Canonicalize added in v0.5.5

func (a *TaskArtifact) Canonicalize()

type TaskDiff added in v0.4.0

type TaskDiff struct {
	Type        string
	Name        string
	Fields      []*FieldDiff
	Objects     []*ObjectDiff
	Annotations []string
}

type TaskEvent added in v0.2.0

type TaskEvent struct {
	Type           string
	Time           int64
	DisplayMessage string
	Details        map[string]string
	// DEPRECATION NOTICE: The following fields are all deprecated. see TaskEvent struct in structs.go for details.
	FailsTask        bool
	RestartReason    string
	SetupError       string
	DriverError      string
	DriverMessage    string
	ExitCode         int
	Signal           int
	Message          string
	KillReason       string
	KillTimeout      time.Duration
	KillError        string
	StartDelay       int64
	DownloadError    string
	ValidationError  string
	DiskLimit        int64
	DiskSize         int64
	FailedSibling    string
	VaultError       string
	TaskSignalReason string
	TaskSignal       string
	GenericSource    string
}

TaskEvent is an event that effects the state of a task and contains meta-data appropriate to the events type.

type TaskGroup

type TaskGroup struct {
	Name             *string
	Count            *int
	Constraints      []*Constraint
	Affinities       []*Affinity
	Tasks            []*Task
	Spreads          []*Spread
	RestartPolicy    *RestartPolicy
	ReschedulePolicy *ReschedulePolicy
	EphemeralDisk    *EphemeralDisk
	Update           *UpdateStrategy
	Migrate          *MigrateStrategy
	Meta             map[string]string
}

TaskGroup is the unit of scheduling.

func NewTaskGroup

func NewTaskGroup(name string, count int) *TaskGroup

NewTaskGroup creates a new TaskGroup.

func (*TaskGroup) AddAffinity

func (g *TaskGroup) AddAffinity(a *Affinity) *TaskGroup

AddAffinity is used to add a new affinity to a task group.

func (*TaskGroup) AddSpread

func (g *TaskGroup) AddSpread(s *Spread) *TaskGroup

AddSpread is used to add a new spread preference to a task group.

func (*TaskGroup) AddTask

func (g *TaskGroup) AddTask(t *Task) *TaskGroup

AddTask is used to add a new task to a task group.

func (*TaskGroup) Canonicalize added in v0.5.5

func (g *TaskGroup) Canonicalize(job *Job)

func (*TaskGroup) Constrain

func (g *TaskGroup) Constrain(c *Constraint) *TaskGroup

Constrain is used to add a constraint to a task group.

func (*TaskGroup) RequireDisk added in v0.5.0

func (g *TaskGroup) RequireDisk(disk *EphemeralDisk) *TaskGroup

RequireDisk adds a ephemeral disk to the task group

func (*TaskGroup) SetMeta

func (g *TaskGroup) SetMeta(key, val string) *TaskGroup

AddMeta is used to add a meta k/v pair to a task group

type TaskGroupDiff added in v0.4.0

type TaskGroupDiff struct {
	Type    string
	Name    string
	Fields  []*FieldDiff
	Objects []*ObjectDiff
	Tasks   []*TaskDiff
	Updates map[string]uint64
}

type TaskGroupSummary added in v0.4.1

type TaskGroupSummary struct {
	Queued   int
	Complete int
	Failed   int
	Running  int
	Starting int
	Lost     int
}

TaskGroup summarizes the state of all the allocations of a particular TaskGroup

type TaskResourceUsage added in v0.4.0

type TaskResourceUsage struct {
	ResourceUsage *ResourceUsage
	Timestamp     int64
	Pids          map[string]*ResourceUsage
}

TaskResourceUsage holds aggregated resource usage of all processes in a Task and the resource usage of the individual pids

type TaskState added in v0.2.0

type TaskState struct {
	State       string
	Failed      bool
	Restarts    uint64
	LastRestart time.Time
	StartedAt   time.Time
	FinishedAt  time.Time
	Events      []*TaskEvent
}

TaskState tracks the current state of a task and events that caused state transitions.

type Template added in v0.5.0

type Template struct {
	SourcePath   *string        `mapstructure:"source"`
	DestPath     *string        `mapstructure:"destination"`
	EmbeddedTmpl *string        `mapstructure:"data"`
	ChangeMode   *string        `mapstructure:"change_mode"`
	ChangeSignal *string        `mapstructure:"change_signal"`
	Splay        *time.Duration `mapstructure:"splay"`
	Perms        *string        `mapstructure:"perms"`
	LeftDelim    *string        `mapstructure:"left_delimiter"`
	RightDelim   *string        `mapstructure:"right_delimiter"`
	Envvars      *bool          `mapstructure:"env"`
	VaultGrace   *time.Duration `mapstructure:"vault_grace"`
}

func (*Template) Canonicalize added in v0.5.5

func (tmpl *Template) Canonicalize()

type UpdateStrategy added in v0.2.0

type UpdateStrategy struct {
	Stagger          *time.Duration `mapstructure:"stagger"`
	MaxParallel      *int           `mapstructure:"max_parallel"`
	HealthCheck      *string        `mapstructure:"health_check"`
	MinHealthyTime   *time.Duration `mapstructure:"min_healthy_time"`
	HealthyDeadline  *time.Duration `mapstructure:"healthy_deadline"`
	ProgressDeadline *time.Duration `mapstructure:"progress_deadline"`
	AutoRevert       *bool          `mapstructure:"auto_revert"`
	Canary           *int           `mapstructure:"canary"`
}

UpdateStrategy defines a task groups update strategy.

func DefaultUpdateStrategy added in v0.7.0

func DefaultUpdateStrategy() *UpdateStrategy

DefaultUpdateStrategy provides a baseline that can be used to upgrade jobs with the old policy or for populating field defaults.

func (*UpdateStrategy) Canonicalize added in v0.6.0

func (u *UpdateStrategy) Canonicalize()

func (*UpdateStrategy) Copy added in v0.6.0

func (u *UpdateStrategy) Copy() *UpdateStrategy

func (*UpdateStrategy) Empty added in v0.6.3

func (u *UpdateStrategy) Empty() bool

Empty returns whether the UpdateStrategy is empty or has user defined values.

func (*UpdateStrategy) Merge added in v0.6.0

func (u *UpdateStrategy) Merge(o *UpdateStrategy)

type Vault added in v0.5.0

type Vault struct {
	Policies     []string
	Env          *bool
	ChangeMode   *string `mapstructure:"change_mode"`
	ChangeSignal *string `mapstructure:"change_signal"`
}

func (*Vault) Canonicalize added in v0.5.5

func (v *Vault) Canonicalize()

type WriteMeta

type WriteMeta struct {
	// LastIndex. This can be used as a WaitIndex to perform
	// a blocking query
	LastIndex uint64

	// How long did the request take
	RequestTime time.Duration
}

WriteMeta is used to return meta data about a write

type WriteOptions

type WriteOptions struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the write.
	Namespace string

	// AuthToken is the secret ID of an ACL token
	AuthToken string
}

WriteOptions are used to parameterize a write

type WriteRequest added in v0.5.5

type WriteRequest struct {
	// The target region for this write
	Region string

	// Namespace is the target namespace for this write
	Namespace string

	// SecretID is the secret ID of an ACL token
	SecretID string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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