pod

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LAYOUT_KEY_PREFIX = "PL-"
	LAYOUT_KEY_FMT    = "PL-%s"
	SB_KEY_FMT        = "SB-%s"
	PS_KEY_FMT        = "PS-%s"
	PMETA_KEY_FMT     = "PM-%s"
	PMAP_KEY_FMT      = "PP-%s"
	CX_KEY_FMT        = "CX-%s"
	VX_KEY_FMT        = "VX-%s-%s"
	IF_KEY_FMT        = "IF-%s-%s"
)
View Source
const (
	//The Log level for Pods
	TRACE   = hlog.TRACE
	DEBUG   = hlog.DEBUG
	INFO    = hlog.INFO
	WARNING = hlog.WARNING
	ERROR   = hlog.ERROR
)
View Source
const (
	// set default mode to masquerading
	// Others are `i` tunneling and `g` gatewaying
	DEFAULT_MODE   string = "m"
	DEFAULT_WEITHT int    = 1
	// Others are wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq
	DEFAULT_SCHEDULER = "rr"
)

Variables

View Source
var DetachError error = fmt.Errorf("DetachError")
View Source
var DetachKeys = "ctrl-p,ctrl-q"
View Source
var (
	ProvisionTimeout = 5 * time.Minute
)

Functions

func GetMountIdByContainer

func GetMountIdByContainer(driver, cid string) (string, error)

func HostsCreator

func HostsCreator(pod string) *utils.Initializer

func HostsPath

func HostsPath(pod string) (hostsDir, hostsPath string)

func ListAllPods

func ListAllPods(db *daemondb.DaemonDB) ([][]byte, error)

func LoadAllPods

func LoadAllPods(db *daemondb.DaemonDB) chan *types.PersistPodLayout

func MigrateLagecyPersistentData

func MigrateLagecyPersistentData(db *daemondb.DaemonDB, podFactory func() *PodFactory) (err error)

MigrateLagecyData migrate lagecy persistence data to current layout.

func ProbeExistingVolume

func ProbeExistingVolume(v *apitypes.UserVolume, sharedDir string) (*runv.VolumeDescription, error)

func UmountExistingVolume

func UmountExistingVolume(fstype, target, sharedDir string) error

Types

type Container

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

A Container is run inside a Pod. It could be created as a member of a pod, and belongs to the pod until it is removed.

func (*Container) Add

func (c *Container) Add() error

Container life cycle operations:

func (*Container) AttachStreams

func (c *Container) AttachStreams(openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.WriteCloser, stderr io.Writer, keys []byte) error

AttachStreams connects streams to a TTY. Used by exec too. Should this move somewhere else?

func (*Container) BriefStatus

func (c *Container) BriefStatus() (s *apitypes.ContainerListResult)

func (*Container) CreatedAt

func (c *Container) CreatedAt() time.Time

func (*Container) CurrentState

func (c *Container) CurrentState() ContainerState

Container status

func (*Container) GetExitCode

func (c *Container) GetExitCode() (uint8, error)

func (*Container) HasTty

func (c *Container) HasTty() bool

func (*Container) Id

func (c *Container) Id() string

Container Info:

func (*Container) Info

func (c *Container) Info() *apitypes.Container

func (*Container) InfoStatus

func (c *Container) InfoStatus() *apitypes.ContainerStatus

func (*Container) IsAlive

func (c *Container) IsAlive() bool

func (*Container) IsRunning

func (c *Container) IsRunning() bool

func (*Container) IsStopped

func (c *Container) IsStopped() bool

func (*Container) Log

func (c *Container) Log(level hlog.LogLevel, args ...interface{})

func (*Container) LogPrefix

func (c *Container) LogPrefix() string

func (*Container) Remove

func (c *Container) Remove() error

func (*Container) RuntimeName

func (c *Container) RuntimeName() string

func (*Container) SpecName

func (c *Container) SpecName() string

func (*Container) StatusString

func (c *Container) StatusString() string

type ContainerEngine

type ContainerEngine interface {
	ContainerCreate(params dockertypes.ContainerCreateConfig) (dockertypes.ContainerCreateResponse, error)
	ContainerInspect(id string, size bool, version version.Version) (interface{}, error)
	ContainerRm(name string, config *dockertypes.ContainerRmConfig) error
	ContainerRename(oldName, newName string) error
}

type ContainerState

type ContainerState int32
const (
	S_CONTAINER_NONE ContainerState = iota
	S_CONTAINER_CREATING
	S_CONTAINER_CREATED
	S_CONTAINER_RUNNING
	S_CONTAINER_STOPPING
)

type ContainerStatus

type ContainerStatus struct {
	State      ContainerState
	CreatedAt  time.Time
	StartedAt  time.Time
	FinishedAt time.Time
	ExitCode   int
	Killed     bool

	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ContainerStatus) Create

func (cs *ContainerStatus) Create() error

container status transition

func (*ContainerStatus) Created

func (cs *ContainerStatus) Created(t time.Time) error

func (*ContainerStatus) IsRunning

func (cs *ContainerStatus) IsRunning() bool

func (*ContainerStatus) IsStopped

func (cs *ContainerStatus) IsStopped() bool

func (*ContainerStatus) Running

func (cs *ContainerStatus) Running(t time.Time) error

func (*ContainerStatus) SetKilled

func (cs *ContainerStatus) SetKilled()

func (*ContainerStatus) Start

func (cs *ContainerStatus) Start() error

func (*ContainerStatus) Stop

func (cs *ContainerStatus) Stop() error

func (*ContainerStatus) Stopped

func (cs *ContainerStatus) Stopped(t time.Time, exitCode int) bool

func (*ContainerStatus) UnexpectedStopped

func (cs *ContainerStatus) UnexpectedStopped() bool

type Exec

type Exec struct {
	Id        string
	Container string
	Cmds      []string
	Terminal  bool
	ExitCode  uint8
	// contains filtered or unexported fields
}

func (*Exec) Log

func (e *Exec) Log(level hlog.LogLevel, args ...interface{})

func (*Exec) LogPrefix

func (e *Exec) LogPrefix() string

type GlobalLogConfig

type GlobalLogConfig struct {
	*apitypes.PodLogConfig
	PathPrefix  string
	PodIdInPath bool
}

type Interface

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

func (*Interface) Log

func (inf *Interface) Log(level hlog.LogLevel, args ...interface{})

func (*Interface) LogPrefix

func (inf *Interface) LogPrefix() string

type LogStatus

type LogStatus struct {
	Copier  *logger.Copier
	Driver  logger.Logger
	LogPath string
}

type PodFactory

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

func NewPodFactory

func NewPodFactory(vmFactory factory.Factory, registry *PodList, db *daemondb.DaemonDB, sd PodStorage, eng ContainerEngine, logCfg *GlobalLogConfig) *PodFactory

type PodFilterOp

type PodFilterOp func(*XPod) bool

type PodList

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

func NewPodList

func NewPodList() *PodList

func (*PodList) CountAll

func (pl *PodList) CountAll() int64

func (*PodList) CountContainers

func (pl *PodList) CountContainers() (num int64)

func (*PodList) CountRunning

func (pl *PodList) CountRunning() int64

func (*PodList) CountStatus

func (pl *PodList) CountStatus(status PodState) (num int64)

func (*PodList) Find

func (pl *PodList) Find(fn PodFilterOp) *XPod

func (*PodList) Foreach

func (pl *PodList) Foreach(fn PodOp) error

func (*PodList) Get

func (pl *PodList) Get(id string) (*XPod, bool)

func (*PodList) GetByContainerId

func (pl *PodList) GetByContainerId(cid string) (*XPod, bool)

func (*PodList) GetByContainerIdOrName

func (pl *PodList) GetByContainerIdOrName(cid string) (*XPod, string, bool)

func (*PodList) Release

func (pl *PodList) Release(id string)

func (*PodList) ReleaseContainer

func (pl *PodList) ReleaseContainer(id, name string)

func (*PodList) ReleaseContainerName

func (pl *PodList) ReleaseContainerName(name string)

func (*PodList) ReserveContainer

func (pl *PodList) ReserveContainer(id, name, pod string) error

func (*PodList) ReserveContainerID

func (pl *PodList) ReserveContainerID(id, pod string) error

func (*PodList) ReserveContainerName

func (pl *PodList) ReserveContainerName(name, pod string) error

func (*PodList) ReservePod

func (pl *PodList) ReservePod(p *XPod) error

type PodOp

type PodOp func(*XPod) error

type PodState

type PodState int32

PodState is the state of a Pod/Sandbox. in the current implementation, we assume the sandbox could be spawned fast enough and we don't need to pre-create a sandbox in the Pod view (or say, App view).

const (
	S_POD_NONE     PodState = iota // DEFAULT
	S_POD_STARTING                 // vm context exist
	S_POD_RUNNING                  // sandbox inited,
	S_POD_PAUSED
	S_POD_STOPPED  // vm stopped, no vm associated
	S_POD_STOPPING // user initiates a stop/remove pod command
	S_POD_ERROR    // failed to stop/remove...
)

type PodStorage

type PodStorage interface {
	Type() string

	PrepareContainer(mountId, sharedDir string, readonly bool) (*runv.VolumeDescription, error)
	CleanupContainer(id, sharedDir string) error
	InjectFile(src io.Reader, containerId, target, baseDir string, perm, uid, gid int) error
	CreateVolume(podId string, spec *apitypes.UserVolume) error
	RemoveVolume(podId string, record []byte) error
}

type Record

type Record struct {
	Hosts string
	IP    string
}

Record Structure for a single host record

func (Record) WriteTo

func (r Record) WriteTo(w io.Writer) (int64, error)

WriteTo writes record to file and returns bytes written or error

type Services

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

func (*Services) Log

func (s *Services) Log(level hlog.LogLevel, args ...interface{})

func (*Services) LogPrefix

func (s *Services) LogPrefix() string

type StreamCloser added in v0.8.1

type StreamCloser struct {
	*broadcaster.Unbuffered
}

func (*StreamCloser) Close added in v0.8.1

func (sc *StreamCloser) Close() error

type StreamConfig

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

StreamConfig holds information about I/O streams managed together.

streamConfig.StdinPipe returns a WriteCloser which can be used to feed data to the standard input of the streamConfig's active process. streamConfig.StdoutPipe and streamConfig.StderrPipe each return a ReadCloser which can be used to retrieve the standard output (and error) generated by the container's active process. The output (and error) are actually copied and delivered to all StdoutPipe and StderrPipe consumers, using a kind of "broadcaster".

func NewStreamConfig

func NewStreamConfig() *StreamConfig

NewStreamConfig creates a stream config and initializes the standard err and standard out to new unbuffered broadcasters.

func (*StreamConfig) CloseStreams

func (streamConfig *StreamConfig) CloseStreams() error

CloseStreams ensures that the configured streams are properly closed.

func (*StreamConfig) NewInputPipes

func (streamConfig *StreamConfig) NewInputPipes()

NewInputPipes creates new pipes for both standard inputs, Stdin and StdinPipe.

func (*StreamConfig) NewNopInputPipe

func (streamConfig *StreamConfig) NewNopInputPipe()

NewNopInputPipe creates a new input pipe that will silently drop all messages in the input.

func (*StreamConfig) Stderr

func (streamConfig *StreamConfig) Stderr() io.WriteCloser

Stderr returns the standard error in the configuration.

func (*StreamConfig) StderrPipe

func (streamConfig *StreamConfig) StderrPipe() io.ReadCloser

StderrPipe creates a new io.ReadCloser with an empty bytes pipe. It adds this new err pipe to the Stderr broadcaster.

func (*StreamConfig) Stdin

func (streamConfig *StreamConfig) Stdin() io.ReadCloser

Stdin returns the standard input in the configuration.

func (*StreamConfig) StdinPipe

func (streamConfig *StreamConfig) StdinPipe() io.WriteCloser

StdinPipe returns an input writer pipe as an io.WriteCloser.

func (*StreamConfig) Stdout

func (streamConfig *StreamConfig) Stdout() io.WriteCloser

Stdout returns the standard output in the configuration.

func (*StreamConfig) StdoutPipe

func (streamConfig *StreamConfig) StdoutPipe() io.ReadCloser

StdoutPipe creates a new io.ReadCloser with an empty bytes pipe. It adds this new out pipe to the Stdout broadcaster.

type Volume

type Volume struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Volume) Info

func (v *Volume) Info() *apitypes.PodVolume

func (*Volume) Log

func (v *Volume) Log(level hlog.LogLevel, args ...interface{})

func (*Volume) LogPrefix

func (v *Volume) LogPrefix() string

type VolumeState

type VolumeState int32
const (
	S_VOLUME_CREATED VolumeState = iota
	S_VOLUME_INSERTING
	S_VOLUME_INSERTED
	S_VOLUME_ERROR
)

type XPod

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

XPod is the Pod keeper, or, the App View of a sandbox. All API for Pod operations or Container operations should be provided by this struct.

func CreateXPod

func CreateXPod(factory *PodFactory, spec *apitypes.UserPod) (*XPod, error)

func LoadXPod

func LoadXPod(factory *PodFactory, layout *types.PersistPodLayout) (*XPod, error)

func (*XPod) AddPortMapping added in v1.0.0

func (p *XPod) AddPortMapping(spec []*apitypes.PortMapping) error

func (*XPod) AddService

func (p *XPod) AddService(srvs []*apitypes.UserService) error

func (*XPod) Attach

func (p *XPod) Attach(cid string, stdin io.ReadCloser, stdout io.WriteCloser, rsp chan<- error) error

func (*XPod) BriefStatus

func (p *XPod) BriefStatus() (s *apitypes.PodListResult)

func (*XPod) CleanupExecs

func (p *XPod) CleanupExecs()

func (*XPod) ContainerBriefStatus

func (p *XPod) ContainerBriefStatus(cid string) *apitypes.ContainerListResult

func (*XPod) ContainerCreate

func (p *XPod) ContainerCreate(c *apitypes.UserContainer) (string, error)

func (*XPod) ContainerHasTty

func (p *XPod) ContainerHasTty(cid string) bool

func (*XPod) ContainerId2Name

func (p *XPod) ContainerId2Name(id string) string

func (*XPod) ContainerIds

func (p *XPod) ContainerIds() []string

func (*XPod) ContainerInfo

func (p *XPod) ContainerInfo(cid string) (*apitypes.ContainerInfo, error)

func (*XPod) ContainerLogger

func (p *XPod) ContainerLogger(id string) logger.Logger

func (*XPod) ContainerName2Id

func (p *XPod) ContainerName2Id(name string) (string, bool)

func (*XPod) ContainerNames

func (p *XPod) ContainerNames() []string

func (*XPod) ContainerStart

func (p *XPod) ContainerStart(cid string) error

func (*XPod) ContainerStatusString

func (p *XPod) ContainerStatusString(cid string) string

func (*XPod) CreateExec

func (p *XPod) CreateExec(containerId, cmds string, terminal bool) (string, error)

func (*XPod) DelayDeleteOn

func (p *XPod) DelayDeleteOn() bool

func (*XPod) DeleteExec

func (p *XPod) DeleteExec(containerId, execId string)

func (*XPod) DeleteService

func (p *XPod) DeleteService(srvs []*apitypes.UserService) error

func (*XPod) Dissociate

func (p *XPod) Dissociate() error

func (*XPod) ExecVM

func (p *XPod) ExecVM(cmd string, stdin io.ReadCloser, stdout, stderr io.WriteCloser) (int, error)

func (*XPod) ForceQuit

func (p *XPod) ForceQuit()

func (*XPod) GetExecExitCode

func (p *XPod) GetExecExitCode(containerId, execId string) (uint8, error)

func (*XPod) GetExitCode

func (p *XPod) GetExitCode(cid, execId string) (uint8, error)

func (*XPod) GetServices

func (p *XPod) GetServices() ([]*apitypes.UserService, error)

func (*XPod) Id

func (p *XPod) Id() string

func (*XPod) Info

func (p *XPod) Info() (*apitypes.PodInfo, error)

func (*XPod) IsAlive

func (p *XPod) IsAlive() bool

func (*XPod) IsContainerAlive

func (p *XPod) IsContainerAlive(cid string) bool

func (*XPod) IsContainerRunning

func (p *XPod) IsContainerRunning(cid string) bool

func (*XPod) IsNone

func (p *XPod) IsNone() bool

func (*XPod) IsRunning

func (p *XPod) IsRunning() bool

func (*XPod) IsStopped added in v0.8.1

func (p *XPod) IsStopped() bool

func (*XPod) KillContainer

func (p *XPod) KillContainer(id string, sig int64) error

func (*XPod) KillExec

func (p *XPod) KillExec(execId string, sig int64) error

func (*XPod) ListPortMappings added in v1.0.0

func (p *XPod) ListPortMappings() []*apitypes.PortMapping

func (*XPod) Log

func (p *XPod) Log(level hlog.LogLevel, args ...interface{})

Log() employ `github.com/hyperhq/hypercontainer-utils/hlog.HLog` to add pod information to the log

func (*XPod) LogPrefix

func (p *XPod) LogPrefix() string

LogPrefix() belongs to the interface `github.com/hyperhq/hypercontainer-utils/hlog.LogOwner`, which helps `hlog.HLog` get proper prefix from the owner object.

func (*XPod) Name

func (p *XPod) Name() string

func (*XPod) Pause

func (p *XPod) Pause() error

func (*XPod) Remove

func (p *XPod) Remove(force bool) error

func (*XPod) RemoveContainer

func (p *XPod) RemoveContainer(id string) error

func (*XPod) RemovePortMappingByDest added in v1.0.0

func (p *XPod) RemovePortMappingByDest(spec []*apitypes.PortMapping) error

func (*XPod) RemovePortMappingStricted added in v1.0.0

func (p *XPod) RemovePortMappingStricted(spec []*apitypes.PortMapping) error

func (*XPod) RenameContainer

func (p *XPod) RenameContainer(cid, name string) error

func (*XPod) SandboxBriefStatus

func (p *XPod) SandboxBriefStatus() (s *apitypes.VMListResult)

func (*XPod) SandboxName

func (p *XPod) SandboxName() string

SandboxName() returns the id of the sandbox, the detail of sandbox should be wrapped inside XPod, this method is used for list/display only.

func (*XPod) SandboxNameLocked added in v1.1.0

func (p *XPod) SandboxNameLocked() string

func (*XPod) SandboxStatusString

func (p *XPod) SandboxStatusString() string

func (*XPod) SetLabel

func (p *XPod) SetLabel(labels map[string]string, update bool) error

func (*XPod) Start

func (p *XPod) Start() error

Start() means start a STOPPED pod.

func (*XPod) StartExec

func (p *XPod) StartExec(stdin io.ReadCloser, stdout io.WriteCloser, containerId, execId string) error

func (*XPod) Stats

func (p *XPod) Stats() *runvtypes.PodStats

func (*XPod) StatusString

func (p *XPod) StatusString() string

func (*XPod) Stop

func (p *XPod) Stop(graceful int) error

func (*XPod) StopContainer

func (p *XPod) StopContainer(id string, graceful int) error

func (*XPod) TtyResize

func (p *XPod) TtyResize(cid, execId string, h, w int) error

func (*XPod) UnPause

func (p *XPod) UnPause() error

func (*XPod) UpdateService

func (p *XPod) UpdateService(srvs []*apitypes.UserService) error

func (*XPod) WaitContainer

func (p *XPod) WaitContainer(cid string, second int) (int, error)

Jump to

Keyboard shortcuts

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