deamon

package
v0.0.0-...-a115fc4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package deamon provides pre-forked container to reduce the container create / destroy costs (about 160ms). It creates deamon within unshared container and communicate with original process using unix socket with oob for fd / pid and structs are encoded in gob format.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPath = "PATH=/usr/local/bin:/usr/bin:/bin"

	// rootfs created by bind mounting
	DefaultMounts = []*mount.Mount{
		{
			Source: "/usr",
			Target: "usr",
			Flags:  roBind,
		},
		{
			Source: "/lib",
			Target: "lib",
			Flags:  roBind,
		},
		{
			Source: "/lib64",
			Target: "lib64",
			Flags:  roBind,
		},
		{
			Source: "/bin",
			Target: "bin",
			Flags:  roBind,
		},

		{
			Source: "tmpfs",
			Target: "w",
			FsType: "tmpfs",
			Flags:  mFlag,
		},

		{
			Source: "tmpfs",
			Target: "tmp",
			FsType: "tmpfs",
			Flags:  mFlag,
		},
	}
)

default parameters. I was tend to reuse the configs but it is hard since there are some cross device symblics

Functions

func ContainerInit

func ContainerInit() (err error)

ContainerInit is called for container init process it will check if pid == 1, otherwise it is noop ContainerInit will do infinite loop on socket commands, and exits when at socket close

func GetBuffer

func GetBuffer() []byte

GetBuffer get buffer from pool

func PutBuffer

func PutBuffer(x []byte)

PutBuffer return buffer to the pool

Types

type Cmd

type Cmd struct {
	Cmd    string          // type of the cmd
	Path   string          // path (copyin / open)
	Argv   []string        // execve argv
	Envv   []string        // execve envv
	RLmits []rlimit.RLimit // execve posix rlimit
	FdExec bool            // if use fexecve (fd[0] as exec)
}

Cmd is the control message send into deamon

type ExecveParam

type ExecveParam struct {
	Args []string
	Envv []string
	Fds  []uintptr
	// fexecve fd
	ExecFile uintptr
	// POSIX Resource limit set by set rlimit
	RLimits []rlimit.RLimit
	// SyncFunc called with pid before execve
	SyncFunc func(pid int) error
}

ExecveParam is parameters to run process inside container

type Master

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

Master manages single pre-forked container

func New

func New(root string) (*Master, error)

New creates new master with underlying container

func (*Master) CopyIn

func (m *Master) CopyIn(f *os.File, p string) error

CopyIn copies file to container

func (*Master) Delete

func (m *Master) Delete(p string) error

Delete remove file from container

func (*Master) Destroy

func (m *Master) Destroy() error

Destroy kill the deamon process (with container)

func (*Master) Execve

func (m *Master) Execve(done <-chan struct{}, param *ExecveParam) (<-chan specs.TraceResult, error)

Execve runs process inside container accepts done for cancelation

func (*Master) Open

func (m *Master) Open(p string) (*os.File, error)

Open open file in container

func (*Master) Ping

func (m *Master) Ping() error

Ping send ping message to container

func (*Master) Reset

func (m *Master) Reset() error

Reset remove all from /tmp and /w

type Reply

type Reply struct {
	Error       string          // empty if no error
	ExitStatus  int             // waitpid exit status
	TraceStatus specs.TraceCode // TraceCode
}

Reply is the reply message send back to controller

Jump to

Keyboard shortcuts

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