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
- Variables
- func ReadUUIDFromFile(path string) (string, error)
- func WalkPods(dataDir string, include IncludeMask, f func(*Pod)) error
- func WriteUUIDToFile(uuid *types.UUID, path string) error
- type ErrChildNotReady
- type IncludeMask
- type Pod
- func (p *Pod) AppExitCode(appName string) (int, error)
- func (p *Pod) AppImageManifest(appName string) (*schema.ImageManifest, error)
- func (p *Pod) ContainerPid1() (pid int, err error)
- func (p *Pod) CreationTime() (time.Time, error)
- func (p *Pod) ExclusiveLockManifest() error
- func (p *Pod) GCMarkedTime() (time.Time, error)
- func (p *Pod) GetAppTreeStoreID(app types.ACName) (string, error)
- func (p *Pod) GetAppsTreeStoreIDs() ([]string, error)
- func (p *Pod) GetStage1TreeStoreID() (string, error)
- func (p *Pod) IsAfterRun() bool
- func (p *Pod) IsFinished() bool
- func (p *Pod) IsMutable() bool
- func (p *Pod) IsSupervisorReady() bool
- func (p *Pod) JournalLogPath() (string, error)
- func (p *Pod) Path() string
- func (p *Pod) Pid() (int, error)
- func (p *Pod) PodManifest() ([]byte, *schema.PodManifest, error)
- func (p *Pod) PodManifestAvailable() bool
- func (p *Pod) SandboxManifest() (*schema.PodManifest, error)
- func (p *Pod) Stage1RootfsPath() (string, error)
- func (p *Pod) StartTime() (time.Time, error)
- func (p *Pod) State() string
- func (p *Pod) Sync() error
- func (p *Pod) ToExitedGarbage() error
- func (p *Pod) ToGarbage() error
- func (p *Pod) ToPrepared() error
- func (p *Pod) ToPreparing() error
- func (p *Pod) ToRun() error
- func (p *Pod) UnlockManifest() error
- func (p *Pod) UpdateManifest(m *schema.PodManifest, path string) error
- func (p *Pod) UsesOverlay() bool
- func (p *Pod) WaitFinished(ctx context.Context) error
- func (p *Pod) WaitReady(ctx context.Context) error
Constants ¶
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 ¶
var ErrImmutable = errors.New("immutable pod")
ErrImmutable is the error that is returned by SandboxManifest if the pod is immutable, hence changes on the pod manifest are not allowed.
Functions ¶
func ReadUUIDFromFile ¶
ReadUUIDFromFile reads the uuid string from 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 // the lock for the whole pod // contains filtered or unexported fields }
Pod is the struct that reflects a pod and its lifecycle. It provides the necessary methods for state transitions and methods for querying internal state.
Unless documented otherwise methods do not refresh the pod state as it is reflected on the file system but only the pod state at the point where this struct was created.
See Documentation/devel/pod-lifecycle.md for some explanation.
func NewPod ¶
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 ¶
PodFromUUIDString attempts to resolve the supplied UUID and return a pod. The pod must be closed using pod.Close()
func (*Pod) AppExitCode ¶
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 ¶
ContainerPid1 returns the pid of the process with pid 1 in the pod. Note: This method blocks indefinitely and refreshes the pod state.
func (*Pod) CreationTime ¶
CreationTime returns the time when the pod was created. This happens at prepare time.
func (*Pod) ExclusiveLockManifest ¶ added in v1.22.0
ExclusiveLockManifest gets an exclusive lock on only the pod manifest in the app sandbox. Since the pod is already running, we won't be able to get an exclusive lock on the pod itself.
func (*Pod) GCMarkedTime ¶
GCMarkedTime returns the time when the pod is marked by gc.
func (*Pod) GetAppTreeStoreID ¶
GetAppTreeStoreID returns the treeStoreID of the provided app. TODO(yifan): Maybe make this unexported.
func (*Pod) GetAppsTreeStoreIDs ¶
GetAppsTreeStoreIDs returns the treeStoreIDs of the apps images used in this pod. TODO(yifan): Maybe make this unexported.
func (*Pod) GetStage1TreeStoreID ¶
GetStage1TreeStoreID returns the treeStoreID of the stage1 image used in this pod TODO(yifan): Maybe make this unexported.
func (*Pod) IsAfterRun ¶ added in v1.22.0
IsAfterRun returns true if the pod is in a post-running state, otherwise it returns false.
func (*Pod) IsFinished ¶ added in v1.22.0
IsFinished returns true if the pod is in a terminal state, else false.
func (*Pod) IsSupervisorReady ¶ added in v1.21.0
IsSupervisorReady checks if the pod supervisor (typically systemd-pid1) has reached its ready state. All errors are handled as non-readiness.
func (*Pod) JournalLogPath ¶
JournalLogPath returns the path to the journal log dir of 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) PodManifestAvailable ¶ added in v1.20.0
PodManifestAvailable returns whether the caller should reasonably expect PodManifest to function in the pod's current state. Namely, in Preparing, AbortedPrepare, and Deleting it's possible for the manifest to not be present
func (*Pod) SandboxManifest ¶ added in v1.22.0
func (p *Pod) SandboxManifest() (*schema.PodManifest, error)
SandboxManifest loads the underlying pod manifest and checks whether mutable operations are allowed. It returns ErrImmutable if the pod does not allow mutable operations or any other error if the operation failed. Upon success a reference to the pod manifest is returned and mutable operations are possible.
func (*Pod) Stage1RootfsPath ¶
Stage1RootfsPath returns the stage1 path of the pod.
func (*Pod) Sync ¶
Sync syncs the pod data. By now it calls a syncfs on the filesystem containing the pod's directory.
func (*Pod) ToExitedGarbage ¶
ToExitedGarbage transitions a pod from run -> exitedGarbage This method refreshes the pod state.
func (*Pod) ToGarbage ¶
ToGarbage transitions a pod from abortedPrepared -> garbage or prepared -> garbage This method refreshes the pod state.
func (*Pod) ToPrepared ¶
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. This method refreshes the pod state.
func (*Pod) ToPreparing ¶
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. This method refreshes the pod state.
func (*Pod) ToRun ¶
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 This method refreshes the pod state.
func (*Pod) UnlockManifest ¶ added in v1.22.0
UnlockManifest unlocks the pod manifest lock.
func (*Pod) UpdateManifest ¶ added in v1.22.0
func (p *Pod) UpdateManifest(m *schema.PodManifest, path string) error
UpdateManifest updates the given pod manifest in the given path atomically on the file system. The pod manifest has to be locked using LockManifest first to avoid races in case of concurrent writes.
func (*Pod) UsesOverlay ¶
UsesOverlay returns whether the pod Uses overlayfs. TODO(yifan): Maybe make this function unexported.
func (*Pod) WaitFinished ¶ added in v1.22.0
WaitFinished waits for a pod to finish by polling every 100 milliseconds or until the given context is cancelled. This method refreshes the pod state. It is the caller's responsibility to determine the actual terminal state.