Documentation ¶
Index ¶
- Constants
- func DefaultConfig() *config.Config
- type AllocRunner
- func (r *AllocRunner) Alloc() *structs.Allocation
- func (r *AllocRunner) AllocStats() map[string]TaskStatsReporter
- func (r *AllocRunner) Destroy()
- func (r *AllocRunner) DestroyContext() error
- func (r *AllocRunner) DestroyState() error
- func (r *AllocRunner) RestoreState() error
- func (r *AllocRunner) Run()
- func (r *AllocRunner) SaveState() error
- func (r *AllocRunner) StatsReporter() AllocStatsReporter
- func (r *AllocRunner) TaskStats(task string) (TaskStatsReporter, error)
- func (r *AllocRunner) Update(update *structs.Allocation)
- func (r *AllocRunner) WaitCh() <-chan struct{}
- type AllocStateUpdater
- type AllocStatsReporter
- type Client
- func (c *Client) AllocStats() map[string]AllocStatsReporter
- func (c *Client) GetAllocFS(allocID string) (allocdir.AllocDirFS, error)
- func (c *Client) HostStats() []*stats.HostStats
- func (c *Client) HostStatsTS(since int64) []*stats.HostStats
- func (c *Client) Leave() error
- func (c *Client) Node() *structs.Node
- func (c *Client) RPC(method string, args interface{}, reply interface{}) error
- func (c *Client) Servers() []string
- func (c *Client) SetServers(servers []string)
- func (c *Client) Shutdown() error
- func (c *Client) Stats() map[string]map[string]string
- func (c *Client) StatsReporter() ClientStatsReporter
- type ClientStatsReporter
- type RestartTracker
- func (r *RestartTracker) GetReason() string
- func (r *RestartTracker) GetState() (string, time.Duration)
- func (r *RestartTracker) SetPolicy(policy *structs.RestartPolicy)
- func (r *RestartTracker) SetStartError(err error) *RestartTracker
- func (r *RestartTracker) SetWaitResult(res *cstructs.WaitResult) *RestartTracker
- type TaskRunner
- func (r *TaskRunner) Destroy()
- func (r *TaskRunner) DestroyState() error
- func (r *TaskRunner) MarkReceived()
- func (r *TaskRunner) ResourceUsage() []*cstructs.TaskResourceUsage
- func (r *TaskRunner) ResourceUsageTS(since int64) []*cstructs.TaskResourceUsage
- func (r *TaskRunner) RestoreState() error
- func (r *TaskRunner) Run()
- func (r *TaskRunner) SaveState() error
- func (r *TaskRunner) StatsReporter() TaskStatsReporter
- func (r *TaskRunner) Update(update *structs.Allocation)
- func (r *TaskRunner) WaitCh() <-chan struct{}
- type TaskStateUpdater
- type TaskStatsReporter
Constants ¶
const ( ReasonNoRestartsAllowed = "Policy allows no restarts" ReasonUnrecoverableErrror = "Error was unrecoverable" ReasonWithinPolicy = "Restart within policy" ReasonDelay = "Exceeded allowed attempts, applying a delay" )
Variables ¶
This section is empty.
Functions ¶
func DefaultConfig ¶
DefaultConfig returns the default configuration
Types ¶
type AllocRunner ¶
type AllocRunner struct {
// contains filtered or unexported fields
}
AllocRunner is used to wrap an allocation and provide the execution context.
func NewAllocRunner ¶
func NewAllocRunner(logger *log.Logger, config *config.Config, updater AllocStateUpdater, alloc *structs.Allocation) *AllocRunner
NewAllocRunner is used to create a new allocation context
func (*AllocRunner) Alloc ¶
func (r *AllocRunner) Alloc() *structs.Allocation
Alloc returns the associated allocation
func (*AllocRunner) AllocStats ¶
func (r *AllocRunner) AllocStats() map[string]TaskStatsReporter
AllocStats returns the stats reporter of all the tasks running in the allocation
func (*AllocRunner) Destroy ¶
func (r *AllocRunner) Destroy()
Destroy is used to indicate that the allocation context should be destroyed
func (*AllocRunner) DestroyContext ¶
func (r *AllocRunner) DestroyContext() error
DestroyContext is used to destroy the context
func (*AllocRunner) DestroyState ¶
func (r *AllocRunner) DestroyState() error
DestroyState is used to cleanup after ourselves
func (*AllocRunner) RestoreState ¶
func (r *AllocRunner) RestoreState() error
RestoreState is used to restore the state of the alloc runner
func (*AllocRunner) Run ¶
func (r *AllocRunner) Run()
Run is a long running goroutine used to manage an allocation
func (*AllocRunner) SaveState ¶
func (r *AllocRunner) SaveState() error
SaveState is used to snapshot the state of the alloc runner if the fullSync is marked as false only the state of the Alloc Runner is snapshotted. If fullSync is marked as true, we snapshot all the Task Runners associated with the Alloc
func (*AllocRunner) StatsReporter ¶ added in v0.4.0
func (r *AllocRunner) StatsReporter() AllocStatsReporter
StatsReporter returns an interface to query resource usage statistics of an allocation
func (*AllocRunner) TaskStats ¶
func (r *AllocRunner) TaskStats(task string) (TaskStatsReporter, error)
TaskStats returns the stats reporter for a specific task running in the allocation
func (*AllocRunner) Update ¶
func (r *AllocRunner) Update(update *structs.Allocation)
Update is used to update the allocation of the context
func (*AllocRunner) WaitCh ¶ added in v0.1.2
func (r *AllocRunner) WaitCh() <-chan struct{}
WaitCh returns a channel to wait for termination
type AllocStateUpdater ¶
type AllocStateUpdater func(alloc *structs.Allocation)
AllocStateUpdater is used to update the status of an allocation
type AllocStatsReporter ¶ added in v0.4.0
type AllocStatsReporter interface {
AllocStats() map[string]TaskStatsReporter
}
AllocStatsReporter exposes stats related APIs of an allocation runner
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to implement the client interaction with Nomad. Clients are expected to register as a schedulable node to the servers, and to run allocations as determined by the servers.
func (*Client) AllocStats ¶
func (c *Client) AllocStats() map[string]AllocStatsReporter
AllocStats returns all the stats reporter of the allocations running on a Nomad client
func (*Client) GetAllocFS ¶ added in v0.3.0
func (c *Client) GetAllocFS(allocID string) (allocdir.AllocDirFS, error)
GetAllocFS returns the AllocFS interface for the alloc dir of an allocation
func (*Client) Servers ¶
Servers is used to return the current known servers list. When an agent is first started, this list comes directly from configuration files.
func (*Client) SetServers ¶
SetServers is used to modify the known servers list. This avoids forcing a config rollout + rolling restart and enables auto-join features. The full set of servers is passed to support adding and/or removing servers.
func (*Client) Stats ¶
Stats is used to return statistics for debugging and insight for various sub-systems
func (*Client) StatsReporter ¶ added in v0.4.0
func (c *Client) StatsReporter() ClientStatsReporter
StatsReporter exposes the various APIs related resource usage of a Nomad client
type ClientStatsReporter ¶ added in v0.4.0
type ClientStatsReporter interface { // AllocStats returns a map of alloc ids and their corresponding stats // collector AllocStats() map[string]AllocStatsReporter // HostStats returns resource usage stats for the host HostStats() []*stats.HostStats // HostStatsTS returns a time series of host resource usage stats HostStatsTS(since int64) []*stats.HostStats }
ClientStatsReporter exposes all the APIs related to resource usage of a Nomad Client
type RestartTracker ¶ added in v0.3.0
type RestartTracker struct {
// contains filtered or unexported fields
}
func (*RestartTracker) GetReason ¶ added in v0.3.2
func (r *RestartTracker) GetReason() string
GetReason returns a human-readable description for the last state returned by GetState.
func (*RestartTracker) GetState ¶ added in v0.3.1
func (r *RestartTracker) GetState() (string, time.Duration)
GetState returns the tasks next state given the set exit code and start error. One of the following states are returned:
- TaskRestarting - Task should be restarted
- TaskNotRestarting - Task should not be restarted and has exceeded its restart policy.
- TaskTerminated - Task has terminated successfully and does not need a restart.
If TaskRestarting is returned, the duration is how long to wait until starting the task again.
func (*RestartTracker) SetPolicy ¶ added in v0.3.0
func (r *RestartTracker) SetPolicy(policy *structs.RestartPolicy)
SetPolicy updates the policy used to determine restarts.
func (*RestartTracker) SetStartError ¶ added in v0.3.1
func (r *RestartTracker) SetStartError(err error) *RestartTracker
SetStartError is used to mark the most recent start error. If starting was successful the error should be nil.
func (*RestartTracker) SetWaitResult ¶ added in v0.3.1
func (r *RestartTracker) SetWaitResult(res *cstructs.WaitResult) *RestartTracker
SetWaitResult is used to mark the most recent wait result.
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner is used to wrap a task within an allocation and provide the execution context.
func NewTaskRunner ¶
func NewTaskRunner(logger *log.Logger, config *config.Config, updater TaskStateUpdater, ctx *driver.ExecContext, alloc *structs.Allocation, task *structs.Task) *TaskRunner
NewTaskRunner is used to create a new task context
func (*TaskRunner) Destroy ¶
func (r *TaskRunner) Destroy()
Destroy is used to indicate that the task context should be destroyed
func (*TaskRunner) DestroyState ¶
func (r *TaskRunner) DestroyState() error
DestroyState is used to cleanup after ourselves
func (*TaskRunner) MarkReceived ¶ added in v0.3.2
func (r *TaskRunner) MarkReceived()
MarkReceived marks the task as received.
func (*TaskRunner) ResourceUsage ¶
func (r *TaskRunner) ResourceUsage() []*cstructs.TaskResourceUsage
ResourceUsage returns the last resource utilization datapoint collected
func (*TaskRunner) ResourceUsageTS ¶
func (r *TaskRunner) ResourceUsageTS(since int64) []*cstructs.TaskResourceUsage
ResourceUsageTS returns the list of all the resource utilization datapoints collected
func (*TaskRunner) RestoreState ¶
func (r *TaskRunner) RestoreState() error
RestoreState is used to restore our state
func (*TaskRunner) Run ¶
func (r *TaskRunner) Run()
Run is a long running routine used to manage the task
func (*TaskRunner) SaveState ¶
func (r *TaskRunner) SaveState() error
SaveState is used to snapshot our state
func (*TaskRunner) StatsReporter ¶
func (r *TaskRunner) StatsReporter() TaskStatsReporter
TaskStatsReporter returns the stats reporter of the task
func (*TaskRunner) Update ¶
func (r *TaskRunner) Update(update *structs.Allocation)
Update is used to update the task of the context
func (*TaskRunner) WaitCh ¶
func (r *TaskRunner) WaitCh() <-chan struct{}
WaitCh returns a channel to wait for termination
type TaskStateUpdater ¶
TaskStateUpdater is used to signal that tasks state has changed.
type TaskStatsReporter ¶
type TaskStatsReporter interface { // ResourceUsage returns the latest resource usage data point collected for // the task ResourceUsage() []*cstructs.TaskResourceUsage // ResourceUsageTS returns all the resource usage data points since a given // time ResourceUsageTS(since int64) []*cstructs.TaskResourceUsage }
TaskStatsReporter exposes APIs to query resource usage of a Task