Documentation ¶
Index ¶
- Constants
- Variables
- func GetMountIdByContainer(driver, cid string) (string, error)
- func HostsCreator(pod string) *utils.Initializer
- func HostsPath(pod string) (hostsDir, hostsPath string)
- func ListAllPods(db *daemondb.DaemonDB) ([][]byte, error)
- func LoadAllPods(db *daemondb.DaemonDB) chan *types.PersistPodLayout
- func MigrateLagecyPersistentData(db *daemondb.DaemonDB, podFactory func() *PodFactory) (err error)
- func ProbeExistingVolume(v *apitypes.UserVolume, sharedDir string) (*runv.VolumeDescription, error)
- func UmountExistingVolume(fstype, target, sharedDir string) error
- type Container
- func (c *Container) Add() error
- func (c *Container) AttachStreams(openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.WriteCloser, ...) error
- func (c *Container) BriefStatus() (s *apitypes.ContainerListResult)
- func (c *Container) CreatedAt() time.Time
- func (c *Container) CurrentState() ContainerState
- func (c *Container) GetExitCode() (uint8, error)
- func (c *Container) HasTty() bool
- func (c *Container) Id() string
- func (c *Container) Info() *apitypes.Container
- func (c *Container) InfoStatus() *apitypes.ContainerStatus
- func (c *Container) IsAlive() bool
- func (c *Container) IsRunning() bool
- func (c *Container) IsStopped() bool
- func (c *Container) Log(level hlog.LogLevel, args ...interface{})
- func (c *Container) LogPrefix() string
- func (c *Container) Remove() error
- func (c *Container) RuntimeName() string
- func (c *Container) SpecName() string
- func (c *Container) StatusString() string
- type ContainerEngine
- type ContainerState
- type ContainerStatus
- func (cs *ContainerStatus) Create() error
- func (cs *ContainerStatus) Created(t time.Time) error
- func (cs *ContainerStatus) IsRunning() bool
- func (cs *ContainerStatus) IsStopped() bool
- func (cs *ContainerStatus) Running(t time.Time) error
- func (cs *ContainerStatus) SetKilled()
- func (cs *ContainerStatus) Start() error
- func (cs *ContainerStatus) Stop() error
- func (cs *ContainerStatus) Stopped(t time.Time, exitCode int) bool
- func (cs *ContainerStatus) UnexpectedStopped() bool
- type Exec
- type GlobalLogConfig
- type Interface
- type LogStatus
- type PodFactory
- type PodFilterOp
- type PodList
- func (pl *PodList) CountAll() int64
- func (pl *PodList) CountContainers() (num int64)
- func (pl *PodList) CountRunning() int64
- func (pl *PodList) CountStatus(status PodState) (num int64)
- func (pl *PodList) Find(fn PodFilterOp) *XPod
- func (pl *PodList) Foreach(fn PodOp) error
- func (pl *PodList) Get(id string) (*XPod, bool)
- func (pl *PodList) GetByContainerId(cid string) (*XPod, bool)
- func (pl *PodList) GetByContainerIdOrName(cid string) (*XPod, string, bool)
- func (pl *PodList) Release(id string)
- func (pl *PodList) ReleaseContainer(id, name string)
- func (pl *PodList) ReleaseContainerName(name string)
- func (pl *PodList) ReserveContainer(id, name, pod string) error
- func (pl *PodList) ReserveContainerID(id, pod string) error
- func (pl *PodList) ReserveContainerName(name, pod string) error
- func (pl *PodList) ReservePod(p *XPod) error
- type PodOp
- type PodState
- type PodStorage
- type Record
- type Services
- type StreamCloser
- type StreamConfig
- func (streamConfig *StreamConfig) CloseStreams() error
- func (streamConfig *StreamConfig) NewInputPipes()
- func (streamConfig *StreamConfig) NewNopInputPipe()
- func (streamConfig *StreamConfig) Stderr() io.WriteCloser
- func (streamConfig *StreamConfig) StderrPipe() io.ReadCloser
- func (streamConfig *StreamConfig) Stdin() io.ReadCloser
- func (streamConfig *StreamConfig) StdinPipe() io.WriteCloser
- func (streamConfig *StreamConfig) Stdout() io.WriteCloser
- func (streamConfig *StreamConfig) StdoutPipe() io.ReadCloser
- type Volume
- type VolumeState
- type XPod
- func (p *XPod) AddPortMapping(spec []*apitypes.PortMapping) error
- func (p *XPod) AddService(srvs []*apitypes.UserService) error
- func (p *XPod) Attach(cid string, stdin io.ReadCloser, stdout io.WriteCloser, rsp chan<- error) error
- func (p *XPod) BriefStatus() (s *apitypes.PodListResult)
- func (p *XPod) CleanupExecs()
- func (p *XPod) ContainerBriefStatus(cid string) *apitypes.ContainerListResult
- func (p *XPod) ContainerCreate(c *apitypes.UserContainer) (string, error)
- func (p *XPod) ContainerHasTty(cid string) bool
- func (p *XPod) ContainerId2Name(id string) string
- func (p *XPod) ContainerIds() []string
- func (p *XPod) ContainerInfo(cid string) (*apitypes.ContainerInfo, error)
- func (p *XPod) ContainerLogger(id string) logger.Logger
- func (p *XPod) ContainerName2Id(name string) (string, bool)
- func (p *XPod) ContainerNames() []string
- func (p *XPod) ContainerStart(cid string) error
- func (p *XPod) ContainerStatusString(cid string) string
- func (p *XPod) CreateExec(containerId, cmds string, terminal bool) (string, error)
- func (p *XPod) DelayDeleteOn() bool
- func (p *XPod) DeleteExec(containerId, execId string)
- func (p *XPod) DeleteService(srvs []*apitypes.UserService) error
- func (p *XPod) Dissociate() error
- func (p *XPod) ExecVM(cmd string, stdin io.ReadCloser, stdout, stderr io.WriteCloser) (int, error)
- func (p *XPod) ForceQuit()
- func (p *XPod) GetExecExitCode(containerId, execId string) (uint8, error)
- func (p *XPod) GetExitCode(cid, execId string) (uint8, error)
- func (p *XPod) GetServices() ([]*apitypes.UserService, error)
- func (p *XPod) Id() string
- func (p *XPod) Info() (*apitypes.PodInfo, error)
- func (p *XPod) IsAlive() bool
- func (p *XPod) IsContainerAlive(cid string) bool
- func (p *XPod) IsContainerRunning(cid string) bool
- func (p *XPod) IsNone() bool
- func (p *XPod) IsRunning() bool
- func (p *XPod) IsStopped() bool
- func (p *XPod) KillContainer(id string, sig int64) error
- func (p *XPod) KillExec(execId string, sig int64) error
- func (p *XPod) ListPortMappings() []*apitypes.PortMapping
- func (p *XPod) Log(level hlog.LogLevel, args ...interface{})
- func (p *XPod) LogPrefix() string
- func (p *XPod) Name() string
- func (p *XPod) Pause() error
- func (p *XPod) Remove(force bool) error
- func (p *XPod) RemoveContainer(id string) error
- func (p *XPod) RemovePortMappingByDest(spec []*apitypes.PortMapping) error
- func (p *XPod) RemovePortMappingStricted(spec []*apitypes.PortMapping) error
- func (p *XPod) RenameContainer(cid, name string) error
- func (p *XPod) SandboxBriefStatus() (s *apitypes.VMListResult)
- func (p *XPod) SandboxName() string
- func (p *XPod) SandboxNameLocked() string
- func (p *XPod) SandboxStatusString() string
- func (p *XPod) SetLabel(labels map[string]string, update bool) error
- func (p *XPod) Start() error
- func (p *XPod) StartExec(stdin io.ReadCloser, stdout io.WriteCloser, containerId, execId string) error
- func (p *XPod) Stats() *runvtypes.PodStats
- func (p *XPod) StatusString() string
- func (p *XPod) Stop(graceful int) error
- func (p *XPod) StopContainer(id string, graceful int) error
- func (p *XPod) TtyResize(cid, execId string, h, w int) error
- func (p *XPod) UnPause() error
- func (p *XPod) UpdateService(srvs []*apitypes.UserService) error
- func (p *XPod) WaitContainer(cid string, second int) (int, error)
Constants ¶
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" )
const ( //The Log level for Pods TRACE = hlog.TRACE DEBUG = hlog.DEBUG INFO = hlog.INFO WARNING = hlog.WARNING ERROR = hlog.ERROR )
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 ¶
var DetachError error = fmt.Errorf("DetachError")
var DetachKeys = "ctrl-p,ctrl-q"
var (
ProvisionTimeout = 5 * time.Minute
)
Functions ¶
func GetMountIdByContainer ¶
func HostsCreator ¶
func HostsCreator(pod string) *utils.Initializer
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 ¶
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) 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) GetExitCode ¶
func (*Container) InfoStatus ¶
func (c *Container) InfoStatus() *apitypes.ContainerStatus
func (*Container) RuntimeName ¶
func (*Container) StatusString ¶
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) IsRunning ¶
func (cs *ContainerStatus) IsRunning() bool
func (*ContainerStatus) IsStopped ¶
func (cs *ContainerStatus) IsStopped() bool
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 GlobalLogConfig ¶
type GlobalLogConfig struct { *apitypes.PodLogConfig PathPrefix string PodIdInPath bool }
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 PodList ¶
type PodList struct {
// contains filtered or unexported fields
}
func NewPodList ¶
func NewPodList() *PodList
func (*PodList) CountContainers ¶
func (*PodList) CountRunning ¶
func (*PodList) CountStatus ¶
func (*PodList) Find ¶
func (pl *PodList) Find(fn PodFilterOp) *XPod
func (*PodList) GetByContainerIdOrName ¶
func (*PodList) ReleaseContainer ¶
func (*PodList) ReleaseContainerName ¶
func (*PodList) ReserveContainer ¶
func (*PodList) ReserveContainerID ¶
func (*PodList) ReserveContainerName ¶
func (*PodList) ReservePod ¶
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).
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 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 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 (*XPod) ContainerId2Name ¶
func (*XPod) ContainerIds ¶
func (*XPod) ContainerInfo ¶
func (p *XPod) ContainerInfo(cid string) (*apitypes.ContainerInfo, error)
func (*XPod) ContainerNames ¶
func (*XPod) ContainerStart ¶
func (*XPod) ContainerStatusString ¶
func (*XPod) CreateExec ¶
func (*XPod) DelayDeleteOn ¶
func (*XPod) DeleteExec ¶
func (*XPod) DeleteService ¶
func (p *XPod) DeleteService(srvs []*apitypes.UserService) error
func (*XPod) Dissociate ¶
func (*XPod) ExecVM ¶
func (p *XPod) ExecVM(cmd string, stdin io.ReadCloser, stdout, stderr io.WriteCloser) (int, error)
func (*XPod) GetExecExitCode ¶
func (*XPod) GetServices ¶
func (p *XPod) GetServices() ([]*apitypes.UserService, error)
func (*XPod) IsContainerAlive ¶
func (*XPod) IsContainerRunning ¶
func (*XPod) ListPortMappings ¶ added in v1.0.0
func (p *XPod) ListPortMappings() []*apitypes.PortMapping
func (*XPod) Log ¶
Log() employ `github.com/hyperhq/hypercontainer-utils/hlog.HLog` to add pod information to the log
func (*XPod) LogPrefix ¶
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) RemoveContainer ¶
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 (*XPod) SandboxBriefStatus ¶
func (p *XPod) SandboxBriefStatus() (s *apitypes.VMListResult)
func (*XPod) SandboxName ¶
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 (*XPod) SandboxStatusString ¶
func (*XPod) StartExec ¶
func (p *XPod) StartExec(stdin io.ReadCloser, stdout io.WriteCloser, containerId, execId string) error
func (*XPod) StatusString ¶
func (*XPod) UpdateService ¶
func (p *XPod) UpdateService(srvs []*apitypes.UserService) error