pod

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

package pod contains the data structure for the pod and functions to get information of the pod. It is shared by other packages, including the CLI implementation, api service, and the library.

Index

Constants

View Source
const (
	Embryo         = "embryo"
	Preparing      = "preparing"
	AbortedPrepare = "aborted prepare"
	Prepared       = "prepared"
	Running        = "running"
	Deleting       = "deleting"
	ExitedDeleting = "exited deleting"
	Exited         = "exited"
	ExitedGarbage  = "exited garbage"
	Garbage        = "garbage"
)

Exported state. See Documentation/devel/pod-lifecycle.md for some explanation

Variables

This section is empty.

Functions

func ReadUUIDFromFile

func ReadUUIDFromFile(path string) (string, error)

ReadUUIDFromFile reads the uuid string from the given path.

func WalkPods

func WalkPods(dataDir string, include IncludeMask, f func(*Pod)) error

WalkPods iterates over the included directories calling function f for every pod found. The pod will be closed after the function 'f' is executed.

func WriteUUIDToFile

func WriteUUIDToFile(uuid *types.UUID, path string) error

WriteUUIDToFile writes the uuid string to the given path.

Types

type ErrChildNotReady

type ErrChildNotReady struct {
}

func (ErrChildNotReady) Error

func (e ErrChildNotReady) Error() string

type IncludeMask

type IncludeMask byte
const (
	IncludeEmbryoDir IncludeMask = 1 << iota
	IncludePrepareDir
	IncludePreparedDir
	IncludeRunDir
	IncludeExitedGarbageDir
	IncludeGarbageDir

	IncludeMostDirs IncludeMask = (IncludeRunDir | IncludeExitedGarbageDir | IncludePrepareDir | IncludePreparedDir)
	IncludeAllDirs  IncludeMask = (IncludeMostDirs | IncludeEmbryoDir | IncludeGarbageDir)
)

type Pod

type Pod struct {
	UUID       *types.UUID
	Nets       []netinfo.NetInfo // list of networks (name, IP, iface) this pod is using
	MountLabel string            // Label to use for container image

	*lock.FileLock
	// contains filtered or unexported fields
}

func NewPod

func NewPod(dataDir string) (*Pod, error)

NewPod creates a new pod directory in the "preparing" state, allocating a unique uuid for it in the process. The returned pod is always left in an exclusively locked state (preparing is locked in the prepared directory) The pod must be closed using pod.Close()

func PodFromUUIDString

func PodFromUUIDString(dataDir, uuid string) (*Pod, error)

PodFromUUIDString attempts to resolve the supplied UUID and return a pod. The pod must be closed using pod.Close()

func (*Pod) AfterRun

func (p *Pod) AfterRun() bool

AfterRun returns true if the pod is in a post-running state, otherwise it returns false.

func (*Pod) AppExitCode

func (p *Pod) AppExitCode(appName string) (int, error)

AppExitCode returns the app's exit code. It returns an error if the exit code file doesn't exit or the content of the file is invalid.

func (*Pod) AppImageManifest

func (p *Pod) AppImageManifest(appName string) (*schema.ImageManifest, error)

AppImageManifest returns an ImageManifest for the app.

func (*Pod) ContainerPid1

func (p *Pod) ContainerPid1() (pid int, err error)

ContainerPid1 returns the pid of the process with pid 1 in the pod.

func (*Pod) CreationTime

func (p *Pod) CreationTime() (time.Time, error)

CreationTime returns the time when the pod was created. This happens at prepare time.

func (*Pod) GCMarkedTime

func (p *Pod) GCMarkedTime() (time.Time, error)

GCMarkedTime returns the time when the pod is marked by gc.

func (*Pod) GetAppTreeStoreID

func (p *Pod) GetAppTreeStoreID(app types.ACName) (string, error)

GetAppTreeStoreID returns the treeStoreID of the provided app. TODO(yifan): Maybe make this unexported.

func (*Pod) GetAppsTreeStoreIDs

func (p *Pod) GetAppsTreeStoreIDs() ([]string, error)

GetAppsTreeStoreIDs returns the treeStoreIDs of the apps images used in this pod. TODO(yifan): Maybe make this unexported.

func (*Pod) GetStage1TreeStoreID

func (p *Pod) GetStage1TreeStoreID() (string, error)

GetStage1TreeStoreID returns the treeStoreID of the stage1 image used in this pod TODO(yifan): Maybe make this unexported.

func (*Pod) JournalLogPath

func (p *Pod) JournalLogPath() (string, error)

JournalLogPath returns the path to the journal log dir of the pod.

func (*Pod) Path

func (p *Pod) Path() string

Path returns the path to the pod according to the current (cached) state.

func (*Pod) Pid

func (p *Pod) Pid() (int, error)

Pid returns the pid of the stage1 process that started the pod.

func (*Pod) PodManifest

func (p *Pod) PodManifest() ([]byte, *schema.PodManifest, error)

PodManifest reads the pod manifest, returns the raw bytes and the unmarshalled object.

func (*Pod) Stage1RootfsPath

func (p *Pod) Stage1RootfsPath() (string, error)

Stage1RootfsPath returns the stage1 path of the pod.

func (*Pod) StartTime

func (p *Pod) StartTime() (time.Time, error)

StartTime returns the time when the pod was started.

func (*Pod) State

func (p *Pod) State() string

State returns the current state of the pod

func (*Pod) Sync

func (p *Pod) Sync() error

Sync syncs the pod data. By now it calls a syncfs on the filesystem containing the pod's directory.

func (*Pod) ToExitedGarbage

func (p *Pod) ToExitedGarbage() error

ToExitedGarbage transitions a pod from run -> exitedGarbage

func (*Pod) ToGarbage

func (p *Pod) ToGarbage() error

ToGarbage transitions a pod from abortedPrepared -> garbage or prepared -> garbage

func (*Pod) ToPrepared

func (p *Pod) ToPrepared() error

ToPrepared transitions a pod from preparing -> prepared, leaves the pod unlocked in the prepared directory. only the creator of the pod (via newPod()) may do this, nobody to race with.

func (*Pod) ToPreparing

func (p *Pod) ToPreparing() error

ToPrepare transitions a pod from embryo -> preparing, leaves the pod locked in the prepare directory. only the creator of the pod (via newPod()) may do this, nobody to race with.

func (*Pod) ToRun

func (p *Pod) ToRun() error

ToRun transitions a pod from prepared -> run, leaves the pod locked in the run directory. the creator of the pod (via newPod()) may also jump directly from preparing -> run

func (*Pod) UsesOverlay

func (p *Pod) UsesOverlay() bool

UsesOverlay returns whether the pod Uses overlayfs. TODO(yifan): Maybe make this function unexported.

func (*Pod) WaitExited

func (p *Pod) WaitExited() error

WaitExited waits for a pod to (run and) exit.

Jump to

Keyboard shortcuts

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