Documentation ¶
Index ¶
- Variables
- func CalculateCPUPercent(newSample, oldSample, newTotal, oldTotal uint64, cores int) float64
- func NewPlugin(logger hclog.Logger) drivers.DriverPlugin
- type CHContainer
- type CHMount
- type Config
- type DriverPlugin
- func (d *DriverPlugin) Capabilities() (*drivers.Capabilities, error)
- func (d *DriverPlugin) ConfigSchema() (*hclspec.Spec, error)
- func (d *DriverPlugin) DestroyTask(taskID string, force bool) error
- func (d *DriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
- func (d *DriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
- func (d *DriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
- func (d *DriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
- func (d *DriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
- func (d *DriverPlugin) SetConfig(cfg *base.Config) error
- func (d *DriverPlugin) SignalTask(taskID string, signal string) error
- func (d *DriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
- func (d *DriverPlugin) StopTask(taskID string, timeout time.Duration, signal string) error
- func (d *DriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
- func (d *DriverPlugin) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)
- func (d *DriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
- func (d *DriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
- type RegistryAuth
- type TaskConfig
- type TaskState
Constants ¶
This section is empty.
Variables ¶
var ( DockerMeasuredCPUStats = []string{"Throttled Periods", "Throttled Time", "Percent"} // cgroup-v2 only exposes a subset of memory stats DockerCgroupV1MeasuredMemStats = []string{"RSS", "Cache", "Swap", "Usage", "Max Usage"} )
Functions ¶
func CalculateCPUPercent ¶ added in v0.0.5
func NewPlugin ¶
func NewPlugin(logger hclog.Logger) drivers.DriverPlugin
NewPlugin returns a new example driver plugin
Types ¶
type CHContainer ¶ added in v0.0.4
type CHContainer struct { CreateBody container.ContainerCreateCreatedBody Mounts []CHMount }
type DriverPlugin ¶ added in v0.0.4
type DriverPlugin struct {
// contains filtered or unexported fields
}
DriverPlugin is an example driver plugin. When provisioned in a job,
func (*DriverPlugin) Capabilities ¶ added in v0.0.4
func (d *DriverPlugin) Capabilities() (*drivers.Capabilities, error)
Capabilities returns the features supported by the driver.
func (*DriverPlugin) ConfigSchema ¶ added in v0.0.4
func (d *DriverPlugin) ConfigSchema() (*hclspec.Spec, error)
ConfigSchema returns the plugin configuration schema.
func (*DriverPlugin) DestroyTask ¶ added in v0.0.4
func (d *DriverPlugin) DestroyTask(taskID string, force bool) error
DestroyTask cleans up and removes a task that has terminated.
func (*DriverPlugin) ExecTask ¶ added in v0.0.4
func (d *DriverPlugin) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)
ExecTask returns the result of executing the given command inside a task. This is an optional capability.
func (*DriverPlugin) Fingerprint ¶ added in v0.0.4
func (d *DriverPlugin) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)
Fingerprint returns a channel that will be used to send health information and other driver specific node attributes.
func (*DriverPlugin) InspectTask ¶ added in v0.0.4
func (d *DriverPlugin) InspectTask(taskID string) (*drivers.TaskStatus, error)
InspectTask returns detailed status information for the referenced taskID.
func (*DriverPlugin) PluginInfo ¶ added in v0.0.4
func (d *DriverPlugin) PluginInfo() (*base.PluginInfoResponse, error)
PluginInfo returns information describing the plugin.
func (*DriverPlugin) RecoverTask ¶ added in v0.0.4
func (d *DriverPlugin) RecoverTask(handle *drivers.TaskHandle) error
RecoverTask recreates the in-memory state of a task from a TaskHandle.
func (*DriverPlugin) SetConfig ¶ added in v0.0.4
func (d *DriverPlugin) SetConfig(cfg *base.Config) error
SetConfig is called by the client to pass the configuration for the plugin.
func (*DriverPlugin) SignalTask ¶ added in v0.0.4
func (d *DriverPlugin) SignalTask(taskID string, signal string) error
SignalTask forwards a signal to a task. This is an optional capability.
func (*DriverPlugin) StartTask ¶ added in v0.0.4
func (d *DriverPlugin) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error)
StartTask returns a task handle and a driver network if necessary.
func (*DriverPlugin) StopTask ¶ added in v0.0.4
StopTask stops a running task with the given signal and within the timeout window.
func (*DriverPlugin) TaskConfigSchema ¶ added in v0.0.4
func (d *DriverPlugin) TaskConfigSchema() (*hclspec.Spec, error)
TaskConfigSchema returns the HCL schema for the configuration of a task.
func (*DriverPlugin) TaskEvents ¶ added in v0.0.4
TaskEvents returns a channel that the plugin can use to emit task related events.
func (*DriverPlugin) TaskStats ¶ added in v0.0.4
func (d *DriverPlugin) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)
TaskStats returns a channel which the driver should send stats to at the given interval.
func (*DriverPlugin) WaitTask ¶ added in v0.0.4
func (d *DriverPlugin) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)
WaitTask returns a channel used to notify Nomad when a task exits.
type RegistryAuth ¶
RegistryAuth info to pull image from registry.
type TaskConfig ¶
type TaskConfig struct { Image string `codec:"image"` Command string `codec:"command"` Auth RegistryAuth `codec:"auth"` Ports []string `codec:"ports"` }
TaskConfig contains configuration information for a task that runs with this plugin
type TaskState ¶
type TaskState struct { ReattachConfig *structs.ReattachConfig TaskConfig *drivers.TaskConfig StartedAt time.Time // TODO: add any extra important values that must be persisted in order // to restore a task. // // The plugin keeps track of its running tasks in a in-memory data // structure. If the plugin crashes, this data will be lost, so Nomad // will respawn a new instance of the plugin and try to restore its // in-memory representation of the running tasks using the RecoverTask() // method below. Pid int ContainerID string CHContainer CHContainer // contains filtered or unexported fields }
TaskState is the runtime state which is encoded in the handle returned to Nomad client. This information is needed to rebuild the task state and handler during recovery.