package shim

import "github.com/containerd/containerd/runtime/v2/shim"

Index

Variables

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

ErrNoAddress is returned when the address file has no content

Functions

func AnonDialer

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

AnonDialer returns a dialer for a npipe

func AnonReconnectDialer

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

AnonReconnectDialer returns a dialer for an existing npipe on containerd reconnection

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 BinaryPath

func BinaryPath(runtime string) string

BinaryPath returns the full path for the shim binary from the runtime name, empty string returns means runtime name is invalid

func Command

func Command(ctx context.Context, runtime, containerdAddress, containerdTTRPCAddress, 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 ReadAddress

func ReadAddress(path string) (string, error)

ReadAddress returns the shim's socket address from the path

func RemoveSocket

func RemoveSocket(address string) error

RemoveSocket removes the socket at the specified address if it exists on the filesystem

func Run

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

Run initializes and runs a shim server

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

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

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 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

type Publisher interface {
	events.Publisher
	io.Closer
}

Publisher for events

type RemoteEventsPublisher

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

RemoteEventsPublisher forwards events to a ttrpc server

func NewPublisher

func NewPublisher(address string) (*RemoteEventsPublisher, error)

NewPublisher creates a new remote events publisher

func (*RemoteEventsPublisher) Close

func (l *RemoteEventsPublisher) Close() (err error)

Close closes the remote connection and closes the done channel

func (*RemoteEventsPublisher) Done

func (l *RemoteEventsPublisher) Done() <-chan struct{}

Done returns a channel which closes when done

func (*RemoteEventsPublisher) Publish

func (l *RemoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error

Publish publishes the event by forwarding it to the configured ttrpc server

type Shim

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

Shim server interface

type StartOpts

type StartOpts struct {
	ID               string
	ContainerdBinary string
	Address          string
	TTRPCAddress     string
}

StartOpts describes shim start configuration received from containerd

Source Files

publisher.go shim.go shim_windows.go util.go util_windows.go

Version
v1.5.5
Published
Jul 29, 2021
Platform
windows/amd64
Imports
30 packages
Last checked
4 hours ago

Tools for package owners.