shim

package
v1.3.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Monitor{
	subscribers: make(map[chan runc.Exit]struct{}),
}

Default is the default monitor initialized for the package

View Source
var ErrNoAddress = errors.New("no shim address")

ErrNoAddress is returned when the address file has no content

View Source
var ErrNoSuchProcess = errors.New("no such process")

ErrNoSuchProcess is returned when the process no longer exists

Functions

func AdjustOOMScore added in v1.3.0

func AdjustOOMScore(pid int) error

AdjustOOMScore sets the OOM score for the process to the parents OOM score +1 to ensure that they parent has a lower* score than the shim

func AnonDialer

func AnonDialer(address string, timeout time.Duration) (net.Conn, error)

AnonDialer returns a dialer for an abstract socket

func BinaryName

func BinaryName(runtime string) string

BinaryName returns the shim binary name from the runtime name, empty string returns means runtime name is invalid

func Command

func Command(ctx context.Context, runtime, containerdAddress, path string, opts *types.Any, cmdArgs ...string) (*exec.Cmd, error)

Command returns the shim command with the provided args and configuration

func Connect

func Connect(address string, d func(string, time.Duration) (net.Conn, error)) (net.Conn, error)

Connect to the provided address

func NewSocket

func NewSocket(address string) (*net.UnixListener, error)

NewSocket returns a new socket

func ReadAddress added in v1.3.0

func ReadAddress(path string) (string, error)

ReadAddress returns the shim's abstract socket address from the path

func Reap

func Reap() error

Reap should be called when the process receives an SIGCHLD. Reap will reap all exited processes and close their wait channels

func Run

func Run(id string, initFunc Init, opts ...BinaryOpts)

Run initializes and runs a shim server

func SetScore

func SetScore(pid int) error

SetScore sets the oom score for a process

func SocketAddress

func SocketAddress(ctx context.Context, id string) (string, error)

SocketAddress returns an abstract socket address

func WriteAddress

func WriteAddress(path, address string) error

WriteAddress writes a address file atomically

func WritePidFile

func WritePidFile(path string, pid int) error

WritePidFile writes a pid file atomically

Types

type BinaryOpts added in v1.3.0

type BinaryOpts func(*Config)

BinaryOpts allows the configuration of a shims binary setup

type Client

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

Client for a shim server

func NewShimClient

func NewShimClient(ctx context.Context, svc shimapi.TaskService, signals chan os.Signal) *Client

NewShimClient creates a new shim server client

func (*Client) Serve

func (s *Client) Serve() error

Serve the shim server

type Config added in v1.3.0

type Config struct {
	// NoSubreaper disables setting the shim as a child subreaper
	NoSubreaper bool
	// NoReaper disables the shim binary from reaping any child process implicitly
	NoReaper bool
	// NoSetupLogger disables automatic configuration of logrus to use the shim FIFO
	NoSetupLogger bool
}

Config of shim binary options provided by shim implementations

type Init

type Init func(context.Context, string, Publisher, func()) (Shim, error)

Init func for the creation of a shim server

type Monitor

type Monitor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Monitor monitors the underlying system for process status changes

func (*Monitor) Start

func (m *Monitor) Start(c *exec.Cmd) (chan runc.Exit, error)

Start starts the command a registers the process with the reaper

func (*Monitor) Subscribe

func (m *Monitor) Subscribe() chan runc.Exit

Subscribe to process exit changes

func (*Monitor) Unsubscribe

func (m *Monitor) Unsubscribe(c chan runc.Exit)

Unsubscribe to process exit changes

func (*Monitor) Wait

func (m *Monitor) Wait(c *exec.Cmd, ec chan runc.Exit) (int, error)

Wait blocks until a process is signal as dead. User should rely on the value of the exit status to determine if the command was successful or not.

type Opts

type Opts struct {
	BundlePath string
	Debug      bool
}

Opts are context options associated with the shim invocation.

type OptsKey

type OptsKey struct{}

OptsKey is the context key for the Opts value.

type Publisher added in v1.3.0

type Publisher interface {
	events.Publisher
	io.Closer
}

Publisher for events

type Shim

type Shim interface {
	shimapi.TaskService
	Cleanup(ctx context.Context) (*shimapi.DeleteResponse, error)
	StartShim(ctx context.Context, id, containerdBinary, containerdAddress string) (string, error)
}

Shim server interface

Jump to

Keyboard shortcuts

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