Documentation ¶
Index ¶
- Constants
- Variables
- func IsUnitExist(rootdir, name string) bool
- func StartUnit(rootdir, podname, hostname, unitname, workingdir, netns string, ...) error
- type Config
- type HealthConfig
- type LogPipe
- type Unit
- func (u *Unit) CreateCommand(command []string, args []string) []string
- func (u *Unit) Destroy() error
- func (u *Unit) GetEnv() []string
- func (u *Unit) GetRootfs() string
- func (u *Unit) GetStatus() (*api.UnitStatus, error)
- func (u *Unit) GetUser(lookup util.UserLookup) (uid, gid uint32, groups []uint32, homedir string, err error)
- func (u *Unit) GetWorkingDir() string
- func (u *Unit) OpenStdinReader() (io.ReadCloser, error)
- func (u *Unit) OpenStdinWriter() (io.WriteCloser, error)
- func (u *Unit) PullAndExtractImage(image, server, username, password string) error
- func (u *Unit) Run(podname, hostname string, command []string, workingdir string, ...) error
- func (u *Unit) RunUnitLoop(command, caplist []string, uid, gid uint32, groups []uint32, unitin io.Reader, ...) (err error)
- func (u *Unit) SaveUnitConfig(unitConfig UnitConfig) error
- func (u *Unit) SetImage(image string) error
- func (u *Unit) SetState(state api.UnitState, restarts *int) error
- func (u *Unit) SetStatus(status *api.UnitStatus) error
- func (u *Unit) SetUnitConfigOverlayfs(useOverlayfs bool)
- func (u *Unit) UpdateStatusAttr(ready, started *bool) error
- type UnitConfig
- type UnitManager
- func (um *UnitManager) CaptureLogs(podName, unitName string, lp *LogPipe)
- func (um *UnitManager) GetLogBuffer(unit string) (*logbuf.LogBuffer, error)
- func (um *UnitManager) GetPid(unitName string) (int, bool)
- func (um *UnitManager) ReadLogBuffer(unit string, n int) ([]logbuf.LogEntry, error)
- func (um *UnitManager) RemoveUnit(name string) error
- func (um *UnitManager) StartUnit(podname, hostname, unitname, workingdir, netns string, ...) error
- func (um *UnitManager) StopUnit(name string) error
- func (um *UnitManager) UnitRunning(unit string) bool
Constants ¶
const ( PIPE_UNIT_STDOUT = "unit-stdout" PIPE_UNIT_STDERR = "unit-stderr" )
const ( MAX_BACKOFF_TIME = 5 * time.Minute BACKOFF_RESET_TIME = 10 * time.Minute CHILD_OOM_SCORE = 15 // chosen arbitrarily... kernel will adjust this value MaxContainerTerminationMessageLength = 1024 * 4 )
Variables ¶
var ( // The kubelet stores container logfiles in this directory. To make it // easier to configure logging agents on cells, we use the same directory. ContainerLogDir = "/var/log/containers" // Sleep length to allow log pipe to drain before closing LOG_PIPE_FINISH_READ_SLEEP = time.Second * 3 )
var UNIT_PIPES = []string{PIPE_UNIT_STDOUT, PIPE_UNIT_STDERR}
Functions ¶
func IsUnitExist ¶
Types ¶
type Config ¶
type Config struct { Hostname string Domainname string User string AttachStdin bool AttachStdout bool AttachStderr bool ExposedPorts map[string]struct{} `json:",omitempty"` Tty bool OpenStdin bool StdinOnce bool Env []string Cmd []string Healthcheck *HealthConfig `json:",omitempty"` ArgsEscaped bool `json:",omitempty"` Image string Volumes map[string]struct{} WorkingDir string Entrypoint []string NetworkDisabled bool `json:",omitempty"` MacAddress string `json:",omitempty"` OnBuild []string Labels map[string]string StopSignal string `json:",omitempty"` StopTimeout *int `json:",omitempty"` Shell []string `json:",omitempty"` }
This is the main config struct for docker images.
type HealthConfig ¶
type HealthConfig struct { Test []string `json:",omitempty"` Interval time.Duration `json:",omitempty"` Timeout time.Duration `json:",omitempty"` StartPeriod time.Duration `json:",omitempty"` Retries int `json:",omitempty"` }
This is part of the config of docker images.
type Unit ¶
type Unit struct { *LogPipe Directory string Name string Image string // contains filtered or unexported fields }
func (*Unit) GetWorkingDir ¶
func (*Unit) OpenStdinReader ¶
func (u *Unit) OpenStdinReader() (io.ReadCloser, error)
This is only used internally to pass in an io.Reader to the process as its stdin. We also start a writer so that opening the pipe for reading won't block. This writer will be stopped via closeStdin().
func (*Unit) OpenStdinWriter ¶
func (u *Unit) OpenStdinWriter() (io.WriteCloser, error)
func (*Unit) PullAndExtractImage ¶
func (*Unit) RunUnitLoop ¶
func (*Unit) SaveUnitConfig ¶
func (u *Unit) SaveUnitConfig(unitConfig UnitConfig) error
func (*Unit) SetUnitConfigOverlayfs ¶
func (*Unit) UpdateStatusAttr ¶
type UnitConfig ¶
type UnitConfig struct { api.PodSecurityContext `json:"podSecurityContext"` api.SecurityContext `json:"securityContext"` StartupProbe *api.Probe `json:",omitempty"` ReadinessProbe *api.Probe `json:",omitempty"` LivenessProbe *api.Probe `json:",omitempty"` TerminationMessagePolicy api.TerminationMessagePolicy TerminationMessagePath string PodIP string UseOverlayfs bool }
type UnitManager ¶
type UnitManager struct { RunningUnits *conmap.StringOsProcess LogBuf *conmap.StringLogbufLogBuffer // contains filtered or unexported fields }
func NewUnitManager ¶
func NewUnitManager(rootDir string) *UnitManager
func (*UnitManager) CaptureLogs ¶
func (um *UnitManager) CaptureLogs(podName, unitName string, lp *LogPipe)
func (*UnitManager) GetLogBuffer ¶
func (um *UnitManager) GetLogBuffer(unit string) (*logbuf.LogBuffer, error)
func (*UnitManager) ReadLogBuffer ¶
func (*UnitManager) RemoveUnit ¶
func (um *UnitManager) RemoveUnit(name string) error
This removes the unit and its files/directories from the filesystem.
func (*UnitManager) StartUnit ¶
func (um *UnitManager) StartUnit(podname, hostname, unitname, workingdir, netns string, command, args, appenv []string, policy api.RestartPolicy) error
This is a bit tricky in Go, since we are not supposed to use fork(). Instead, call the daemon with command line flags indicating that it is only used as a helper to start a new unit in a new filesystem namespace.
func (*UnitManager) StopUnit ¶
func (um *UnitManager) StopUnit(name string) error
It's possible we need to set up some communication with the waiting process that it doesn't need to clean up everything. Lets see how the logging works out...
func (*UnitManager) UnitRunning ¶
func (um *UnitManager) UnitRunning(unit string) bool