xfn

package
v1.14.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package xfn is the reference implementation of Composition Functions.

Index

Constants

View Source
const (
	UserNamespaceUIDs = 65536
	UserNamespaceGIDs = 65536
	MaxStdioBytes     = 100 << 20 // 100 MB
)

How many UIDs and GIDs to map from the parent to the child user namespace, if possible. Doing so requires CAP_SETUID and CAP_SETGID.

Variables

This section is empty.

Functions

func HasCapSetGID

func HasCapSetGID() bool

HasCapSetGID returns true if this process has CAP_SETGID.

func HasCapSetUID

func HasCapSetUID() bool

HasCapSetUID returns true if this process has CAP_SETUID.

Types

type ContainerRunner

type ContainerRunner struct {
	v1alpha1.UnimplementedContainerizedFunctionRunnerServiceServer
	// contains filtered or unexported fields
}

An ContainerRunner runs a Composition Function packaged as an OCI image by extracting it and running it as a 'rootless' container.

func NewContainerRunner

func NewContainerRunner(o ...ContainerRunnerOption) *ContainerRunner

NewContainerRunner returns a new Runner that runs functions as rootless containers.

func (*ContainerRunner) ListenAndServe

func (r *ContainerRunner) ListenAndServe(network, address string) error

ListenAndServe gRPC connections at the supplied address.

func (*ContainerRunner) RunFunction

RunFunction runs a function as a rootless OCI container. Functions that return non-zero, or that cannot be executed in the first place (e.g. because they cannot be fetched from the registry) will return an error.

type ContainerRunnerOption

type ContainerRunnerOption func(*ContainerRunner)

A ContainerRunnerOption configures a new ContainerRunner.

func MapToRoot

func MapToRoot(uid, gid int) ContainerRunnerOption

MapToRoot configures what UID and GID should map to root (UID/GID 0) in the user namespace in which the function will be run.

func SetUID

func SetUID(s bool) ContainerRunnerOption

SetUID indicates that the container runner should attempt operations that require CAP_SETUID and CAP_SETGID, for example creating a user namespace that maps arbitrary UIDs and GIDs to the parent namespace.

func WithCacheDir

func WithCacheDir(d string) ContainerRunnerOption

WithCacheDir specifies the directory used for caching function images and containers.

func WithLogger

func WithLogger(l logging.Logger) ContainerRunnerOption

WithLogger configures which logger the container runner should use. Logging is disabled by default.

func WithRegistry added in v1.13.0

func WithRegistry(dr string) ContainerRunnerOption

WithRegistry specifies the default registry used to retrieve function images and containers.

type Stdio

type Stdio struct {
	Stdin  io.WriteCloser
	Stdout io.ReadCloser
	Stderr io.ReadCloser
}

Stdio can be used to read and write a command's standard I/O.

func StdioPipes

func StdioPipes(cmd *exec.Cmd, uid, gid int) (*Stdio, error)

StdioPipes creates and returns pipes that will be connected to the supplied command's stdio when it starts. It calls fchown(2) to ensure all pipes are owned by the supplied user and group ID; this ensures that the command can read and write its stdio even when xfn is running as root (in the parent namespace) and the command is not.

Jump to

Keyboard shortcuts

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