worker

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerManager

type ContainerManager interface {
	CreateContainer(ctx context.Context, cmd []string, wfID string, action *proto.WorkflowAction, captureLogs, privileged bool) (string, error)
	StartContainer(ctx context.Context, id string) error
	WaitForContainer(ctx context.Context, id string) (proto.State, error)
	WaitForFailedContainer(ctx context.Context, id string, failedActionStatus chan proto.State)
	RemoveContainer(ctx context.Context, id string) error
	PullImage(ctx context.Context, image string) error
}

ContainerManager manages linux containers for Tinkerbell workers.

func NewContainerManager

func NewContainerManager(logger logr.Logger, cli DockerClient, registryDetails RegistryConnDetails) ContainerManager

NewContainerManager returns a new container manager.

type DockerClient

type DockerClient interface {
	client.ImageAPIClient
	client.ContainerAPIClient
}

DockerClient is a subset of the interfaces implemented by docker's client.Client.

type DockerLogCapturer

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

DockerLogCapturer is a LogCapturer that can stream docker container logs to an io.Writer.

func NewDockerLogCapturer

func NewDockerLogCapturer(cli client.ContainerAPIClient, logger logr.Logger, writer io.Writer) *DockerLogCapturer

NewDockerLogCapturer returns a LogCapturer that can stream container logs to a given writer.

func (*DockerLogCapturer) CaptureLogs

func (l *DockerLogCapturer) CaptureLogs(ctx context.Context, id string)

CaptureLogs streams container logs to the capturer's writer.

type ImagePullStatus

type ImagePullStatus struct {
	Status         string `json:"status"`
	Error          string `json:"error"`
	Progress       string `json:"progress"`
	ProgressDetail struct {
		Current int `json:"current"`
		Total   int `json:"total"`
	} `json:"progressDetail"`
}

ImagePullStatus is the status of the downloaded Image chunk.

type LogCapturer

type LogCapturer interface {
	CaptureLogs(ctx context.Context, containerID string)
}

LogCapturer emits container logs.

type Option

type Option func(*Worker)

Option is a type for modifying a worker.

func WithDataDir

func WithDataDir(dir string) Option

WithDataDir changes the default directory for a worker.

func WithLogCapture

func WithLogCapture(capture bool) Option

WithLogCapture enables capture of container logs.

func WithMaxFileSize

func WithMaxFileSize(maxSize int64) Option

WithMaxFileSize changes the max file size for a worker.

func WithPrivileged

func WithPrivileged(privileged bool) Option

WithPrivileged enables containers to be privileged.

func WithRetries

func WithRetries(interval time.Duration, retries int) Option

WithRetries adds custom retries to a worker.

type RegistryConnDetails

type RegistryConnDetails struct {
	Registry string
	Username string
	Password string
}

RegistryConnDetails are the connection details for accessing a Docker registry.

type Worker

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

Worker details provide all the context needed to run workflows.

func NewWorker

func NewWorker(
	workerID string,
	tinkClient proto.WorkflowServiceClient,
	containerManager ContainerManager,
	logCapturer LogCapturer,
	logger logr.Logger,
	opts ...Option,
) *Worker

NewWorker creates a new Worker, creating a new Docker registry client.

func (*Worker) ProcessWorkflowActions

func (w *Worker) ProcessWorkflowActions(ctx context.Context) error

ProcessWorkflowActions gets all Workflow contexts and processes their actions.

type WorkflowMetadata

type WorkflowMetadata struct {
	WorkerID  string    `json:"workerID"`
	Action    string    `json:"actionName"`
	Task      string    `json:"taskName"`
	UpdatedAt time.Time `json:"updatedAt"`
	SHA       string    `json:"sha256"`
}

WorkflowMetadata is the metadata related to workflow data.

Jump to

Keyboard shortcuts

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