unikontainers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const UruncConfigPath = "/etc/urunc/config.toml"

Variables

View Source
var ErrCopyDir = errors.New("can not copy a directory")
View Source
var ErrEmptyAnnotations = errors.New("spec annotations are empty")
View Source
var ErrMountpoint = errors.New("no FS is mounted in this mountpoint")
View Source
var ErrNotExistingNS = errors.New("the namespace does not exist")
View Source
var ErrNotUnikernel = errors.New("this is not a unikernel container")
View Source
var ErrQueueProxy = errors.New("this a queue proxy container")

Functions

func AwaitMessage

func AwaitMessage(listener *net.UnixListener, expectedMessage IPCMessage) error

awaitMessage opens a new connection to socketAddress and waits for a given message

func SendIPCMessage

func SendIPCMessage(socketAddress string, message IPCMessage) error

SendIPCMessage creates a new connection to socketAddress, sends the message and closes the connection

func SockAddrExists

func SockAddrExists(sockAddr string) bool

sockAddrExists returns true if if given sock address exists returns false if any error is encountered

Types

type IPCMessage

type IPCMessage string
const (
	ReexecStarted IPCMessage = "RX_START"
	AckReexec     IPCMessage = "UC_ACK"
	StartExecve   IPCMessage = "UC_START"
	StartSuccess  IPCMessage = "RX_SUCCESS"
	StartErr      IPCMessage = "RX_ERROR"

	FromReexec = true
)

type LogMetricsUruncConfig

type LogMetricsUruncConfig struct {
	Log        UruncLog        `toml:"log"`
	Timestamps UruncTimestamps `toml:"timestamps"`
}

this struct is used to parse only the log and timestamp section of the urunc config file

func ParseLogMetricsConfig

func ParseLogMetricsConfig(path string) (LogMetricsUruncConfig, error)

type UnikernelConfig

type UnikernelConfig struct {
	UnikernelType    string `json:"com.urunc.unikernel.unikernelType"`
	UnikernelVersion string `json:"com.urunc.unikernel.unikernelVersion"`
	UnikernelCmd     string `json:"com.urunc.unikernel.cmdline,omitempty"`
	UnikernelBinary  string `json:"com.urunc.unikernel.binary"`
	Hypervisor       string `json:"com.urunc.unikernel.hypervisor"`
	Initrd           string `json:"com.urunc.unikernel.initrd,omitempty"`
	Block            string `json:"com.urunc.unikernel.block,omitempty"`
	BlkMntPoint      string `json:"com.urunc.unikernel.blkMntPoint,omitempty"`
	MountRootfs      string `json:"com.urunc.unikernel.mountRootfs"`
}

A UnikernelConfig struct holds the info provided by bima image on how to execute our unikernel

func GetUnikernelConfig

func GetUnikernelConfig(bundleDir string, spec *specs.Spec) (*UnikernelConfig, error)

GetUnikernelConfig tries to get the Unikernel config from the bundle annotations. If that fails, it gets the Unikernel config from the urunc.json file inside the rootfs. FIXME: custom annotations are unreachable, we need to investigate why to skip adding the urunc.json file For more details, see: https://github.com/urunc-dev/urunc/issues/12 GetUnikernelConfig tries to get a valid Unikernel config from the bundle annotations. If the annotations do not provide a valid config, it falls back to the urunc.json file.

func (*UnikernelConfig) Map

func (c *UnikernelConfig) Map() map[string]string

Map returns a map containing the Unikernel config data

type Unikontainer

type Unikontainer struct {
	State    *specs.State
	Spec     *specs.Spec
	BaseDir  string
	RootDir  string
	UruncCfg *UruncConfig
	Listener *net.UnixListener
	Conn     *net.UnixConn
}

Unikontainer holds the data necessary to create, manage and delete unikernel containers

func Get

func Get(containerID string, rootDir string) (*Unikontainer, error)

Get retrieves unikernel data from disk to create a Unikontainer object

func New

func New(bundlePath string, containerID string, rootDir string, cfg *UruncConfig) (*Unikontainer, error)

New parses the bundle and creates a new Unikontainer object

func (*Unikontainer) AwaitMsg

func (u *Unikontainer) AwaitMsg(msg IPCMessage) error

AwaitMessage waits for a specific message in the listener of unikontainer instance

func (*Unikontainer) Create

func (u *Unikontainer) Create(pid int) error

Create sets the Unikernel status as created, and saves the given PID in init.pid

func (*Unikontainer) CreateConn

func (u *Unikontainer) CreateConn(isReexec bool) error

CreateConn opens a new connection to a unix socket. If the caller is reexec then the new connection will refer to the uruncSock, the socket that holds messages from reexec to urunc instances If it is not the reexec process then the connection will refer to the ReexecSock, the socket that holds messages from urunc instances to the reexec process

func (*Unikontainer) CreateListener

func (u *Unikontainer) CreateListener(isReexec bool) error

CreateListener creates a new listener over a Unix socket. If the caller is reexec then the new listener will refer to the ReexecSock, the socket that holds messages from urunc instances to the reexec process If it is not the reexec process then the listener will refer to the uruncSock, the socket that holds messages from reexec to urunc instances

func (*Unikontainer) Delete

func (u *Unikontainer) Delete() error

Delete removes the containers base directory and its contents

func (*Unikontainer) DestroyConn

func (u *Unikontainer) DestroyConn(isReexec bool) error

DestroyListenerReexec destroys an existing listener over a socket

func (*Unikontainer) DestroyListener

func (u *Unikontainer) DestroyListener(isReexec bool) error

DestroyListener destroys an existing listener over a socket

func (*Unikontainer) Exec

func (u *Unikontainer) Exec(metrics m.Writer) error

func (*Unikontainer) ExecuteHooks

func (u *Unikontainer) ExecuteHooks(name string) error

func (*Unikontainer) FormatNsenterInfo

func (u *Unikontainer) FormatNsenterInfo() (rdr io.Reader, retErr error)

FormatNsenterInfo encodes namespace info in netlink binary format as a io.Reader, in order to send the info to nsenter. The implementation is inspired from: https://github.com/opencontainers/runc/blob/c8737446d2f99c1b7f2fcf374a7ee5b4519b2051/libcontainer/container_linux.go#L1047

func (*Unikontainer) InitialSetup

func (u *Unikontainer) InitialSetup() error

InitialSetup sets the Unikernel status as creating, creates the Unikernel base directory and saves the state.json file with the current Unikernel state

func (*Unikontainer) Kill

func (u *Unikontainer) Kill() error

Kill stops the VMM process, first by asking the VMM struct to stop and consequently by killing the process described in u.State.Pid

func (*Unikontainer) SendMessage

func (u *Unikontainer) SendMessage(message IPCMessage) error

SendMessage sends message over the active connection

func (*Unikontainer) SetRunningState

func (u *Unikontainer) SetRunningState() error

SetRunningState sets the Unikernel status as running,

func (*Unikontainer) SetupNet

func (u *Unikontainer) SetupNet() (types.NetDevParams, error)

type UruncConfig

type UruncConfig struct {
	Log        UruncLog                        `toml:"log"`
	Timestamps UruncTimestamps                 `toml:"timestamps"`
	Monitors   map[string]types.MonitorConfig  `toml:"monitors"`
	ExtraBins  map[string]types.ExtraBinConfig `toml:"extra_binaries"`
}

func LoadUruncConfig

func LoadUruncConfig(path string) (*UruncConfig, error)

LoadUruncConfig loads the urunc configuration from the specified path. If the file does not exist or is malformed, it returns the default configuration.

func UruncConfigFromMap

func UruncConfigFromMap(cfgMap map[string]string) *UruncConfig

func (*UruncConfig) Map

func (p *UruncConfig) Map() map[string]string

type UruncLog

type UruncLog struct {
	Level  string `toml:"level"`
	Syslog bool   `toml:"syslog"`
}

type UruncTimestamps

type UruncTimestamps struct {
	Enabled     bool   `toml:"enabled"`
	Destination string `toml:"destination"` // Used to specify a file for timestamps
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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