Documentation ¶
Index ¶
- Variables
- func AdjustOOMScore(pid int) error
- func AnonDialer(address string, timeout time.Duration) (net.Conn, error)
- func AnonReconnectDialer(address string, timeout time.Duration) (net.Conn, error)
- func BinaryName(runtime string) string
- func BinaryPath(runtime string) string
- func CanConnect(address string) bool
- func Command(ctx context.Context, config *CommandConfig) (*exec.Cmd, error)
- func Connect(address string, d func(string, time.Duration) (net.Conn, error)) (net.Conn, error)
- func NewSocket(address string) (*net.UnixListener, error)
- func ReadAddress(path string) (string, error)
- func ReadRuntimeOptions[T any](reader io.Reader) (T, error)
- func RemoveSocket(address string) error
- func Run(ctx context.Context, manager Manager, opts ...BinaryOpts)
- func SocketAddress(ctx context.Context, socketPath, id string) (string, error)
- func SocketEaddrinuse(err error) bool
- func WritePidFile(path string, pid int) error
- type BinaryOpts
- type BootstrapParams
- type CommandConfig
- type Config
- type Manager
- type Opts
- type OptsKey
- type Publisher
- type RemoteEventsPublisher
- type StartOpts
- type StopStatus
- type TTRPCServerOptioner
- type TTRPCService
Constants ¶
This section is empty.
Variables ¶
var ErrNoAddress = errors.New("no shim address")
ErrNoAddress is returned when the address file has no content
Functions ¶
func AdjustOOMScore ¶
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 if not already at the maximum OOM Score
func AnonDialer ¶
AnonDialer returns a dialer for a socket
func AnonReconnectDialer ¶
AnonReconnectDialer returns a dialer for an existing socket on reconnection
func BinaryName ¶
BinaryName returns the shim binary name from the runtime name, empty string returns means runtime name is invalid
func BinaryPath ¶
BinaryPath returns the full path for the shim binary from the runtime name, empty string returns means runtime name is invalid
func CanConnect ¶
CanConnect returns true if the socket provided at the address is accepting new connections
func NewSocket ¶
func NewSocket(address string) (*net.UnixListener, error)
NewSocket returns a new socket
func ReadAddress ¶
ReadAddress returns the shim's socket address from the path
func ReadRuntimeOptions ¶
ReadRuntimeOptions reads config bytes from io.Reader and unmarshals it into the provided type. The type must be registered with typeurl.
The function will return ErrNotFound, if the config is not provided. And ErrInvalidArgument, if unable to cast the config to the provided type T.
func RemoveSocket ¶
RemoveSocket removes the socket at the specified address if it exists on the filesystem
func Run ¶
func Run(ctx context.Context, manager Manager, opts ...BinaryOpts)
Run initializes and runs a shim server.
func SocketAddress ¶
SocketAddress returns a socket address
func SocketEaddrinuse ¶
SocketEaddrinuse returns true if the provided error is caused by the EADDRINUSE error number
func WritePidFile ¶
WritePidFile writes a pid file atomically
Types ¶
type BinaryOpts ¶
type BinaryOpts func(*Config)
BinaryOpts allows the configuration of a shims binary setup
type BootstrapParams ¶
type BootstrapParams struct { // Version is the version of shim parameters (expected 2 for shim v2) Version int `json:"version"` // Address is a address containerd should use to connect to shim. Address string `json:"address"` // Protocol is either TTRPC or GRPC. Protocol string `json:"protocol"` }
BootstrapParams is a JSON payload returned in stdout from shim.Start call.
type CommandConfig ¶
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 Manager ¶
type Manager interface { Name() string Start(ctx context.Context, id string, opts StartOpts) (BootstrapParams, error) Stop(ctx context.Context, id string) (StopStatus, error) Info(ctx context.Context, optionsR io.Reader) (*types.RuntimeInfo, error) }
Manager is the interface which manages the shim process
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
type TTRPCServerOptioner ¶
type TTRPCServerOptioner interface { TTRPCService UnaryInterceptor() ttrpc.UnaryServerInterceptor }