runner

package
v0.0.0-...-06858c0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SIGQUIT is the character that causes a tty to send the SIGQUIT signal to the controlled process.
	SIGQUIT = 0x1c
)

Variables

View Source
var (
	ErrNoRunnersAvailable = errors.New("no runners available for this execution environment")
	ErrRunnerNotFound     = errors.New("no runner found with this id")
)
View Source
var (
	ErrUnknownExecution                    = errors.New("unknown execution")
	ErrInvalidPortMapping                  = errors.New("invalid port mapping")
	ErrFileCopyFailed                      = errors.New("file copy failed")
	ErrFileNotFound                        = errors.New("file not found or insufficient permissions")
	ErrLocalDestruction      DestroyReason = nomad.ErrLocalDestruction
	ErrOOMKilled             DestroyReason = nomad.ErrOOMKilled
	ErrDestroyedByAPIRequest DestroyReason = errors.New("the client wants to stop the runner")
	ErrCannotStopExecution   DestroyReason = errors.New("the execution did not stop after SIGQUIT")
	ErrDestroyedAndReplaced  DestroyReason = fmt.Errorf("the runner will be destroyed and replaced: %w", ErrLocalDestruction)
	ErrEnvironmentUpdated    DestroyReason = errors.New("the environment will be destroyed and updated")
)
View Source
var ErrUnknownExecutionEnvironment = errors.New("execution environment not found")
View Source
var ErrWrongMessageType = errors.New("received message that is not a text message")

Functions

func MonitorEnvironmentID

func MonitorEnvironmentID[T any](id dto.EnvironmentID) storage.WriteCallback[T]

MonitorEnvironmentID adds the passed environment id to the monitoring Point p.

func MonitorRunnersEnvironmentID

func MonitorRunnersEnvironmentID(p *write.Point, e Runner, _ storage.EventType)

MonitorRunnersEnvironmentID passes the id of the environment e into the monitoring Point p.

func NewContext

func NewContext(ctx context.Context, runner Runner) context.Context

NewContext creates a context containing a runner.

Types

type AWSFunctionWorkload

type AWSFunctionWorkload struct {
	InactivityTimer
	// contains filtered or unexported fields
}

AWSFunctionWorkload is an abstraction to build a request to an AWS Lambda Function. It is not persisted on a Poseidon restart. The InactivityTimer is used actively. It stops listening to the Lambda function. AWS terminates the Lambda Function after the [Globals.Function.Timeout](deploy/aws/template.yaml).

func NewAWSFunctionWorkload

func NewAWSFunctionWorkload(
	environment ExecutionEnvironment, onDestroy DestroyRunnerHandler,
) (*AWSFunctionWorkload, error)

NewAWSFunctionWorkload creates a new AWSFunctionWorkload with the provided id.

func (*AWSFunctionWorkload) Destroy

func (w *AWSFunctionWorkload) Destroy(_ DestroyReason) error

func (*AWSFunctionWorkload) Environment

func (w *AWSFunctionWorkload) Environment() dto.EnvironmentID

func (*AWSFunctionWorkload) ExecuteInteractively

func (w *AWSFunctionWorkload) ExecuteInteractively(
	_ context.Context, id string, _ io.ReadWriter, stdout, stderr io.Writer) (
	<-chan ExitInfo, context.CancelFunc, error,
)

ExecuteInteractively runs the execution request in an AWS function. It should be further improved by using the passed context to handle lost connections.

func (*AWSFunctionWorkload) ExecutionExists

func (w *AWSFunctionWorkload) ExecutionExists(id string) bool

func (*AWSFunctionWorkload) GetFileContent

func (w *AWSFunctionWorkload) GetFileContent(_ context.Context, _ string, _ http.ResponseWriter, _ bool) error

GetFileContent is currently not supported with this aws serverless function. This is because the function execution ends with the termination of the workload code. So an on-demand file streaming after the termination is not possible. Also, we do not want to copy all files.

func (*AWSFunctionWorkload) ID

func (w *AWSFunctionWorkload) ID() string

func (*AWSFunctionWorkload) ListFileSystem

func (w *AWSFunctionWorkload) ListFileSystem(_ context.Context, _ string, _ bool, _ io.Writer, _ bool) error

ListFileSystem is currently not supported with this aws serverless function. This is because the function execution ends with the termination of the workload code. So an on-demand file system listing after the termination is not possible. Also, we do not want to copy all files.

func (*AWSFunctionWorkload) MappedPorts

func (w *AWSFunctionWorkload) MappedPorts() []*dto.MappedPort

func (*AWSFunctionWorkload) StoreExecution

func (w *AWSFunctionWorkload) StoreExecution(id string, request *dto.ExecutionRequest)

func (*AWSFunctionWorkload) UpdateFileSystem

func (w *AWSFunctionWorkload) UpdateFileSystem(_ context.Context, request *dto.UpdateFileSystemRequest) error

UpdateFileSystem copies Files into the executor. Current limitation: No files can be deleted apart from the previously added files. Future Work: Deduplication of the file systems, as the largest workload is likely to be used by additional CSV files or similar, which are the same for many executions.

type AWSRunnerManager

type AWSRunnerManager struct {
	*AbstractManager
}

func NewAWSRunnerManager

func NewAWSRunnerManager(ctx context.Context) *AWSRunnerManager

NewAWSRunnerManager creates a new runner manager that keeps track of all runners at AWS.

func (AWSRunnerManager) Claim

func (a AWSRunnerManager) Claim(id dto.EnvironmentID, duration int) (Runner, error)

func (AWSRunnerManager) Return

func (a AWSRunnerManager) Return(r Runner) error

type AbstractManager

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

AbstractManager is used to have a fallback runner manager in the chain of responsibility following the null object pattern. Remember all functions that can call the NextHandler should call it (See AccessorHandler).

func NewAbstractManager

func NewAbstractManager(ctx context.Context) *AbstractManager

NewAbstractManager creates a new abstract runner manager that keeps track of all runners of one kind. Since this manager is currently directly bound to the lifespan of Poseidon, it does not need a context cancel.

func (*AbstractManager) Claim

func (n *AbstractManager) Claim(_ dto.EnvironmentID, _ int) (Runner, error)

func (*AbstractManager) DeleteEnvironment

func (n *AbstractManager) DeleteEnvironment(id dto.EnvironmentID)

func (*AbstractManager) EnvironmentStatistics

func (*AbstractManager) Get

func (n *AbstractManager) Get(runnerID string) (Runner, error)

func (*AbstractManager) GetEnvironment

func (n *AbstractManager) GetEnvironment(id dto.EnvironmentID) (ExecutionEnvironment, bool)

func (*AbstractManager) HasNextHandler

func (n *AbstractManager) HasNextHandler() bool

func (*AbstractManager) ListEnvironments

func (n *AbstractManager) ListEnvironments() []ExecutionEnvironment

func (*AbstractManager) NextHandler

func (n *AbstractManager) NextHandler() AccessorHandler

func (*AbstractManager) Return

func (n *AbstractManager) Return(_ Runner) error

func (*AbstractManager) SetNextHandler

func (n *AbstractManager) SetNextHandler(next AccessorHandler)

func (*AbstractManager) StoreEnvironment

func (n *AbstractManager) StoreEnvironment(environment ExecutionEnvironment)

type Accessor

type Accessor interface {
	// Claim returns a new runner. The runner is deleted after duration seconds if duration is not 0.
	// It makes sure that the runner is not in use yet and returns an error if no runner could be provided.
	Claim(id dto.EnvironmentID, duration int) (Runner, error)

	// Get returns the used runner with the given runnerId.
	// If no runner with the given runnerId is currently used, it returns an error.
	Get(runnerID string) (Runner, error)

	// Return signals that the runner is no longer used by the caller and can be claimed by someone else.
	// The runner is deleted or cleaned up for reuse depending on the used executor.
	Return(r Runner) error
}

Accessor manages the lifecycle of Runner.

type AccessorHandler

type AccessorHandler interface {
	Accessor
	SetNextHandler(m AccessorHandler)
	NextHandler() AccessorHandler
	HasNextHandler() bool
}

AccessorHandler is one handler in the chain of responsibility of runner accessors. Each runner accessor can handle different requests.

type DestroyReason

type DestroyReason error

DestroyReason specifies errors that are expected as reason for destroying a runner.

var (
	ErrRunnerInactivityTimeout DestroyReason = errors.New("runner inactivity timeout exceeded")
	ErrExecutionTimeout                      = errors.New("execution timeout exceeded")
)

type DestroyRunnerHandler

type DestroyRunnerHandler = func(r Runner) error

type EnvironmentAccessor

type EnvironmentAccessor interface {
	// ListEnvironments returns all execution environments known by Poseidon.
	ListEnvironments() []ExecutionEnvironment

	// GetEnvironment returns the details of the requested environment.
	// Iff the requested environment is not stored it returns false.
	GetEnvironment(id dto.EnvironmentID) (ExecutionEnvironment, bool)

	// StoreEnvironment stores the environment in Poseidons memory.
	StoreEnvironment(environment ExecutionEnvironment)

	// DeleteEnvironment removes the specified execution environment in Poseidons memory.
	// It does nothing if the specified environment can not be found.
	DeleteEnvironment(id dto.EnvironmentID)

	// EnvironmentStatistics returns statistical data for each execution environment.
	EnvironmentStatistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData
}

EnvironmentAccessor provides access to the stored environments.

type ExecutionEnvironment

ExecutionEnvironment are groups of runner that share the configuration stored in the environment.

type ExecutionEnvironmentMock

type ExecutionEnvironmentMock struct {
	mock.Mock
}

ExecutionEnvironmentMock is an autogenerated mock type for the ExecutionEnvironment type

func NewExecutionEnvironmentMock

func NewExecutionEnvironmentMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *ExecutionEnvironmentMock

NewExecutionEnvironmentMock creates a new instance of ExecutionEnvironmentMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*ExecutionEnvironmentMock) AddRunner

func (_m *ExecutionEnvironmentMock) AddRunner(r Runner)

AddRunner provides a mock function with given fields: r

func (*ExecutionEnvironmentMock) ApplyPrewarmingPoolSize

func (_m *ExecutionEnvironmentMock) ApplyPrewarmingPoolSize() error

ApplyPrewarmingPoolSize provides a mock function with given fields:

func (*ExecutionEnvironmentMock) CPULimit

func (_m *ExecutionEnvironmentMock) CPULimit() uint

CPULimit provides a mock function with given fields:

func (*ExecutionEnvironmentMock) Delete

func (_m *ExecutionEnvironmentMock) Delete(reason DestroyReason) error

Delete provides a mock function with given fields: reason

func (*ExecutionEnvironmentMock) DeleteRunner

func (_m *ExecutionEnvironmentMock) DeleteRunner(id string) (Runner, bool)

DeleteRunner provides a mock function with given fields: id

func (*ExecutionEnvironmentMock) ID

ID provides a mock function with given fields:

func (*ExecutionEnvironmentMock) IdleRunnerCount

func (_m *ExecutionEnvironmentMock) IdleRunnerCount() uint

IdleRunnerCount provides a mock function with given fields:

func (*ExecutionEnvironmentMock) Image

func (_m *ExecutionEnvironmentMock) Image() string

Image provides a mock function with given fields:

func (*ExecutionEnvironmentMock) MarshalJSON

func (_m *ExecutionEnvironmentMock) MarshalJSON() ([]byte, error)

MarshalJSON provides a mock function with given fields:

func (*ExecutionEnvironmentMock) MemoryLimit

func (_m *ExecutionEnvironmentMock) MemoryLimit() uint

MemoryLimit provides a mock function with given fields:

func (*ExecutionEnvironmentMock) NetworkAccess

func (_m *ExecutionEnvironmentMock) NetworkAccess() (bool, []uint16)

NetworkAccess provides a mock function with given fields:

func (*ExecutionEnvironmentMock) PrewarmingPoolSize

func (_m *ExecutionEnvironmentMock) PrewarmingPoolSize() uint

PrewarmingPoolSize provides a mock function with given fields:

func (*ExecutionEnvironmentMock) Register

func (_m *ExecutionEnvironmentMock) Register() error

Register provides a mock function with given fields:

func (*ExecutionEnvironmentMock) Sample

func (_m *ExecutionEnvironmentMock) Sample() (Runner, bool)

Sample provides a mock function with given fields:

func (*ExecutionEnvironmentMock) SetCPULimit

func (_m *ExecutionEnvironmentMock) SetCPULimit(limit uint) error

SetCPULimit provides a mock function with given fields: limit

func (*ExecutionEnvironmentMock) SetConfigFrom

func (_m *ExecutionEnvironmentMock) SetConfigFrom(environment ExecutionEnvironment)

SetConfigFrom provides a mock function with given fields: environment

func (*ExecutionEnvironmentMock) SetID

SetID provides a mock function with given fields: id

func (*ExecutionEnvironmentMock) SetImage

func (_m *ExecutionEnvironmentMock) SetImage(image string)

SetImage provides a mock function with given fields: image

func (*ExecutionEnvironmentMock) SetMemoryLimit

func (_m *ExecutionEnvironmentMock) SetMemoryLimit(limit uint) error

SetMemoryLimit provides a mock function with given fields: limit

func (*ExecutionEnvironmentMock) SetNetworkAccess

func (_m *ExecutionEnvironmentMock) SetNetworkAccess(allow bool, ports []uint16)

SetNetworkAccess provides a mock function with given fields: allow, ports

func (*ExecutionEnvironmentMock) SetPrewarmingPoolSize

func (_m *ExecutionEnvironmentMock) SetPrewarmingPoolSize(count uint)

SetPrewarmingPoolSize provides a mock function with given fields: count

type ExitInfo

type ExitInfo struct {
	Code uint8
	Err  error
}

type ExternalExecutionEnvironment

type ExternalExecutionEnvironment interface {
	// Register saves this environment at the executor.
	Register() error
	// ApplyPrewarmingPoolSize creates idle runners according to the PrewarmingPoolSize.
	ApplyPrewarmingPoolSize() error
	// Delete removes this environment and all it's runner from the executor and Poseidon itself.
	// Iff local the environment is just removed from Poseidon without external escalation.
	Delete(reason DestroyReason) error

	// Sample returns and removes an arbitrary available runner.
	// ok is true iff a runner was returned.
	Sample() (r Runner, ok bool)
	// DeleteRunner removes an idle runner from the environment and returns it.
	// This function handles only the environment. The runner has to be destroyed separately.
	// ok is true iff the runner was found (and deleted).
	DeleteRunner(id string) (r Runner, ok bool)
}

ExternalExecutionEnvironment defines the functionalities with impact on external executors.

type InactivityTimer

type InactivityTimer interface {
	// SetupTimeout starts the timeout after a runner gets deleted.
	SetupTimeout(duration time.Duration)

	// ResetTimeout resets the current timeout so that the runner gets deleted after the time set in Setup from now.
	// It does not make an already expired timer run again.
	ResetTimeout()

	// StopTimeout stops the timeout but does not remove the runner.
	StopTimeout()

	// TimeoutPassed returns true if the timeout expired and false otherwise.
	TimeoutPassed() bool
}

InactivityTimer is a wrapper around a timer that is used to delete a Runner after some time of inactivity.

func NewInactivityTimer

func NewInactivityTimer(runner Runner, onDestroy DestroyRunnerHandler) InactivityTimer

type InactivityTimerImplementation

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

func (*InactivityTimerImplementation) ResetTimeout

func (t *InactivityTimerImplementation) ResetTimeout()

func (*InactivityTimerImplementation) SetupTimeout

func (t *InactivityTimerImplementation) SetupTimeout(duration time.Duration)

func (*InactivityTimerImplementation) StopTimeout

func (t *InactivityTimerImplementation) StopTimeout()

func (*InactivityTimerImplementation) TimeoutPassed

func (t *InactivityTimerImplementation) TimeoutPassed() bool

type InactivityTimerMock

type InactivityTimerMock struct {
	mock.Mock
}

InactivityTimerMock is an autogenerated mock type for the InactivityTimer type

func (*InactivityTimerMock) ResetTimeout

func (_m *InactivityTimerMock) ResetTimeout()

ResetTimeout provides a mock function with given fields:

func (*InactivityTimerMock) SetupTimeout

func (_m *InactivityTimerMock) SetupTimeout(duration time.Duration)

SetupTimeout provides a mock function with given fields: duration

func (*InactivityTimerMock) StopTimeout

func (_m *InactivityTimerMock) StopTimeout()

StopTimeout provides a mock function with given fields:

func (*InactivityTimerMock) TimeoutPassed

func (_m *InactivityTimerMock) TimeoutPassed() bool

TimeoutPassed provides a mock function with given fields:

type Manager

type Manager interface {
	EnvironmentAccessor
	AccessorHandler
}

Manager keeps track of the used and unused runners of all execution environments in order to provide unused runners to new clients and ensure no runner is used twice.

type ManagerMock

type ManagerMock struct {
	mock.Mock
}

ManagerMock is an autogenerated mock type for the Manager type

func (*ManagerMock) Claim

func (_m *ManagerMock) Claim(id dto.EnvironmentID, duration int) (Runner, error)

Claim provides a mock function with given fields: id, duration

func (*ManagerMock) DeleteEnvironment

func (_m *ManagerMock) DeleteEnvironment(id dto.EnvironmentID)

DeleteEnvironment provides a mock function with given fields: id

func (*ManagerMock) EnvironmentStatistics

func (_m *ManagerMock) EnvironmentStatistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData

EnvironmentStatistics provides a mock function with given fields:

func (*ManagerMock) Get

func (_m *ManagerMock) Get(runnerID string) (Runner, error)

Get provides a mock function with given fields: runnerID

func (*ManagerMock) GetEnvironment

func (_m *ManagerMock) GetEnvironment(id dto.EnvironmentID) (ExecutionEnvironment, bool)

GetEnvironment provides a mock function with given fields: id

func (*ManagerMock) HasNextHandler

func (_m *ManagerMock) HasNextHandler() bool

HasNextHandler provides a mock function with given fields:

func (*ManagerMock) ListEnvironments

func (_m *ManagerMock) ListEnvironments() []ExecutionEnvironment

ListEnvironments provides a mock function with given fields:

func (*ManagerMock) Load

func (_m *ManagerMock) Load()

Load provides a mock function with given fields:

func (*ManagerMock) NextHandler

func (_m *ManagerMock) NextHandler() AccessorHandler

NextHandler provides a mock function with given fields:

func (*ManagerMock) Return

func (_m *ManagerMock) Return(r Runner) error

Return provides a mock function with given fields: r

func (*ManagerMock) SetNextHandler

func (_m *ManagerMock) SetNextHandler(m AccessorHandler)

SetNextHandler provides a mock function with given fields: m

func (*ManagerMock) StoreEnvironment

func (_m *ManagerMock) StoreEnvironment(environment ExecutionEnvironment)

StoreEnvironment provides a mock function with given fields: environment

type NomadJob

type NomadJob struct {
	InactivityTimer
	// contains filtered or unexported fields
}

NomadJob is an abstraction to communicate with Nomad environments.

func NewNomadJob

func NewNomadJob(ctx context.Context, jobID string, portMappings []nomadApi.PortMapping,
	apiClient nomad.ExecutorAPI, onDestroy DestroyRunnerHandler,
) *NomadJob

NewNomadJob creates a new NomadJob with the provided id. The InactivityTimer is used actively. It executes onDestroy when it has expired. The InactivityTimer is persisted in Nomad by the runner manager's Claim Function. The passed context does not define the lifespan of the Runner, instead use Destroy.

func (*NomadJob) Destroy

func (r *NomadJob) Destroy(reason DestroyReason) (err error)

func (*NomadJob) Environment

func (r *NomadJob) Environment() dto.EnvironmentID

func (*NomadJob) ExecuteInteractively

func (r *NomadJob) ExecuteInteractively(
	requestCtx context.Context,
	id string,
	stdin io.ReadWriter,
	stdout, stderr io.Writer,
) (<-chan ExitInfo, context.CancelFunc, error)

func (*NomadJob) ExecutionExists

func (r *NomadJob) ExecutionExists(id string) bool

func (*NomadJob) GetFileContent

func (r *NomadJob) GetFileContent(
	requestCtx context.Context, path string, content http.ResponseWriter, privilegedExecution bool,
) error

func (*NomadJob) ID

func (r *NomadJob) ID() string

func (*NomadJob) ListFileSystem

func (r *NomadJob) ListFileSystem(
	requestCtx context.Context, path string, recursive bool, content io.Writer, privilegedExecution bool,
) error

func (*NomadJob) MappedPorts

func (r *NomadJob) MappedPorts() []*dto.MappedPort

func (*NomadJob) MarshalJSON

func (r *NomadJob) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface. This exports private attributes like the id too.

func (*NomadJob) StoreExecution

func (r *NomadJob) StoreExecution(id string, request *dto.ExecutionRequest)

func (*NomadJob) UpdateFileSystem

func (r *NomadJob) UpdateFileSystem(requestCtx context.Context, copyRequest *dto.UpdateFileSystemRequest) error

func (*NomadJob) UpdateMappedPorts

func (r *NomadJob) UpdateMappedPorts(ports []*dto.MappedPort) error

UpdateMappedPorts changes the local information about the runner's port mapping.

type NomadRunnerManager

type NomadRunnerManager struct {
	*AbstractManager
	// contains filtered or unexported fields
}

func NewNomadRunnerManager

func NewNomadRunnerManager(ctx context.Context, apiClient nomad.ExecutorAPI) *NomadRunnerManager

NewNomadRunnerManager creates a new runner manager that keeps track of all runners. KeepRunnersSynced has to be started separately.

func (*NomadRunnerManager) Claim

func (m *NomadRunnerManager) Claim(environmentID dto.EnvironmentID, duration int) (Runner, error)

func (*NomadRunnerManager) DeleteEnvironment

func (m *NomadRunnerManager) DeleteEnvironment(id dto.EnvironmentID)

func (*NomadRunnerManager) Load

func (m *NomadRunnerManager) Load(ctx context.Context)

Load recovers all runners for all existing environments.

func (*NomadRunnerManager) Return

func (m *NomadRunnerManager) Return(r Runner) error

func (*NomadRunnerManager) StoreEnvironment

func (m *NomadRunnerManager) StoreEnvironment(environment ExecutionEnvironment)

func (*NomadRunnerManager) SynchronizeRunners

func (m *NomadRunnerManager) SynchronizeRunners(ctx context.Context) error

SynchronizeRunners connect once (without retry) to Nomad to receive status updates regarding runners.

type ReadableExecutionEnvironment

type ReadableExecutionEnvironment interface {
	// ID returns the id of the environment.
	ID() dto.EnvironmentID

	// PrewarmingPoolSize sets the number of idle runner of this environment that should be prewarmed.
	PrewarmingPoolSize() uint

	// CPULimit sets the share of cpu that a runner should receive at minimum.
	CPULimit() uint

	// MemoryLimit sets the amount of memory that should be available for each runner.
	MemoryLimit() uint

	// Image sets the image of the runner, e.g. Docker image.
	Image() string

	// NetworkAccess sets if a runner should have network access and if ports should be mapped.
	NetworkAccess() (bool, []uint16)

	// IdleRunnerCount returns the number of idle runners of the environment.
	IdleRunnerCount() uint
}

ReadableExecutionEnvironment defines structs that can return the attributes of an Execution Environment.

type Runner

type Runner interface {
	InactivityTimer

	// ID returns the id of the runner.
	ID() string

	// Environment returns the id of the Environment to which the Runner belongs.
	Environment() dto.EnvironmentID

	// MappedPorts returns the mapped ports of the runner.
	MappedPorts() []*dto.MappedPort

	// StoreExecution adds a new execution to the runner that can then be executed using ExecuteInteractively.
	StoreExecution(id string, executionRequest *dto.ExecutionRequest)

	// ExecutionExists returns whether the execution with the given id is already stored.
	ExecutionExists(id string) bool

	// ExecuteInteractively runs the given execution request and forwards from and to the given reader and writers.
	// An ExitInfo is sent to the exit channel on command completion.
	// Output from the runner is forwarded immediately.
	ExecuteInteractively(
		ctx context.Context,
		id string,
		stdin io.ReadWriter,
		stdout,
		stderr io.Writer,
	) (exit <-chan ExitInfo, cancel context.CancelFunc, err error)

	// ListFileSystem streams the listing of the file system of the requested directory into the Writer provided.
	// The result is streamed via the io.Writer in order to not overload the memory with user input.
	ListFileSystem(ctx context.Context, path string, recursive bool, result io.Writer, privilegedExecution bool) error

	// UpdateFileSystem processes a dto.UpdateFileSystemRequest by first deleting each given dto.FilePath recursively
	// and then copying each given dto.File to the runner.
	UpdateFileSystem(ctx context.Context, request *dto.UpdateFileSystemRequest) error

	// GetFileContent streams the file content at the requested path into the Writer provided at content.
	// The result is streamed via the io.Writer in order to not overload the memory with user input.
	GetFileContent(ctx context.Context, path string, content http.ResponseWriter, privilegedExecution bool) error

	// Destroy destroys the Runner in Nomad.
	// Depending on the reason special cases of the Destruction will be handled.
	Destroy(reason DestroyReason) error
}

func FromContext

func FromContext(ctx context.Context) (Runner, bool)

FromContext returns a runner from a context.

type RunnerMock

type RunnerMock struct {
	mock.Mock
}

RunnerMock is an autogenerated mock type for the Runner type

func NewRunnerMock

func NewRunnerMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *RunnerMock

NewRunnerMock creates a new instance of RunnerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*RunnerMock) Destroy

func (_m *RunnerMock) Destroy(reason DestroyReason) error

Destroy provides a mock function with given fields: reason

func (*RunnerMock) Environment

func (_m *RunnerMock) Environment() dto.EnvironmentID

Environment provides a mock function with given fields:

func (*RunnerMock) ExecuteInteractively

func (_m *RunnerMock) ExecuteInteractively(ctx context.Context, id string, stdin io.ReadWriter, stdout io.Writer, stderr io.Writer) (<-chan ExitInfo, context.CancelFunc, error)

ExecuteInteractively provides a mock function with given fields: ctx, id, stdin, stdout, stderr

func (*RunnerMock) ExecutionExists

func (_m *RunnerMock) ExecutionExists(id string) bool

ExecutionExists provides a mock function with given fields: id

func (*RunnerMock) GetFileContent

func (_m *RunnerMock) GetFileContent(ctx context.Context, path string, content http.ResponseWriter, privilegedExecution bool) error

GetFileContent provides a mock function with given fields: ctx, path, content, privilegedExecution

func (*RunnerMock) ID

func (_m *RunnerMock) ID() string

ID provides a mock function with given fields:

func (*RunnerMock) ListFileSystem

func (_m *RunnerMock) ListFileSystem(ctx context.Context, path string, recursive bool, result io.Writer, privilegedExecution bool) error

ListFileSystem provides a mock function with given fields: ctx, path, recursive, result, privilegedExecution

func (*RunnerMock) MappedPorts

func (_m *RunnerMock) MappedPorts() []*dto.MappedPort

MappedPorts provides a mock function with given fields:

func (*RunnerMock) ResetTimeout

func (_m *RunnerMock) ResetTimeout()

ResetTimeout provides a mock function with given fields:

func (*RunnerMock) SetupTimeout

func (_m *RunnerMock) SetupTimeout(duration time.Duration)

SetupTimeout provides a mock function with given fields: duration

func (*RunnerMock) StopTimeout

func (_m *RunnerMock) StopTimeout()

StopTimeout provides a mock function with given fields:

func (*RunnerMock) StoreExecution

func (_m *RunnerMock) StoreExecution(id string, executionRequest *dto.ExecutionRequest)

StoreExecution provides a mock function with given fields: id, executionRequest

func (*RunnerMock) TimeoutPassed

func (_m *RunnerMock) TimeoutPassed() bool

TimeoutPassed provides a mock function with given fields:

func (*RunnerMock) UpdateFileSystem

func (_m *RunnerMock) UpdateFileSystem(ctx context.Context, request *dto.UpdateFileSystemRequest) error

UpdateFileSystem provides a mock function with given fields: ctx, request

type TimerState

type TimerState uint8
const (
	TimerInactive TimerState = 0
	TimerRunning  TimerState = 1
	TimerExpired  TimerState = 2
)

type WriteableExecutionEnvironment

type WriteableExecutionEnvironment interface {
	SetID(id dto.EnvironmentID)
	SetPrewarmingPoolSize(count uint)
	SetCPULimit(limit uint) error
	SetMemoryLimit(limit uint) error
	SetImage(image string)
	SetNetworkAccess(allow bool, ports []uint16)

	// SetConfigFrom copies all above attributes from the passed environment to the object itself.
	SetConfigFrom(environment ExecutionEnvironment)

	// AddRunner adds an existing runner to the idle runners of the environment.
	AddRunner(r Runner)
}

WriteableExecutionEnvironment defines structs that can update the attributes of an Execution Environment.

Jump to

Keyboard shortcuts

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