worker

package
v0.75.0-no-limit Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2016 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const VolumeTTL = containerTTL

Variables

View Source
var (
	ErrNoWorkers     = errors.New("no workers")
	ErrMissingWorker = errors.New("worker for container is missing")
)
View Source
var ErrIncompatiblePlatform = errors.New("incompatible platform")
View Source
var ErrMismatchedTags = errors.New("mismatched tags")
View Source
var ErrMissingVolume = errors.New("volume mounted to container is missing")
View Source
var ErrMultipleWorkersWithName = errors.New("More than one worker has given worker name")
View Source
var ErrUnsupportedResourceType = errors.New("unsupported resource type")

Functions

func FinalTTL

func FinalTTL(ttl time.Duration) *time.Duration

func NewGardenContainerSpecFactory

func NewGardenContainerSpecFactory(logger lager.Logger, baggageclaimClient baggageclaim.Client, imageFetcher ImageFetcher) gardenContainerSpecFactory

func NewHardcoded

func NewHardcoded(
	logger lager.Logger, workerDB SaveWorkerDB, clock c.Clock,
	gardenAddr string, baggageclaimURL string, resourceTypesNG []atc.WorkerResourceType,
) ifrit.RunFunc

Types

type Client

type Client interface {
	CreateContainer(
		lager.Logger,
		<-chan os.Signal,
		ImageFetchingDelegate,
		Identifier,
		Metadata,
		ContainerSpec,
		atc.ResourceTypes,
	) (Container, error)

	FindContainerForIdentifier(lager.Logger, Identifier) (Container, bool, error)
	LookupContainer(lager.Logger, string) (Container, bool, error)

	Satisfying(WorkerSpec, atc.ResourceTypes) (Worker, error)
	AllSatisfying(WorkerSpec, atc.ResourceTypes) ([]Worker, error)
	GetWorker(workerName string) (Worker, error)
}

func NewPool

func NewPool(provider WorkerProvider) Client

type Container

type Container interface {
	garden.Container

	Destroy() error

	Release(*time.Duration)

	Volumes() []Volume
	VolumeMounts() []VolumeMount
}

type ContainerSpec

type ContainerSpec interface {
	WorkerSpec() WorkerSpec
	ImageResource() (atc.TaskImageConfig, bool)
}

type ExponentialRetryPolicy

type ExponentialRetryPolicy struct {
	Timeout time.Duration
}

func (ExponentialRetryPolicy) DelayFor

func (policy ExponentialRetryPolicy) DelayFor(attempts uint) (time.Duration, bool)

type GardenConnectionFactory

type GardenConnectionFactory interface {
	BuildConnection() gconn.Connection
	BuildConnectionFromDB() (gconn.Connection, error)
}

func NewGardenConnectionFactory

func NewGardenConnectionFactory(
	db GardenConnectionFactoryDB,
	dialer gconn.DialerFunc,
	logger lager.Logger,
	workerName string,
	address string,
) GardenConnectionFactory

type GardenConnectionFactoryDB

type GardenConnectionFactoryDB interface {
	GetWorker(string) (db.SavedWorker, bool, error)
}

type GardenWorkerDB

type GardenWorkerDB interface {
	CreateContainer(db.Container, time.Duration) (db.SavedContainer, error)
	UpdateExpiresAtOnContainer(handle string, ttl time.Duration) error
}

type Identifier

type Identifier db.ContainerIdentifier

type Image

type Image interface {
	Volume() Volume
	Metadata() ImageMetadata
	Release(*time.Duration)
}

type ImageFetcher

type ImageFetcher interface {
	FetchImage(
		lager.Logger,
		atc.TaskImageConfig,
		<-chan os.Signal,
		Identifier,
		Metadata,
		ImageFetchingDelegate,
		Client,
		atc.Tags,
		atc.ResourceTypes,
	) (Image, error)
}

type ImageFetchingDelegate

type ImageFetchingDelegate interface {
	Stderr() io.Writer
	ImageVersionDetermined(db.VolumeIdentifier) error
}

type ImageMetadata

type ImageMetadata struct {
	Env  []string `json:"env"`
	User string   `json:"user"`
}

type Metadata

type Metadata db.ContainerMetadata

type MultiWorkerError

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

func (*MultiWorkerError) AddError

func (mwe *MultiWorkerError) AddError(workerName string, err error)

func (MultiWorkerError) Error

func (err MultiWorkerError) Error() string

func (MultiWorkerError) Errors

func (mwe MultiWorkerError) Errors() map[string]error

type MultipleContainersError

type MultipleContainersError struct {
	Handles []string
}

func (MultipleContainersError) Error

func (err MultipleContainersError) Error() string

type MultipleWorkersFoundContainerError

type MultipleWorkersFoundContainerError struct {
	Names []string
}

func (MultipleWorkersFoundContainerError) Error

type NoCompatibleWorkersError

type NoCompatibleWorkersError struct {
	Spec    WorkerSpec
	Workers []Worker
}

func (NoCompatibleWorkersError) Error

func (err NoCompatibleWorkersError) Error() string

type NoopImageFetchingDelegate

type NoopImageFetchingDelegate struct{}

func (NoopImageFetchingDelegate) ImageVersionDetermined

func (NoopImageFetchingDelegate) ImageVersionDetermined(db.VolumeIdentifier) error

func (NoopImageFetchingDelegate) Stderr

type ResourceTypeContainerSpec

type ResourceTypeContainerSpec struct {
	Type                 string
	ImageResourcePointer *atc.TaskImageConfig
	Ephemeral            bool
	Tags                 []string
	Env                  []string

	// Not Copy-on-Write. Used for a single mount in Get containers.
	Cache VolumeMount

	// Copy-on-Write. Used for mounting multiple resources into a Put container.
	Mounts []VolumeMount
}

func (ResourceTypeContainerSpec) ImageResource

func (spec ResourceTypeContainerSpec) ImageResource() (atc.TaskImageConfig, bool)

func (ResourceTypeContainerSpec) WorkerSpec

func (spec ResourceTypeContainerSpec) WorkerSpec() WorkerSpec

type RetryPolicy

type RetryPolicy interface {
	DelayFor(uint) (time.Duration, bool)
}

type RetryableConnection

type RetryableConnection struct {
	gconn.Connection

	Logger            lager.Logger
	Sleeper           Sleeper
	RetryPolicy       RetryPolicy
	ConnectionFactory GardenConnectionFactory
	// contains filtered or unexported fields
}

func NewRetryableConnection

func NewRetryableConnection(
	logger lager.Logger,
	sleeper Sleeper,
	retryPolicy RetryPolicy,
	connectionFactory GardenConnectionFactory,
) *RetryableConnection

func (*RetryableConnection) Attach

func (conn *RetryableConnection) Attach(handle string, processID string, processIO garden.ProcessIO) (garden.Process, error)

func (*RetryableConnection) Capacity

func (conn *RetryableConnection) Capacity() (garden.Capacity, error)

func (*RetryableConnection) Create

func (conn *RetryableConnection) Create(spec garden.ContainerSpec) (string, error)

func (*RetryableConnection) CurrentBandwidthLimits

func (conn *RetryableConnection) CurrentBandwidthLimits(handle string) (garden.BandwidthLimits, error)

func (*RetryableConnection) CurrentCPULimits

func (conn *RetryableConnection) CurrentCPULimits(handle string) (garden.CPULimits, error)

func (*RetryableConnection) CurrentDiskLimits

func (conn *RetryableConnection) CurrentDiskLimits(handle string) (garden.DiskLimits, error)

func (*RetryableConnection) CurrentMemoryLimits

func (conn *RetryableConnection) CurrentMemoryLimits(handle string) (garden.MemoryLimits, error)

func (*RetryableConnection) Destroy

func (conn *RetryableConnection) Destroy(handle string) error

func (*RetryableConnection) Info

func (conn *RetryableConnection) Info(handle string) (garden.ContainerInfo, error)

func (*RetryableConnection) LimitBandwidth

func (conn *RetryableConnection) LimitBandwidth(handle string, limits garden.BandwidthLimits) (garden.BandwidthLimits, error)

func (*RetryableConnection) LimitCPU

func (conn *RetryableConnection) LimitCPU(handle string, limits garden.CPULimits) (garden.CPULimits, error)

func (*RetryableConnection) LimitMemory

func (conn *RetryableConnection) LimitMemory(handle string, limits garden.MemoryLimits) (garden.MemoryLimits, error)

func (*RetryableConnection) List

func (conn *RetryableConnection) List(properties garden.Properties) ([]string, error)

func (*RetryableConnection) NetIn

func (conn *RetryableConnection) NetIn(handle string, hostPort, containerPort uint32) (uint32, uint32, error)

func (*RetryableConnection) NetOut

func (conn *RetryableConnection) NetOut(handle string, rule garden.NetOutRule) error

func (*RetryableConnection) Ping

func (conn *RetryableConnection) Ping() error

func (*RetryableConnection) Property

func (conn *RetryableConnection) Property(handle string, name string) (string, error)

func (*RetryableConnection) RemoveProperty

func (conn *RetryableConnection) RemoveProperty(handle string, name string) error

func (*RetryableConnection) Run

func (conn *RetryableConnection) Run(handle string, processSpec garden.ProcessSpec, processIO garden.ProcessIO) (garden.Process, error)

func (*RetryableConnection) SetProperty

func (conn *RetryableConnection) SetProperty(handle string, name string, value string) error

func (*RetryableConnection) Stop

func (conn *RetryableConnection) Stop(handle string, kill bool) error

func (*RetryableConnection) StreamIn

func (conn *RetryableConnection) StreamIn(handle string, spec garden.StreamInSpec) error

func (*RetryableConnection) StreamOut

func (conn *RetryableConnection) StreamOut(handle string, spec garden.StreamOutSpec) (io.ReadCloser, error)

type SaveWorkerDB

type SaveWorkerDB interface {
	SaveWorker(db.WorkerInfo, time.Duration) (db.SavedWorker, error)
}

type Sleeper

type Sleeper interface {
	Sleep(time.Duration)
}

type TaskContainerSpec

type TaskContainerSpec struct {
	Platform             string
	Image                string
	ImageResourcePointer *atc.TaskImageConfig
	Privileged           bool
	Tags                 []string
	Inputs               []VolumeMount
	Outputs              []VolumeMount
}

func (TaskContainerSpec) ImageResource

func (spec TaskContainerSpec) ImageResource() (atc.TaskImageConfig, bool)

func (TaskContainerSpec) WorkerSpec

func (spec TaskContainerSpec) WorkerSpec() WorkerSpec

type Volume

type Volume interface {
	baggageclaim.Volume
}

type VolumeFactory

type VolumeFactory interface {
	Build(lager.Logger, baggageclaim.Volume) (Volume, error)
}

func NewVolumeFactory

func NewVolumeFactory(db VolumeFactoryDB, clock clock.Clock) VolumeFactory

type VolumeFactoryDB

type VolumeFactoryDB interface {
	GetVolumeTTL(volumeHandle string) (time.Duration, error)
	ReapVolume(handle string) error
	SetVolumeTTL(string, time.Duration) error
}

type VolumeMount

type VolumeMount struct {
	Volume    Volume
	MountPath string
}

type Worker

type Worker interface {
	Client

	ActiveContainers() int

	Description() string
	Name() string

	VolumeManager() (baggageclaim.Client, bool)
}

func NewGardenWorker

func NewGardenWorker(
	gardenClient garden.Client,
	baggageclaimClient baggageclaim.Client,
	volumeFactory VolumeFactory,
	imageFetcher ImageFetcher,
	db GardenWorkerDB,
	provider WorkerProvider,
	clock clock.Clock,
	activeContainers int,
	resourceTypes []atc.WorkerResourceType,
	platform string,
	tags atc.Tags,
	name string,
) Worker

type WorkerDB

type WorkerDB interface {
	Workers() ([]db.SavedWorker, error)
	GetWorker(string) (db.SavedWorker, bool, error)
	CreateContainer(db.Container, time.Duration) (db.SavedContainer, error)
	GetContainer(string) (db.SavedContainer, bool, error)
	FindContainerByIdentifier(db.ContainerIdentifier) (db.SavedContainer, bool, error)

	UpdateExpiresAtOnContainer(handle string, ttl time.Duration) error
	ReapContainer(handle string) error

	GetVolumeTTL(volumeHandle string) (time.Duration, error)
	ReapVolume(handle string) error
	SetVolumeTTL(string, time.Duration) error
}

type WorkerProvider

type WorkerProvider interface {
	Workers() ([]Worker, error)
	GetWorker(string) (Worker, bool, error)
	FindContainerForIdentifier(Identifier) (db.SavedContainer, bool, error)
	GetContainer(string) (db.SavedContainer, bool, error)
	ReapContainer(string) error
}

func NewDBWorkerProvider

func NewDBWorkerProvider(
	logger lager.Logger,
	db WorkerDB,
	dialer gconn.DialerFunc,
	retryPolicy RetryPolicy,
	imageFetcher ImageFetcher,
) WorkerProvider

type WorkerSpec

type WorkerSpec struct {
	Platform     string
	ResourceType string
	Tags         []string
}

func (WorkerSpec) Description

func (spec WorkerSpec) Description() string

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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