Documentation ¶
Index ¶
- Constants
- Variables
- func NewHardcoded(logger lager.Logger, workerFactory db.WorkerFactory, clock c.Clock, ...) ifrit.RunFunc
- type ArtifactDestination
- type ArtifactName
- type ArtifactRepository
- func (repo *ArtifactRepository) AsMap() map[ArtifactName]ArtifactSource
- func (repo *ArtifactRepository) RegisterSource(name ArtifactName, source ArtifactSource)
- func (repo *ArtifactRepository) ScopedTo(names ...ArtifactName) (*ArtifactRepository, error)
- func (repo *ArtifactRepository) SourceFor(name ArtifactName) (ArtifactSource, bool)
- func (repo *ArtifactRepository) StreamFile(path string) (io.ReadCloser, error)
- func (repo *ArtifactRepository) StreamTo(dest ArtifactDestination) error
- func (repo *ArtifactRepository) VolumeOn(worker Worker) (Volume, bool, error)
- type ArtifactSource
- type BindMountSource
- type CertsVolumeMount
- type Client
- type Container
- type ContainerPlacementStrategy
- type ContainerProvider
- type ContainerSpec
- type ErrCreatedVolumeNotFound
- type FetchedImage
- type FileNotFoundError
- type GardenConnectionFactory
- type HostRootFSStrategy
- type Image
- type ImageFactory
- type ImageFetchingDelegate
- type ImageMetadata
- type ImageResource
- type ImageSpec
- type InputSource
- type MalformedMetadataError
- type NoCompatibleWorkersError
- type NoopImageFetchingDelegate
- type OutputPaths
- type RandomPlacementStrategy
- type RetryableConnection
- type Sleeper
- type Volume
- type VolumeClient
- type VolumeLocalityPlacementStrategy
- type VolumeMount
- type VolumeProperties
- type VolumeSpec
- type Worker
- type WorkerProvider
- type WorkerSpec
Constants ¶
const ImageMetadataFile = "metadata.json"
const RawRootFSScheme = "raw"
Variables ¶
var ( ErrNoWorkers = errors.New("no workers") ErrMissingWorker = errors.New("worker for container is missing") )
var ErrBaseResourceTypeNotFound = errors.New("base resource type not found")
var ErrDesiredWorkerNotRunning = errors.New("desired garden worker is not known to be running")
var ErrIncompatiblePlatform = errors.New("incompatible platform")
var ErrMismatchedTags = errors.New("mismatched tags")
var ErrMissingVolume = errors.New("volume mounted to container is missing")
var ErrNoVolumeManager = errors.New("worker does not support volume management")
var ErrNotImplemented = errors.New("Not implemented")
var ErrTeamMismatch = errors.New("mismatched team")
var ErrUnsupportedResourceType = errors.New("unsupported resource type")
var ErrVolumeExpiredImmediately = errors.New("volume expired immediately after saving")
Functions ¶
func NewHardcoded ¶
Types ¶
type ArtifactDestination ¶
type ArtifactDestination interface { // StreamIn is called with a destination directory and the tar stream to // expand into the destination directory. StreamIn(string, io.Reader) error }
Destination is the inverse of Source. This interface allows the receiving end to determine the location of the data, e.g. based on a task's input configuration.
type ArtifactName ¶
type ArtifactName string
ArtifactName is just a string, with its own type to make interfaces using it more self-documenting.
type ArtifactRepository ¶
type ArtifactRepository struct {
// contains filtered or unexported fields
}
ArtifactRepository is the mapping from a ArtifactName to an ArtifactSource. Steps will both populate this map with new artifacts (e.g. the resource fetched by a Get step), and look up required artifacts (e.g. the inputs configured for a Task step).
There is only one ArtifactRepository for the duration of a build plan's execution.
ArtifactRepository is, itself, an ArtifactSource. As an ArtifactSource it acts as the set of all ArtifactSources it contains, as if they were each in subdirectories corresponding to their ArtifactName.
func NewArtifactRepository ¶
func NewArtifactRepository() *ArtifactRepository
NewArtifactRepository constructs a new repository.
func (*ArtifactRepository) AsMap ¶
func (repo *ArtifactRepository) AsMap() map[ArtifactName]ArtifactSource
AsMap extracts the current contents of the ArtifactRepository into a new map and returns it. Changes to the returned map or the ArtifactRepository will not affect each other.
func (*ArtifactRepository) RegisterSource ¶
func (repo *ArtifactRepository) RegisterSource(name ArtifactName, source ArtifactSource)
RegisterSource inserts an ArtifactSource into the map under the given ArtifactName. Producers of artifacts, e.g. the Get step and the Task step, will call this after they've successfully produced their artifact(s).
func (*ArtifactRepository) ScopedTo ¶
func (repo *ArtifactRepository) ScopedTo(names ...ArtifactName) (*ArtifactRepository, error)
ScopedTo returns a new ArtifactRepository restricted to the given set of ArtifactNames. This is used by the Put step to stream in the sources that did not have a volume available on its destination.
func (*ArtifactRepository) SourceFor ¶
func (repo *ArtifactRepository) SourceFor(name ArtifactName) (ArtifactSource, bool)
SourceFor looks up a Source for the given ArtifactName. Consumers of artifacts, e.g. the Task step, will call this to locate their dependencies.
func (*ArtifactRepository) StreamFile ¶
func (repo *ArtifactRepository) StreamFile(path string) (io.ReadCloser, error)
StreamFile streams a single file out of the repository, using the first path segment to determine the ArtifactSource to stream out of. For example, StreamFile("a/b.yml") will look up the "a" ArtifactSource and return the result of StreamFile("b.yml") on it.
If the ArtifactSource determined by the path is not present, FileNotFoundError will be returned.
func (*ArtifactRepository) StreamTo ¶
func (repo *ArtifactRepository) StreamTo(dest ArtifactDestination) error
StreamTo will stream all currently registered artifacts to the destination. This is used by the Put step, which currently does not have an explicit set of dependencies, and instead just pulls in everything.
Each ArtifactSource will be streamed to a subdirectory matching its ArtifactName.
type ArtifactSource ¶
type ArtifactSource interface { // StreamTo copies the data from the source to the destination. Note that // this potentially uses a lot of network transfer, for larger artifacts, as // the ATC will effectively act as a middleman. StreamTo(ArtifactDestination) error // StreamFile returns the contents of a single file in the artifact source. // This is used for loading a task's configuration at runtime. // // If the file cannot be found, FileNotFoundError should be returned. StreamFile(path string) (io.ReadCloser, error) // VolumeOn attempts to locate a volume equivalent to this source on the // given worker. If a volume can be found, it will be used directly. If not, // `StreamTo` will be used to copy the data to the destination instead. VolumeOn(Worker) (Volume, bool, error) }
Source represents data produced by the steps, that can be transferred to other steps.
type BindMountSource ¶
type CertsVolumeMount ¶
type Client ¶
type Client interface { FindOrCreateContainer( context.Context, lager.Logger, ImageFetchingDelegate, db.ContainerOwner, db.ContainerMetadata, ContainerSpec, creds.VersionedResourceTypes, ) (Container, error) FindContainerByHandle(lager.Logger, int, string) (Container, bool, error) LookupVolume(lager.Logger, string) (Volume, bool, error) FindResourceTypeByPath(path string) (atc.WorkerResourceType, bool) Satisfying(lager.Logger, WorkerSpec, creds.VersionedResourceTypes) (Worker, error) AllSatisfying(lager.Logger, WorkerSpec, creds.VersionedResourceTypes) ([]Worker, error) RunningWorkers(lager.Logger) ([]Worker, error) }
func NewPool ¶
func NewPool(provider WorkerProvider, strategy ContainerPlacementStrategy) Client
type ContainerPlacementStrategy ¶
type ContainerPlacementStrategy interface {
Choose([]Worker, ContainerSpec) (Worker, error)
}
func NewRandomPlacementStrategy ¶
func NewRandomPlacementStrategy() ContainerPlacementStrategy
func NewVolumeLocalityPlacementStrategy ¶
func NewVolumeLocalityPlacementStrategy() ContainerPlacementStrategy
type ContainerProvider ¶
type ContainerProvider interface { FindCreatedContainerByHandle( logger lager.Logger, handle string, teamID int, ) (Container, bool, error) FindOrCreateContainer( ctx context.Context, logger lager.Logger, owner db.ContainerOwner, delegate ImageFetchingDelegate, metadata db.ContainerMetadata, spec ContainerSpec, resourceTypes creds.VersionedResourceTypes, ) (Container, error) }
func NewContainerProvider ¶
func NewContainerProvider( gardenClient garden.Client, baggageclaimClient baggageclaim.Client, reaperClient reaper.ReaperClient, volumeClient VolumeClient, dbWorker db.Worker, clock clock.Clock, imageFactory ImageFactory, dbVolumeFactory db.VolumeFactory, dbTeamFactory db.TeamFactory, lockFactory lock.LockFactory, ) ContainerProvider
type ContainerSpec ¶
type ContainerSpec struct { Platform string Tags []string TeamID int ImageSpec ImageSpec Env []string // Working directory for processes run in the container. Dir string // Inputs to provide to the container. Inputs with a volume local to the // selected worker will be made available via a COW volume; others will be // streamed. Inputs []InputSource // Outputs for which volumes should be created and mounted into the container. Outputs OutputPaths // Local volumes to bind mount directly to the container when creating in garden. BindMounts []BindMountSource // Optional user to run processes as. Overwrites the one specified in the docker image. User string }
func (ContainerSpec) WorkerSpec ¶
func (spec ContainerSpec) WorkerSpec() WorkerSpec
type ErrCreatedVolumeNotFound ¶
func (ErrCreatedVolumeNotFound) Error ¶
func (e ErrCreatedVolumeNotFound) Error() string
type FetchedImage ¶
type FetchedImage struct { Metadata ImageMetadata Version atc.Version URL string Privileged bool }
type FileNotFoundError ¶
type FileNotFoundError struct {
Path string
}
FileNotFoundError is the error to return from StreamFile when the given path does not exist.
func (FileNotFoundError) Error ¶
func (err FileNotFoundError) Error() string
Error prints a helpful message including the file path. The user will see this message if e.g. their task config path does not exist.
type GardenConnectionFactory ¶
type GardenConnectionFactory interface {
BuildConnection() gconn.Connection
}
func NewGardenConnectionFactory ¶
func NewGardenConnectionFactory( db transport.TransportDB, logger lager.Logger, workerName string, workerHost *string, retryBackOffFactory retryhttp.BackOffFactory, ) GardenConnectionFactory
type HostRootFSStrategy ¶
type Image ¶
type Image interface { FetchForContainer( ctx context.Context, logger lager.Logger, container db.CreatingContainer, ) (FetchedImage, error) }
type ImageFactory ¶
type ImageFactory interface { GetImage( logger lager.Logger, workerClient Worker, volumeClient VolumeClient, imageSpec ImageSpec, teamID int, delegate ImageFetchingDelegate, resourceTypes creds.VersionedResourceTypes, ) (Image, error) }
type ImageFetchingDelegate ¶
type ImageMetadata ¶
type ImageResource ¶
type ImageSpec ¶
type ImageSpec struct { ResourceType string ImageURL string ImageResource *ImageResource ImageArtifactSource ArtifactSource ImageArtifactName ArtifactName Privileged bool }
type InputSource ¶
type InputSource interface { Source() ArtifactSource DestinationPath() string }
type MalformedMetadataError ¶
type MalformedMetadataError struct {
UnmarshalError error
}
func (MalformedMetadataError) Error ¶
func (err MalformedMetadataError) Error() string
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.UsedResourceCache) error
func (NoopImageFetchingDelegate) Stderr ¶
func (NoopImageFetchingDelegate) Stderr() io.Writer
func (NoopImageFetchingDelegate) Stdout ¶
func (NoopImageFetchingDelegate) Stdout() io.Writer
type OutputPaths ¶
OutputPaths is a mapping from output name to its path in the container.
type RandomPlacementStrategy ¶
type RandomPlacementStrategy struct {
// contains filtered or unexported fields
}
func (*RandomPlacementStrategy) Choose ¶
func (strategy *RandomPlacementStrategy) Choose(workers []Worker, spec ContainerSpec) (Worker, error)
type RetryableConnection ¶
type RetryableConnection struct {
gconn.Connection
}
func NewRetryableConnection ¶
func NewRetryableConnection(connection gconn.Connection) *RetryableConnection
type Volume ¶
type Volume interface { Handle() string Path() string SetProperty(key string, value string) error Properties() (baggageclaim.VolumeProperties, error) SetPrivileged(bool) error StreamIn(path string, tarStream io.Reader) error StreamOut(path string) (io.ReadCloser, error) COWStrategy() baggageclaim.COWStrategy InitializeResourceCache(*db.UsedResourceCache) error InitializeTaskCache(lager.Logger, int, string, string, bool) error CreateChildForContainer(db.CreatingContainer, string) (db.CreatingVolume, error) Destroy() error }
func NewVolume ¶
func NewVolume( bcVolume baggageclaim.Volume, dbVolume db.CreatedVolume, volumeClient VolumeClient, ) Volume
type VolumeClient ¶
type VolumeClient interface { FindOrCreateVolumeForContainer( lager.Logger, VolumeSpec, db.CreatingContainer, int, string, ) (Volume, error) FindOrCreateCOWVolumeForContainer( lager.Logger, VolumeSpec, db.CreatingContainer, Volume, int, string, ) (Volume, error) FindOrCreateVolumeForBaseResourceType( lager.Logger, VolumeSpec, int, string, ) (Volume, error) FindVolumeForResourceCache( lager.Logger, *db.UsedResourceCache, ) (Volume, bool, error) FindVolumeForTaskCache( logger lager.Logger, teamID int, jobID int, stepName string, path string, ) (Volume, bool, error) CreateVolumeForTaskCache( logger lager.Logger, volumeSpec VolumeSpec, teamID int, jobID int, stepName string, path string, ) (Volume, error) FindOrCreateVolumeForResourceCerts( logger lager.Logger, ) (volume Volume, found bool, err error) LookupVolume(lager.Logger, string) (Volume, bool, error) }
func NewVolumeClient ¶
func NewVolumeClient( baggageclaimClient baggageclaim.Client, dbWorker db.Worker, clock clock.Clock, lockFactory lock.LockFactory, dbVolumeFactory db.VolumeFactory, dbWorkerBaseResourceTypeFactory db.WorkerBaseResourceTypeFactory, dbWorkerTaskCacheFactory db.WorkerTaskCacheFactory, ) VolumeClient
type VolumeLocalityPlacementStrategy ¶
type VolumeLocalityPlacementStrategy struct {
// contains filtered or unexported fields
}
func (*VolumeLocalityPlacementStrategy) Choose ¶
func (strategy *VolumeLocalityPlacementStrategy) Choose(workers []Worker, spec ContainerSpec) (Worker, error)
type VolumeMount ¶
type VolumeProperties ¶
type VolumeSpec ¶
type VolumeSpec struct { Strategy baggageclaim.Strategy Properties VolumeProperties Privileged bool TTL time.Duration }
type Worker ¶
type Worker interface { Client ActiveContainers() int Description() string Name() string ResourceTypes() []atc.WorkerResourceType Tags() atc.Tags Uptime() time.Duration IsOwnedByTeam() bool IsVersionCompatible(lager.Logger, *version.Version) bool FindVolumeForResourceCache(logger lager.Logger, resourceCache *db.UsedResourceCache) (Volume, bool, error) FindVolumeForTaskCache(lager.Logger, int, int, string, string) (Volume, bool, error) CertsVolume(lager.Logger) (volume Volume, found bool, err error) GardenClient() garden.Client BaggageclaimClient() baggageclaim.Client ReaperClient() reaper.ReaperClient }
func NewGardenWorker ¶
func NewGardenWorker( gardenClient garden.Client, baggageclaimClient baggageclaim.Client, reaperClient reaper.ReaperClient, containerProvider ContainerProvider, volumeClient VolumeClient, dbWorker db.Worker, clock clock.Clock, ) Worker
type WorkerProvider ¶
type WorkerProvider interface { RunningWorkers(lager.Logger) ([]Worker, error) FindWorkerForContainer( logger lager.Logger, teamID int, handle string, ) (Worker, bool, error) FindWorkerForContainerByOwner( logger lager.Logger, teamID int, owner db.ContainerOwner, ) (Worker, bool, error) NewGardenWorker( logger lager.Logger, tikTok clock.Clock, savedWorker db.Worker, ) Worker }
func NewDBWorkerProvider ¶
func NewDBWorkerProvider( lockFactory lock.LockFactory, retryBackOffFactory retryhttp.BackOffFactory, imageFactory ImageFactory, dbResourceCacheFactory db.ResourceCacheFactory, dbResourceConfigFactory db.ResourceConfigFactory, dbWorkerBaseResourceTypeFactory db.WorkerBaseResourceTypeFactory, dbWorkerTaskCacheFactory db.WorkerTaskCacheFactory, dbVolumeFactory db.VolumeFactory, dbTeamFactory db.TeamFactory, workerFactory db.WorkerFactory, workerVersion *version.Version, baggageclaimResponseHeaderTimeout time.Duration, ) WorkerProvider
type WorkerSpec ¶
func (WorkerSpec) Description ¶
func (spec WorkerSpec) Description() string
Source Files ¶
- artifact_destination.go
- artifact_repository.go
- artifact_source.go
- certificates_mount.go
- client.go
- container.go
- container_provider.go
- container_spec.go
- db_worker_provider.go
- garden_connection_factory.go
- hardcoded.go
- image_factory.go
- placement.go
- pool.go
- retryable_garden_connection.go
- volume.go
- volume_client.go
- worker.go
Directories ¶
Path | Synopsis |
---|---|
imagefakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
transportfakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
Code generated by counterfeiter.
|
Code generated by counterfeiter. |