docker

package
v0.3.750 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 32 Imported by: 7

Documentation

Overview

Package docker provides a Docker driver for Fn. Provides an implementation of

github.com/fnproject/fn/api/agent/drivers.Driver

that knows how to run Docker images.

Index

Constants

View Source
const (
	FnUserId  = 1000
	FnGroupId = 1000
)
View Source
const (
	FnAgentClassifierLabel = "fn-agent-classifier"
	FnAgentInstanceLabel   = "fn-agent-instance"
)
View Source
const (
	LimitPerSec = 10
	LimitBurst  = 20
)

Variables

View Source
var (
	ErrImageWithVolume = models.NewAPIError(http.StatusBadRequest, errors.New("image has Volume definition"))
	// FnDockerUser is used as the runtime user/group when running docker containers.
	// This is not configurable at the moment, because some fdks require that user/group to be present in the container.
	FnDockerUser = fmt.Sprintf("%v:%v", FnUserId, FnGroupId)
)
View Source
var (
	ErrorPoolEmpty = errors.New("docker pre fork pool empty")
)

Functions

func RecordImageCleanerStats added in v0.3.647

func RecordImageCleanerStats(ctx context.Context, sample *ImageCacherStats)

func RecordInstanceId added in v0.3.647

func RecordInstanceId(ctx context.Context, id string)

func RecordWaitContainerResult

func RecordWaitContainerResult(ctx context.Context, exitCode int)

func RegisterViews

func RegisterViews(tagKeys []string, latencyDist []float64)

RegisterViews creates and registers views with provided tag keys

Types

type Auther

type Auther interface {
	// DockerAuth should return docker auth credentials that will authenticate
	// against a docker registry for a given drivers.ContainerTask.Image(). An
	// error may be returned which will cause the task not to be run, this can be
	// useful for an implementer to do things like testing auth configurations
	// before returning them; e.g. if the implementer would like to impose
	// certain restrictions on images or if credentials must be acquired right
	// before runtime and there's an error doing so. If these credentials don't
	// work, the docker pull will fail and the task will be set to error status.
	DockerAuth(ctx context.Context, image string) (*docker.AuthConfiguration, error)
}

Auther may by implemented by a drivers.ContainerTask if it would like to use not-necessarily-public docker images for any or all task invocations.

type CachedImage added in v0.3.645

type CachedImage struct {
	ID       string // Image Cache key
	ParentID string
	RepoTags []string // RepoTags are used to match special/status images that are exempt from image cache
	Size     uint64
}

type DockerDriver

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

DockerDriver implements drivers.Driver via the docker http API

func NewDocker

func NewDocker(conf drivers.Config) *DockerDriver

NewDocker implements drivers.Driver

func (*DockerDriver) Close

func (drv *DockerDriver) Close() error

func (*DockerDriver) CreateCookie

func (drv *DockerDriver) CreateCookie(ctx context.Context, task drivers.ContainerTask) (drivers.Cookie, error)

func (*DockerDriver) GetSlotKeyExtensions added in v0.3.720

func (drv *DockerDriver) GetSlotKeyExtensions(extn map[string]string) string

func (*DockerDriver) SetPullImageRetryPolicy added in v0.3.673

func (drv *DockerDriver) SetPullImageRetryPolicy(policy common.BackOffConfig, checker drivers.RetryErrorChecker) error

type DockerNetworks added in v0.3.659

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

func NewDockerNetworks added in v0.3.659

func NewDockerNetworks(conf drivers.Config) *DockerNetworks

func (*DockerNetworks) AllocNetwork added in v0.3.659

func (n *DockerNetworks) AllocNetwork() string

pick least used network

func (*DockerNetworks) FreeNetwork added in v0.3.659

func (n *DockerNetworks) FreeNetwork(id string)

unregister network

type DockerPool

type DockerPool interface {
	// fetch a pre-allocated free id from the pool
	// may return too busy error.
	AllocPoolId() (string, error)

	// Release the id back to the pool
	FreePoolId(id string)

	// stop and terminate the pool
	Close() error

	// returns inuse versus free
	Usage() DockerPoolStats
}

func NewDockerPool

func NewDockerPool(conf drivers.Config, driver *DockerDriver) DockerPool

type DockerPoolStats

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

type ImageCacher added in v0.3.645

type ImageCacher interface {
	// IsMaxCapacity returns true if total size of all images exceeds the limit
	// and if there's an image in LRU cache that can be removed.
	IsMaxCapacity() bool

	// GetNotifier returns a channel that can be monitored. The channel will return
	// data every time IsMaxCapacity() flips from false to true state.
	GetNotifier() <-chan struct{}

	// Removes an image from the LRU cache if cache is not empty
	Pop() *CachedImage

	// Update adds an image to the LRU cache if the image is not marked in-use
	Update(img *CachedImage)

	// Mark/Unmark an image in-use. If an image is in-use, it will
	// not be a candidate in LRU. When the reference count of the
	// image drops to zero (via MarkFree() calls), the image will
	// be added back to LRU.
	MarkBusy(img *CachedImage)
	MarkFree(img *CachedImage)

	// Stats Monitoring
	GetStats() *ImageCacherStats
}

func NewImageCache added in v0.3.645

func NewImageCache(exemptTags []string, maxSize uint64) ImageCacher

type ImageCacherStats added in v0.3.647

type ImageCacherStats struct {
	BusyImgTotalSize uint64
	BusyImgCount     uint64
	IdleImgTotalSize uint64
	IdleImgCount     uint64
	MaxImgTotalSize  uint64
}

type ImagePuller added in v0.3.672

type ImagePuller interface {
	PullImage(ctx context.Context, cfg *docker.AuthConfiguration, img, repo, tag string) chan error
	SetRetryPolicy(policy common.BackOffConfig, checker drivers.RetryErrorChecker) error
}

func NewImagePuller added in v0.3.672

func NewImagePuller(docker dockerClient) ImagePuller

type PoolTaskStateType

type PoolTaskStateType int
const (
	PoolTaskStateInit  PoolTaskStateType = iota // initializing
	PoolTaskStateReady                          // ready to be run
)

Jump to

Keyboard shortcuts

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