Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToMB(bytes int64) int64
- func DeviceToProto(device *DeviceConfig) *proto.Device
- func DevicesToProto(devices []*DeviceConfig) []*proto.Device
- func MountToProto(mount *MountConfig) *proto.Mount
- func MountsToProto(mounts []*MountConfig) []*proto.Mount
- func ResourcesToProto(r *Resources) *proto.Resources
- func Serve(d DriverPlugin, logger hclog.Logger)
- func TaskStatsToProto(stats *TaskResourceUsage) (*proto.TaskStats, error)
- type Capabilities
- type CpuStats
- type DeviceConfig
- type DriverExecTaskNotSupported
- type DriverNetwork
- type DriverPlugin
- type DriverSignalTaskNotSupported
- type ExecTaskResult
- type ExitResult
- type FSIsolation
- type Fingerprint
- type HealthState
- type InternalDriverPlugin
- type LinuxResources
- type MemoryStats
- type MountConfig
- type PluginDriver
- type ResourceUsage
- type Resources
- type TaskConfig
- func (tc *TaskConfig) Copy() *TaskConfig
- func (tc *TaskConfig) DecodeDriverConfig(t interface{}) error
- func (tc *TaskConfig) EncodeConcreteDriverConfig(t interface{}) error
- func (tc *TaskConfig) EncodeDriverConfig(val cty.Value) error
- func (tc *TaskConfig) EnvList() []string
- func (tc *TaskConfig) TaskDir() *allocdir.TaskDir
- type TaskEvent
- type TaskHandle
- type TaskResourceUsage
- type TaskState
- type TaskStatus
Constants ¶
const ( // DriverHealthy is the default health description that should be used // if the driver is nominal DriverHealthy = "Healthy" // Pre09TaskHandleVersion is the version used to identify that the task // handle is from a driver that existed before driver plugins (v0.9). The // driver should take appropriate action to handle the old driver state. Pre09TaskHandleVersion = 0 )
const (
// ApiVersion010 is the initial API version for the device plugins
ApiVersion010 = "v0.1.0"
)
const CheckBufSize = cstructs.CheckBufSize
CheckBufSize is the size of the buffer that is used for job output
Variables ¶
var ( HealthStateUndetected = HealthState("undetected") HealthStateUnhealthy = HealthState("unhealthy") HealthStateHealthy = HealthState("healthy") )
var ( // FSIsolationNone means no isolation. The host filesystem is used. FSIsolationNone = FSIsolation("none") // FSIsolationChroot means the driver will use a chroot on the host // filesystem. FSIsolationChroot = FSIsolation("chroot") // FSIsolationImage means the driver uses an image. FSIsolationImage = FSIsolation("image") )
var CgroupMountEmpty = "Cgroup mount point unavailable"
var DriverRequiresRootMessage = "Driver must run as root"
var DriverStatsNotImplemented = cstructs.DriverStatsNotImplemented
DriverStatsNotImplemented is the error to be returned if a driver doesn't implement stats.
var ErrTaskNotFound = fmt.Errorf("task not found for given id")
var NoCgroupMountMessage = "Failed to discover cgroup mount point"
Functions ¶
func DeviceToProto ¶
func DeviceToProto(device *DeviceConfig) *proto.Device
func DevicesToProto ¶
func DevicesToProto(devices []*DeviceConfig) []*proto.Device
func MountToProto ¶
func MountToProto(mount *MountConfig) *proto.Mount
func MountsToProto ¶
func MountsToProto(mounts []*MountConfig) []*proto.Mount
func ResourcesToProto ¶
func TaskStatsToProto ¶
func TaskStatsToProto(stats *TaskResourceUsage) (*proto.TaskStats, error)
Types ¶
type Capabilities ¶
type Capabilities struct { // SendSignals marks the driver as being able to send signals SendSignals bool // Exec marks the driver as being able to execute arbitrary commands // such as health checks. Used by the ScriptExecutor interface. Exec bool //FSIsolation indicates what kind of filesystem isolation the driver supports. FSIsolation FSIsolation }
type DeviceConfig ¶
func DeviceFromProto ¶
func DeviceFromProto(device *proto.Device) *DeviceConfig
func DevicesFromProto ¶
func DevicesFromProto(devices []*proto.Device) []*DeviceConfig
func (*DeviceConfig) Copy ¶
func (d *DeviceConfig) Copy() *DeviceConfig
type DriverExecTaskNotSupported ¶
type DriverExecTaskNotSupported struct{}
DriverExecTaskNotSupported can be embedded by drivers which don't support the ExecTask RPC. This satisfies the ExecTask func requirement of the DriverPlugin interface.
func (DriverExecTaskNotSupported) ExecTask ¶
func (_ DriverExecTaskNotSupported) ExecTask(taskID, signal string) error
type DriverNetwork ¶
type DriverNetwork struct { // PortMap can be set by drivers to replace ports in environment // variables with driver-specific mappings. PortMap map[string]int // IP is the IP address for the task created by the driver. IP string // AutoAdvertise indicates whether the driver thinks services that // choose to auto-advertise-addresses should use this IP instead of the // host's. eg If a Docker network plugin is used AutoAdvertise bool }
DriverNetwork is the network created by driver's (eg Docker's bridge network) during Prestart.
func (*DriverNetwork) Advertise ¶
func (d *DriverNetwork) Advertise() bool
Advertise returns true if the driver suggests using the IP set. May be called on a nil Network in which case it returns false.
func (*DriverNetwork) Copy ¶
func (d *DriverNetwork) Copy() *DriverNetwork
Copy a DriverNetwork struct. If it is nil, nil is returned.
func (*DriverNetwork) Hash ¶
func (d *DriverNetwork) Hash() []byte
Hash the contents of a DriverNetwork struct to detect changes. If it is nil, an empty slice is returned.
type DriverPlugin ¶
type DriverPlugin interface { base.BasePlugin TaskConfigSchema() (*hclspec.Spec, error) Capabilities() (*Capabilities, error) Fingerprint(context.Context) (<-chan *Fingerprint, error) RecoverTask(*TaskHandle) error StartTask(*TaskConfig) (*TaskHandle, *DriverNetwork, error) WaitTask(ctx context.Context, taskID string) (<-chan *ExitResult, error) StopTask(taskID string, timeout time.Duration, signal string) error DestroyTask(taskID string, force bool) error InspectTask(taskID string) (*TaskStatus, error) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *cstructs.TaskResourceUsage, error) TaskEvents(context.Context) (<-chan *TaskEvent, error) SignalTask(taskID string, signal string) error ExecTask(taskID string, cmd []string, timeout time.Duration) (*ExecTaskResult, error) }
DriverPlugin is the interface with drivers will implement. It is also implemented by a plugin client which proxies the calls to go-plugin. See the proto/driver.proto file for detailed information about each RPC and message structure.
type DriverSignalTaskNotSupported ¶
type DriverSignalTaskNotSupported struct{}
DriverSignalTaskNotSupported can be embedded by drivers which don't support the SignalTask RPC. This satisfies the SignalTask func requirement for the DriverPlugin interface.
func (DriverSignalTaskNotSupported) SignalTask ¶
func (DriverSignalTaskNotSupported) SignalTask(taskID, signal string) error
type ExecTaskResult ¶
type ExecTaskResult struct { Stdout []byte Stderr []byte ExitResult *ExitResult }
type ExitResult ¶
func (*ExitResult) Copy ¶
func (r *ExitResult) Copy() *ExitResult
func (*ExitResult) Successful ¶
func (r *ExitResult) Successful() bool
type FSIsolation ¶
type FSIsolation string
FSIsolation is an enumeration to describe what kind of filesystem isolation a driver supports.
type Fingerprint ¶
type HealthState ¶
type HealthState string
type InternalDriverPlugin ¶
type InternalDriverPlugin interface { // Shutdown allows the plugin to cleanup any running state to avoid leaking // resources. It should not block. Shutdown() }
InternalDriverPlugin is an interface that exposes functions that are only implemented by internal driver plugins.
type LinuxResources ¶
type LinuxResources struct { CPUPeriod int64 CPUQuota int64 MemoryLimitBytes int64 OOMScoreAdj int64 CpusetCPUs string CpusetMems string // PrecentTicks is used to calculate the CPUQuota, currently the docker // driver exposes cpu period and quota through the driver configuration // and thus the calculation for CPUQuota cannot be done on the client. // This is a capatability and should only be used by docker until the docker // specific options are deprecated in favor of exposes CPUPeriod and // CPUQuota at the task resource stanza. PercentTicks float64 }
func (*LinuxResources) Copy ¶
func (r *LinuxResources) Copy() *LinuxResources
type MemoryStats ¶
type MemoryStats = cstructs.MemoryStats
MemoryStats holds memory usage related stats
type MountConfig ¶
func MountFromProto ¶
func MountFromProto(mount *proto.Mount) *MountConfig
func MountsFromProto ¶
func MountsFromProto(mounts []*proto.Mount) []*MountConfig
func (*MountConfig) Copy ¶
func (m *MountConfig) Copy() *MountConfig
type PluginDriver ¶
type PluginDriver struct { plugin.NetRPCUnsupportedPlugin // contains filtered or unexported fields }
PluginDriver wraps a DriverPlugin and implements go-plugins GRPCPlugin interface to expose the the interface over gRPC
func NewDriverPlugin ¶
func NewDriverPlugin(d DriverPlugin, logger hclog.Logger) *PluginDriver
func (*PluginDriver) GRPCClient ¶
func (p *PluginDriver) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)
func (*PluginDriver) GRPCServer ¶
func (p *PluginDriver) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error
type ResourceUsage ¶
type ResourceUsage = cstructs.ResourceUsage
ResourceUsage holds information related to cpu and memory stats
type Resources ¶
type Resources struct { NomadResources *structs.AllocatedTaskResources LinuxResources *LinuxResources }
func ResourcesFromProto ¶
type TaskConfig ¶
type TaskConfig struct { ID string JobName string TaskGroupName string Name string Env map[string]string DeviceEnv map[string]string Resources *Resources Devices []*DeviceConfig Mounts []*MountConfig User string AllocDir string StdoutPath string StderrPath string AllocID string // contains filtered or unexported fields }
func (*TaskConfig) Copy ¶
func (tc *TaskConfig) Copy() *TaskConfig
func (*TaskConfig) DecodeDriverConfig ¶
func (tc *TaskConfig) DecodeDriverConfig(t interface{}) error
func (*TaskConfig) EncodeConcreteDriverConfig ¶
func (tc *TaskConfig) EncodeConcreteDriverConfig(t interface{}) error
func (*TaskConfig) EncodeDriverConfig ¶
func (tc *TaskConfig) EncodeDriverConfig(val cty.Value) error
func (*TaskConfig) EnvList ¶
func (tc *TaskConfig) EnvList() []string
func (*TaskConfig) TaskDir ¶
func (tc *TaskConfig) TaskDir() *allocdir.TaskDir
type TaskHandle ¶
type TaskHandle struct { // Version is set by the driver an allows it to handle upgrading from // an older DriverState struct. Prior to 0.9 the only state stored for // driver was the reattach config for the executor. To allow upgrading to // 0.9, Version 0 is handled as if it is the json encoded reattach config. Version int Config *TaskConfig State TaskState DriverState []byte }
TaskHandle is the state shared between a driver and the client. It is returned to the client after starting the task and used for recovery of tasks during a driver restart.
func NewTaskHandle ¶
func NewTaskHandle(version int) *TaskHandle
func (*TaskHandle) Copy ¶
func (h *TaskHandle) Copy() *TaskHandle
func (*TaskHandle) GetDriverState ¶
func (h *TaskHandle) GetDriverState(v interface{}) error
func (*TaskHandle) SetDriverState ¶
func (h *TaskHandle) SetDriverState(v interface{}) error
type TaskResourceUsage ¶
type TaskResourceUsage = cstructs.TaskResourceUsage
TaskResourceUsage holds aggregated resource usage of all processes in a Task and the resource usage of the individual pids
func TaskStatsFromProto ¶
func TaskStatsFromProto(pb *proto.TaskStats) (*TaskResourceUsage, error)