Documentation

Index

Constants

View Source
const BridgeIPKey = "garden.network.host-ip"
View Source
const CleanupRetryLimit = 30
View Source
const CleanupRetrySleep = 3 * time.Second
View Source
const ContainerIPKey = "garden.network.container-ip"
View Source
const ExternalIPKey = "garden.network.external-ip"
View Source
const GraceTimeKey = "garden.grace-time"
View Source
const MappedPortsKey = "garden.network.mapped-ports"
View Source
const RawRootFSScheme = "raw"
View Source
const VolumizerSession = "volumizer"

Variables

View Source
var ErrGraphDisabled = errors.New("no image plugin configured")

Functions

func NewBulkStarter

func NewBulkStarter(starters []Starter) *bulkStarter

Types

type ActualContainerMetrics

type ActualContainerMetrics struct {
	StatsContainerMetrics
	CPUEntitlement uint64
}

type BulkStarter

type BulkStarter interface {
	StartAll() error
}

type CommandFactory

type CommandFactory func(ctrPID, uid, gid int, mode os.FileMode, recreate bool, paths ...string) *exec.Cmd

type Containerizer

type Containerizer interface {
	Create(log lager.Logger, desiredContainerSpec spec.DesiredContainerSpec) error
	Handles() ([]string, error)

	StreamIn(log lager.Logger, handle string, streamInSpec garden.StreamInSpec) error
	StreamOut(log lager.Logger, handle string, streamOutSpec garden.StreamOutSpec) (io.ReadCloser, error)

	Run(log lager.Logger, handle string, processSpec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error)
	Attach(log lager.Logger, handle string, processGUID string, io garden.ProcessIO) (garden.Process, error)
	Stop(log lager.Logger, handle string, kill bool) error
	Destroy(log lager.Logger, handle string) error
	RemoveBundle(log lager.Logger, handle string) error

	Info(log lager.Logger, handle string) (spec.ActualContainerSpec, error)
	Metrics(log lager.Logger, handle string) (ActualContainerMetrics, error)
	WatchRuntimeEvents(log lager.Logger) error

	Shutdown() error
}

type Gardener

type Gardener struct {
	// SysInfoProvider returns total memory and total disk
	SysInfoProvider SysInfoProvider

	// Containerizer runs and manages linux containers
	Containerizer Containerizer

	// UidGenerator generates unique ids for containers
	UidGenerator UidGenerator

	// BulkStarter runs any needed Starters that do start-up tasks (e.g. setting up cgroups)
	BulkStarter BulkStarter

	// Networker creates a network for containers
	Networker Networker

	// Volumizer creates volumes for containers
	Volumizer Volumizer

	Logger lager.Logger

	// PropertyManager creates map of container properties
	PropertyManager PropertyManager

	Sleep Sleeper

	// MaxContainers limits the advertised container capacity
	MaxContainers uint64

	Restorer Restorer

	PeaCleaner PeaCleaner

	AllowPrivilgedContainers bool
}

    Gardener orchestrates other components to implement the Garden API

    func New

    func New(
    	uidGenerator UidGenerator,
    	bulkStarter BulkStarter,
    	sysInfoProvider SysInfoProvider,
    	networker Networker,
    	volumizer Volumizer,
    	containerizer Containerizer,
    	propertyManager PropertyManager,
    	restorer Restorer,
    	peaCleaner PeaCleaner,
    	logger lager.Logger,
    	maxContainers uint64,
    	allowPrivilegedContainers bool,
    ) *Gardener

    func (*Gardener) BulkInfo

    func (g *Gardener) BulkInfo(handles []string) (map[string]garden.ContainerInfoEntry, error)

    func (*Gardener) BulkMetrics

    func (g *Gardener) BulkMetrics(handles []string) (map[string]garden.ContainerMetricsEntry, error)

    func (*Gardener) Capacity

    func (g *Gardener) Capacity() (garden.Capacity, error)

    func (*Gardener) Cleanup

    func (g *Gardener) Cleanup(log lager.Logger) error

    func (*Gardener) Containers

    func (g *Gardener) Containers(props garden.Properties) ([]garden.Container, error)

    func (*Gardener) Create

    func (g *Gardener) Create(containerSpec garden.ContainerSpec) (ctr garden.Container, err error)

      Create creates a container by combining the results of networker.Network, volumizer.Create and containzer.Create.

      func (*Gardener) Destroy

      func (g *Gardener) Destroy(handle string) error

      func (*Gardener) GraceTime

      func (g *Gardener) GraceTime(container garden.Container) time.Duration

      func (*Gardener) Lookup

      func (g *Gardener) Lookup(handle string) (garden.Container, error)

      func (*Gardener) Ping

      func (g *Gardener) Ping() error

      func (*Gardener) Start

      func (g *Gardener) Start() error

      func (*Gardener) Stop

      func (g *Gardener) Stop() error

      type Networker

      type Networker interface {
      	SetupBindMounts(log lager.Logger, handle string, privileged bool, rootfsPath string) ([]garden.BindMount, error)
      	Network(log lager.Logger, spec garden.ContainerSpec, pid int) error
      	Capacity() uint64
      	Destroy(log lager.Logger, handle string) error
      	NetIn(log lager.Logger, handle string, hostPort, containerPort uint32) (uint32, uint32, error)
      	BulkNetOut(log lager.Logger, handle string, rules []garden.NetOutRule) error
      	NetOut(log lager.Logger, handle string, rule garden.NetOutRule) error
      	Restore(log lager.Logger, handle string) error
      }

      type NoopRestorer

      type NoopRestorer struct{}

      func (*NoopRestorer) Restore

      func (n *NoopRestorer) Restore(_ lager.Logger, handles []string) []string

      type NoopVolumizer

      type NoopVolumizer struct{}

      func (NoopVolumizer) Capacity

      func (NoopVolumizer) Capacity(lager.Logger) (uint64, error)

      func (NoopVolumizer) Create

      func (NoopVolumizer) Destroy

      func (NoopVolumizer) GC

      func (NoopVolumizer) Metrics

      type PeaCleaner

      type PeaCleaner interface {
      	CleanAll(logger lager.Logger) error
      	Clean(logger lager.Logger, handle string) error
      }

      type PropertyManager

      type PropertyManager interface {
      	All(handle string) (props garden.Properties, err error)
      	Set(handle string, name string, value string)
      	Remove(handle string, name string) error
      	Get(handle string, name string) (string, bool)
      	MatchesAll(handle string, props garden.Properties) bool
      	DestroyKeySpace(string) error
      }

      type Restorer

      type Restorer interface {
      	Restore(logger lager.Logger, handles []string) []string
      }

      func NewRestorer

      func NewRestorer(networker Networker) Restorer

      type RootfsSpec

      type RootfsSpec struct {
      	RootFS     *url.URL
      	Username   string `json:"-"`
      	Password   string `json:"-"`
      	Namespaced bool
      	QuotaSize  int64
      	QuotaScope garden.DiskLimitScope
      }

        TODO GoRename RootfsSpec

        type Sleeper

        type Sleeper func(time.Duration)

        type Starter

        type Starter interface {
        	Start() error
        }

        type StatsContainerMetrics

        type StatsContainerMetrics struct {
        	CPU    garden.ContainerCPUStat
        	Memory garden.ContainerMemoryStat
        	Pid    garden.ContainerPidStat
        	Age    time.Duration
        }

        type SysInfoProvider

        type SysInfoProvider interface {
        	TotalMemory() (uint64, error)
        	TotalDisk() (uint64, error)
        	CPUCores() (int, error)
        }

        type UidGenerator

        type UidGenerator interface {
        	Generate() string
        }

        type UidGeneratorFunc

        type UidGeneratorFunc func() string

        func (UidGeneratorFunc) Generate

        func (fn UidGeneratorFunc) Generate() string

        type VolumeCreator

        type VolumeCreator interface {
        	Create(log lager.Logger, handle string, spec RootfsSpec) (specs.Spec, error)
        }

        type VolumeDestroyMetricsGC

        type VolumeDestroyMetricsGC interface {
        	Destroy(log lager.Logger, handle string) error
        	Metrics(log lager.Logger, handle string, namespaced bool) (garden.ContainerDiskStat, error)
        	GC(log lager.Logger) error
        	Capacity(log lager.Logger) (uint64, error)
        }

        type VolumeProvider

        type VolumeProvider struct {
        	VolumeCreator VolumeCreator
        	VolumeDestroyMetricsGC
        
        	ContainerRootUID int
        	ContainerRootGID int
        	// contains filtered or unexported fields
        }

        func NewVolumeProvider

        func NewVolumeProvider(creator VolumeCreator, manager VolumeDestroyMetricsGC, commandrunner commandrunner.CommandRunner, rootUID, rootGID int) *VolumeProvider

        func (*VolumeProvider) Create

        func (v *VolumeProvider) Create(log lager.Logger, spec garden.ContainerSpec) (specs.Spec, error)

        type Volumizer

        type Volumizer interface {
        	Create(log lager.Logger, spec garden.ContainerSpec) (specs.Spec, error)
        	VolumeDestroyMetricsGC
        }

        Directories

        Path Synopsis
        Code generated by counterfeiter.
        Code generated by counterfeiter.