runcext

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvNameProcSyncPipe = "_RUNCEXT_PROC_SYNC_PIPE"
View Source
var RuntimeExtCommand = "embedshim-runcext"

Functions

func NewSocketPair

func NewSocketPair(name string) (*os.File, *os.File, error)

func ParseProcSync

func ParseProcSync(pipe io.Reader, fn func(*ProcSync) error) error

func ReadProcSync

func ReadProcSync(r io.Reader, expected ProcSyncType) error

func RuncExecOptsArgs

func RuncExecOptsArgs(opts *runc.ExecOpts) (out []string, err error)

RuncExecOptsArgs is based on

func RuntimeCommand

func RuntimeCommand(ctx context.Context, ext bool, r *runc.Runc, args ...string) *exec.Cmd

RuntimeCommand is based on github.com/containerd/go-runc@v1.0.0/command_linux.go

func WriteProcSyncMessage

func WriteProcSyncMessage(w io.Writer, msg ProcSync) error

Types

type PidFile

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

PidFile is used to read pid from file named by --pid-file option.

func NewPidFile

func NewPidFile(p string) *PidFile

func (*PidFile) Path

func (p *PidFile) Path() string

func (*PidFile) Read

func (p *PidFile) Read() (int, error)

type ProcSync

type ProcSync struct {
	Type         ProcSyncType `json:"type"`
	Pid          uint32       `json:"pid"`
	Exited       bool         `json:"exited"`
	ExitedStatus uint32       `json:"exited_status"`
	Message      string       `json:"message,omitempty"`
}

func NewProcSyncErrorMessage

func NewProcSyncErrorMessage(err error) ProcSync

func NewProcSyncExecPidDoneMessage

func NewProcSyncExecPidDoneMessage() ProcSync

func NewProcSyncExecPidMessage

func NewProcSyncExecPidMessage(pid uint32) ProcSync

func NewProcSyncExecStatusDoneMessage

func NewProcSyncExecStatusDoneMessage() ProcSync

func NewProcSyncExecStatusMessage

func NewProcSyncExecStatusMessage(exited bool, status uint32) ProcSync

type ProcSyncType

type ProcSyncType string

ProcSyncType is used for synchronisation between parent and child process during setup containers exec processes.

Since the exec process doesn't like container init which has two-steps to setup, we need a wrapper runc-exec commandline to setup pidfd exit event monitor like what we does for runc-init.

NOTE: The design is based on runc's syncType from commit[1].

[1] https://github.com/opencontainers/runc/blob/899342b5d49434611635d64f64c343e2a1aeee0a/libcontainer/sync.go

const (
	ProcSyncError ProcSyncType = "error"

	// [ runc-exec-ext(child)]		     [     parent     ]
	//
	// 	SyncExecPid		-->	           read pid
	//
	//				<--             SyncExecPidDone
	//
	//    SyncExecPidStatus		-->	      exec current status
	//
	//				<--	       SyncExecPidStatusDone
	//
	// NOTE:
	//
	// The commit[1] only supports pidfd type on waitid, not including
	// the non-parent support. We need one extra step to check exec process
	// is still alive. In the future, pidfd_wait[2] API can support waitid
	// by non-parent process.
	//
	// [1] https://github.com/torvalds/linux/commit/3695eae5fee0605f316fbaad0b9e3de791d7dfaf
	// [2] https://lwn.net/Articles/794707/
	ProcSyncExecPid        ProcSyncType = "execPid"
	ProcSyncExecPidDone    ProcSyncType = "execPidDone"
	ProcSyncExecStatus     ProcSyncType = "execStatus"
	ProcSyncExecStatusDone ProcSyncType = "execStatusDone"
)

Jump to

Keyboard shortcuts

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