Documentation ¶
Index ¶
- Constants
- type Agent
- type AllocCounter
- type AllocGarbageCollector
- func (a *AllocGarbageCollector) Collect(allocID string) bool
- func (a *AllocGarbageCollector) CollectAll()
- func (a *AllocGarbageCollector) MakeRoomFor(allocations []*structs.Allocation) error
- func (a *AllocGarbageCollector) MarkForCollection(allocID string, ar AllocRunner)
- func (a *AllocGarbageCollector) Run()
- func (a *AllocGarbageCollector) Stop()
- func (a *AllocGarbageCollector) Trigger()
- type AllocRunner
- type Allocations
- func (a *Allocations) GarbageCollect(args *nstructs.AllocSpecificRequest, reply *nstructs.GenericResponse) error
- func (a *Allocations) GarbageCollectAll(args *nstructs.NodeSpecificRequest, reply *nstructs.GenericResponse) error
- func (a *Allocations) Restart(args *nstructs.AllocRestartRequest, reply *nstructs.GenericResponse) error
- func (a *Allocations) Signal(args *nstructs.AllocSignalRequest, reply *nstructs.GenericResponse) error
- func (a *Allocations) Stats(args *cstructs.AllocStatsRequest, reply *cstructs.AllocStatsResponse) error
- type Client
- func (c *Client) AllocStateUpdated(alloc *structs.Allocation)
- func (c *Client) ClientRPC(method string, args interface{}, reply interface{}) error
- func (c *Client) CollectAllAllocs()
- func (c *Client) CollectAllocation(allocID string) bool
- func (c *Client) Datacenter() string
- func (c *Client) GetAlloc(allocID string) (*structs.Allocation, error)
- func (c *Client) GetAllocFS(allocID string) (allocdir.AllocDirFS, error)
- func (c *Client) GetAllocState(allocID string) (*arstate.State, error)
- func (c *Client) GetAllocStats(allocID string) (interfaces.AllocStatsReporter, error)
- func (c *Client) GetConfig() *config.Config
- func (c *Client) GetServers() []string
- func (c *Client) GetTaskEventHandler(allocID, taskName string) drivermanager.EventHandler
- func (c *Client) LatestDeviceResourceStats(devices []*structs.AllocatedDeviceResource) []*device.DeviceGroupStats
- func (c *Client) LatestHostStats() *stats.HostStats
- func (c *Client) Leave() error
- func (c *Client) Node() *structs.Node
- func (c *Client) NodeID() string
- func (c *Client) NumAllocs() int
- func (c *Client) Ping(srv net.Addr) error
- func (c *Client) RPC(method string, args interface{}, reply interface{}) error
- func (c *Client) RPCMajorVersion() int
- func (c *Client) RPCMinorVersion() int
- func (c *Client) Ready() <-chan struct{}
- func (c *Client) Region() string
- func (c *Client) Reload(newConfig *config.Config) error
- func (c *Client) RemoteStreamingRpcHandler(method string) (structs.StreamingRpcHandler, error)
- func (c *Client) ResolveToken(secretID string) (*acl.ACL, error)
- func (c *Client) RestartAllocation(allocID, taskName string) error
- func (c *Client) SetServers(in []string) (int, error)
- func (c *Client) Shutdown() error
- func (c *Client) SignalAllocation(allocID, task, signal string) error
- func (c *Client) Stats() map[string]map[string]string
- func (c *Client) StatsReporter() ClientStatsReporter
- func (c *Client) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error)
- func (c *Client) ValidateMigrateToken(allocID, migrateToken string) bool
- type ClientStats
- type ClientStatsReporter
- type FileSystem
- type FingerprintManager
- type GCAlloc
- type GCAllocPQImpl
- type GCConfig
- type IndexedGCAllocPQ
Constants ¶
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" )
const (
// MB is a constant which converts values in bytes to MB
MB = 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgentEndpoint ¶
func (*Agent) Profile ¶
func (a *Agent) Profile(args *structs.AgentPprofRequest, reply *structs.AgentPprofResponse) error
type AllocCounter ¶
type AllocCounter interface {
NumAllocs() int
}
AllocCounter is used by AllocGarbageCollector to discover how many un-GC'd allocations a client has and is generally fulfilled by the Client.
type AllocGarbageCollector ¶
type AllocGarbageCollector struct {
// contains filtered or unexported fields
}
AllocGarbageCollector garbage collects terminated allocations on a node
func NewAllocGarbageCollector ¶
func NewAllocGarbageCollector(logger hclog.Logger, statsCollector stats.NodeStatsCollector, ac AllocCounter, config *GCConfig) *AllocGarbageCollector
NewAllocGarbageCollector returns a garbage collector for terminated allocations on a node. Must call Run() in a goroutine enable periodic garbage collection.
func (*AllocGarbageCollector) Collect ¶
func (a *AllocGarbageCollector) Collect(allocID string) bool
Collect garbage collects a single allocation on a node. Returns true if alloc was found and garbage collected; otherwise false.
func (*AllocGarbageCollector) CollectAll ¶
func (a *AllocGarbageCollector) CollectAll()
CollectAll garbage collects all terminated allocations on a node
func (*AllocGarbageCollector) MakeRoomFor ¶
func (a *AllocGarbageCollector) MakeRoomFor(allocations []*structs.Allocation) error
MakeRoomFor garbage collects enough number of allocations in the terminal state to make room for new allocations
func (*AllocGarbageCollector) MarkForCollection ¶
func (a *AllocGarbageCollector) MarkForCollection(allocID string, ar AllocRunner)
MarkForCollection starts tracking an allocation for Garbage Collection
func (*AllocGarbageCollector) Run ¶
func (a *AllocGarbageCollector) Run()
Run the periodic garbage collector.
func (*AllocGarbageCollector) Stop ¶
func (a *AllocGarbageCollector) Stop()
func (*AllocGarbageCollector) Trigger ¶
func (a *AllocGarbageCollector) Trigger()
Force the garbage collector to run.
type AllocRunner ¶
type AllocRunner interface { Alloc() *structs.Allocation AllocState() *arstate.State Destroy() Shutdown() GetAllocDir() *allocdir.AllocDir IsDestroyed() bool IsMigrating() bool IsWaiting() bool Listener() *cstructs.AllocListener Restore() error Run() StatsReporter() interfaces.AllocStatsReporter Update(*structs.Allocation) WaitCh() <-chan struct{} DestroyCh() <-chan struct{} ShutdownCh() <-chan struct{} Signal(taskName, signal string) error GetTaskEventHandler(taskName string) drivermanager.EventHandler PersistState() error RestartTask(taskName string, taskEvent *structs.TaskEvent) error RestartAll(taskEvent *structs.TaskEvent) error GetTaskExecHandler(taskName string) drivermanager.TaskExecHandler GetTaskDriverCapabilities(taskName string) (*drivers.Capabilities, error) }
AllocRunner is the interface implemented by the core alloc runner. TODO Create via factory to allow testing Client with mock AllocRunners.
type Allocations ¶
type Allocations struct {
// contains filtered or unexported fields
}
Allocations endpoint is used for interacting with client allocations
func NewAllocationsEndpoint ¶
func NewAllocationsEndpoint(c *Client) *Allocations
func (*Allocations) GarbageCollect ¶
func (a *Allocations) GarbageCollect(args *nstructs.AllocSpecificRequest, reply *nstructs.GenericResponse) error
GarbageCollect is used to garbage collect an allocation on a client.
func (*Allocations) GarbageCollectAll ¶
func (a *Allocations) GarbageCollectAll(args *nstructs.NodeSpecificRequest, reply *nstructs.GenericResponse) error
GarbageCollectAll is used to garbage collect all allocations on a client.
func (*Allocations) Restart ¶
func (a *Allocations) Restart(args *nstructs.AllocRestartRequest, reply *nstructs.GenericResponse) error
Restart is used to trigger a restart of an allocation or a subtask on a client.
func (*Allocations) Signal ¶
func (a *Allocations) Signal(args *nstructs.AllocSignalRequest, reply *nstructs.GenericResponse) error
Signal is used to send a signal to an allocation's tasks on a client.
func (*Allocations) Stats ¶
func (a *Allocations) Stats(args *cstructs.AllocStatsRequest, reply *cstructs.AllocStatsResponse) error
Stats is used to collect allocation statistics
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 NewClient ¶
func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulService consulApi.ConsulServiceAPI) (*Client, error)
NewClient is used to create a new client from the given configuration
func TestClient ¶
TestClient creates an in-memory client for testing purposes and returns a cleanup func to shutdown the client and remove the alloc and state dirs.
There is no need to override the AllocDir or StateDir as they are randomized and removed in the returned cleanup function. If they are overridden in the callback then the caller still must run the returned cleanup func.
func (*Client) AllocStateUpdated ¶
func (c *Client) AllocStateUpdated(alloc *structs.Allocation)
AllocStateUpdated asynchronously updates the server with the current state of an allocations and its tasks.
func (*Client) CollectAllAllocs ¶
func (c *Client) CollectAllAllocs()
CollectAllAllocs garbage collects all allocations on a node in the terminal state
func (*Client) CollectAllocation ¶
CollectAllocation garbage collects a single allocation on a node. Returns true if alloc was found and garbage collected; otherwise false.
func (*Client) Datacenter ¶
Datacenter returns the datacenter for the given client
func (*Client) GetAlloc ¶
func (c *Client) GetAlloc(allocID string) (*structs.Allocation, error)
GetAlloc returns an allocation or an error.
func (*Client) GetAllocFS ¶
func (c *Client) GetAllocFS(allocID string) (allocdir.AllocDirFS, error)
GetAllocFS returns the AllocFS interface for the alloc dir of an allocation
func (*Client) GetAllocState ¶
GetAllocState returns a copy of an allocation's state on this client. It returns either an AllocState or an unknown allocation error.
func (*Client) GetAllocStats ¶
func (c *Client) GetAllocStats(allocID string) (interfaces.AllocStatsReporter, error)
func (*Client) GetServers ¶
GetServers returns the list of nomad servers this client is aware of.
func (*Client) GetTaskEventHandler ¶
func (c *Client) GetTaskEventHandler(allocID, taskName string) drivermanager.EventHandler
GetTaskEventHandler returns an event handler for the given allocID and task name
func (*Client) LatestDeviceResourceStats ¶
func (c *Client) LatestDeviceResourceStats(devices []*structs.AllocatedDeviceResource) []*device.DeviceGroupStats
func (*Client) LatestHostStats ¶
HostStats returns all the stats related to a Nomad client
func (*Client) NumAllocs ¶
NumAllocs returns the number of un-GC'd allocs this client has. Used to fulfill the AllocCounter interface for the GC.
func (*Client) Ping ¶
Ping is used to ping a particular server and returns whether it is healthy or a potential error.
func (*Client) RPCMajorVersion ¶
RPCMajorVersion returns the structs.ApiMajorVersion supported by the client.
func (*Client) RPCMinorVersion ¶
RPCMinorVersion returns the structs.ApiMinorVersion supported by the client.
func (*Client) Ready ¶
func (c *Client) Ready() <-chan struct{}
Ready returns a chan that is closed when the client is fully initialized
func (*Client) RemoteStreamingRpcHandler ¶
func (c *Client) RemoteStreamingRpcHandler(method string) (structs.StreamingRpcHandler, error)
RemoteStreamingRpcHandler is used to make a streaming RPC call to a remote server.
func (*Client) ResolveToken ¶
ResolveToken is used to translate an ACL Token Secret ID into an ACL object, nil if ACLs are disabled, or an error.
func (*Client) RestartAllocation ¶
func (*Client) SetServers ¶
SetServers sets a new list of nomad servers to connect to. As long as one server is resolvable no error is returned.
func (*Client) SignalAllocation ¶
SignalAllocation sends a signal to the tasks within an allocation. If the provided task is empty, then every allocation will be signalled. If a task is provided, then only an exactly matching task will be signalled.
func (*Client) Stats ¶
Stats is used to return statistics for debugging and insight for various sub-systems
func (*Client) StatsReporter ¶
func (c *Client) StatsReporter() ClientStatsReporter
StatsReporter exposes the various APIs related resource usage of a Nomad client
func (*Client) StreamingRpcHandler ¶
func (c *Client) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error)
StreamingRpcHandler is used to make a local, client only streaming RPC call.
func (*Client) ValidateMigrateToken ¶
ValidateMigrateToken verifies that a token is for a specific client and allocation, and has been created by a trusted party that has privileged knowledge of the client's secret identifier
type ClientStats ¶
type ClientStats struct {
// contains filtered or unexported fields
}
ClientStats endpoint is used for retrieving stats about a client
func (*ClientStats) Stats ¶
func (s *ClientStats) Stats(args *nstructs.NodeSpecificRequest, reply *structs.ClientStatsResponse) error
Stats is used to retrieve the Clients stats.
type ClientStatsReporter ¶
type ClientStatsReporter interface { // GetAllocStats returns the AllocStatsReporter for the passed allocation. // If it does not exist an error is reported. GetAllocStats(allocID string) (interfaces.AllocStatsReporter, error) // LatestHostStats returns the latest resource usage stats for the host LatestHostStats() *stats.HostStats }
ClientStatsReporter exposes all the APIs related to resource usage of a Nomad Client
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem endpoint is used for accessing the logs and filesystem of allocations.
func NewFileSystemEndpoint ¶
func NewFileSystemEndpoint(c *Client) *FileSystem
func (*FileSystem) List ¶
func (f *FileSystem) List(args *cstructs.FsListRequest, reply *cstructs.FsListResponse) error
List is used to list the contents of an allocation's directory.
func (*FileSystem) Stat ¶
func (f *FileSystem) Stat(args *cstructs.FsStatRequest, reply *cstructs.FsStatResponse) error
Stat is used to stat a file in the allocation's directory.
type FingerprintManager ¶
type FingerprintManager struct {
// contains filtered or unexported fields
}
FingerprintManager runs a client fingerprinters on a continuous basis, and updates the client when the node has changed
func NewFingerprintManager ¶
func NewFingerprintManager( singletonLoader loader.PluginCatalog, getConfig func() *config.Config, node *structs.Node, shutdownCh chan struct{}, updateNodeAttributes func(*fingerprint.FingerprintResponse) *structs.Node, logger log.Logger) *FingerprintManager
NewFingerprintManager is a constructor that creates and returns an instance of FingerprintManager
func (*FingerprintManager) Run ¶
func (fp *FingerprintManager) Run() error
Run starts the process of fingerprinting the node. It does an initial pass, identifying whitelisted and blacklisted fingerprints/drivers. Then, for those which require periotic checking, it starts a periodic process for each.
type GCAlloc ¶
type GCAlloc struct {
// contains filtered or unexported fields
}
GCAlloc wraps an allocation runner and an index enabling it to be used within a PQ
type GCAllocPQImpl ¶
type GCAllocPQImpl []*GCAlloc
func (GCAllocPQImpl) Len ¶
func (pq GCAllocPQImpl) Len() int
func (GCAllocPQImpl) Less ¶
func (pq GCAllocPQImpl) Less(i, j int) bool
func (*GCAllocPQImpl) Pop ¶
func (pq *GCAllocPQImpl) Pop() interface{}
func (*GCAllocPQImpl) Push ¶
func (pq *GCAllocPQImpl) Push(x interface{})
func (GCAllocPQImpl) Swap ¶
func (pq GCAllocPQImpl) Swap(i, j int)
type GCConfig ¶
type GCConfig struct { // MaxAllocs is the maximum number of allocations to track before a GC // is triggered. MaxAllocs int DiskUsageThreshold float64 InodeUsageThreshold float64 Interval time.Duration ReservedDiskMB int ParallelDestroys int }
GCConfig allows changing the behaviour of the garbage collector
type IndexedGCAllocPQ ¶
type IndexedGCAllocPQ struct {
// contains filtered or unexported fields
}
IndexedGCAllocPQ is an indexed PQ which maintains a list of allocation runner based on their termination time.
func NewIndexedGCAllocPQ ¶
func NewIndexedGCAllocPQ() *IndexedGCAllocPQ
func (*IndexedGCAllocPQ) Length ¶
func (i *IndexedGCAllocPQ) Length() int
func (*IndexedGCAllocPQ) Pop ¶
func (i *IndexedGCAllocPQ) Pop() *GCAlloc
func (*IndexedGCAllocPQ) Push ¶
func (i *IndexedGCAllocPQ) Push(allocID string, ar AllocRunner) bool
Push an alloc runner into the GC queue. Returns true if alloc was added, false if the alloc already existed.
func (*IndexedGCAllocPQ) Remove ¶
func (i *IndexedGCAllocPQ) Remove(allocID string) *GCAlloc
Remove alloc from GC. Returns nil if alloc doesn't exist.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package allocwatcher allows blocking until another allocation - whether running locally or remotely - completes and migrates the allocation directory if necessary.
|
Package allocwatcher allows blocking until another allocation - whether running locally or remotely - completes and migrates the allocation directory if necessary. |
Package devicemanager is used to manage device plugins
|
Package devicemanager is used to manage device plugins |
lib
|
|
fifo
Package fifo implements functions to create and open a fifo for inter-process communication in an OS agnostic way.
|
Package fifo implements functions to create and open a fifo for inter-process communication in an OS agnostic way. |
Package servers provides an interface for choosing Servers to communicate with from a Nomad Client perspective.
|
Package servers provides an interface for choosing Servers to communicate with from a Nomad Client perspective. |