Documentation
¶
Index ¶
- Constants
- Variables
- func FormatMessage(payload interface{}) ([]byte, error)
- func SendIoMessageWithConn(conn net.Conn, ttyMsg *TtyMessage) error
- func SetLogger(logger logrus.FieldLogger)
- type Capabilities
- type Constraints
- type Container
- type DecodedMessage
- type EnvironmentVar
- type ExecCommand
- type FileCommand
- type FsmapDescriptor
- type Hyperstart
- func (h *Hyperstart) CheckReturnedCode(recvMsg *DecodedMessage, expectedCode uint32) error
- func (h *Hyperstart) CloseSockets() error
- func (h *Hyperstart) CodeFromCmd(cmd string) (uint32, error)
- func (h *Hyperstart) GetCtlSock() net.Conn
- func (h *Hyperstart) GetCtlSockPath() string
- func (h *Hyperstart) GetIoSock() net.Conn
- func (h *Hyperstart) GetIoSockPath() string
- func (h *Hyperstart) GetSockType() string
- func (h *Hyperstart) IsStarted() bool
- func (h *Hyperstart) OpenSockets() error
- func (h *Hyperstart) OpenSocketsNoMulticast() error
- func (h *Hyperstart) ReadIoMessage() (*TtyMessage, error)
- func (h *Hyperstart) SendCtlMessage(cmd string, data []byte) (*DecodedMessage, error)
- func (h *Hyperstart) SendIoMessage(ttyMsg *TtyMessage) error
- func (h *Hyperstart) SetDeadline(t time.Time) error
- func (h *Hyperstart) WaitForPAE(containerID, processID string) (*PAECommand, error)
- func (h *Hyperstart) WaitForReady() error
- func (h *Hyperstart) WriteCtlMessage(conn net.Conn, m *DecodedMessage) error
- type IPAddress
- type KillCommand
- type NetworkIface
- type PAECommand
- type Process
- type PsCommand
- type RemoveCommand
- type Rlimit
- type Route
- type Sandbox
- type SystemMountsInfo
- type TtyMessage
- type VolumeDescriptor
- type WindowSizeMessage
Constants ¶
const ( Version = "version" StartSandbox = "startsandbox" DestroySandbox = "destroysandbox" ExecCmd = "execcmd" Ready = "ready" Ack = "ack" Error = "error" WinSize = "winsize" Ping = "ping" FinishSandbox = "finishsandbox" Next = "next" WriteFile = "writefile" ReadFile = "readfile" NewContainer = "newcontainer" KillContainer = "killcontainer" OnlineCPUMem = "onlinecpumem" SetupInterface = "setupinterface" SetupRoute = "setuproute" RemoveContainer = "removecontainer" PsContainer = "pscontainer" )
Control command IDs Need to be in sync with hyperstart/src/api.h
const ( CtlHdrSize = 8 CtlHdrLenOffset = 4 )
Values related to the communication on control channel.
const ( TtyHdrSize = 12 TtyHdrLenOffset = 8 )
Values related to the communication on tty channel.
const ( VersionCode = iota StartSandboxCode GetSandboxDeprecatedCode StopSandboxDeprecatedCode DestroySandboxCode RestartContainerDeprecatedCode ExecCmdCode FinishCmdDeprecatedCode ReadyCode AckCode ErrorCode WinsizeCode PingCode FinishSandboxDeprecatedCode NextCode WriteFileCode ReadFileCode NewContainerCode KillContainerCode OnlineCPUMemCode SetupInterfaceCode SetupRouteCode RemoveContainerCode PsContainerCode ProcessAsyncEventCode )
Defines all available commands to communicate with hyperstart agent.
Variables ¶
var CodeList = map[string]uint32{ Version: VersionCode, StartSandbox: StartSandboxCode, DestroySandbox: DestroySandboxCode, ExecCmd: ExecCmdCode, Ready: ReadyCode, Ack: AckCode, Error: ErrorCode, WinSize: WinsizeCode, Ping: PingCode, Next: NextCode, WriteFile: WriteFileCode, ReadFile: ReadFileCode, NewContainer: NewContainerCode, KillContainer: KillContainerCode, OnlineCPUMem: OnlineCPUMemCode, SetupInterface: SetupInterfaceCode, SetupRoute: SetupRouteCode, RemoveContainer: RemoveContainerCode, PsContainer: PsContainerCode, }
CodeList is the map making the relation between a string command and its corresponding code.
Functions ¶
func FormatMessage ¶
FormatMessage formats hyperstart messages.
func SendIoMessageWithConn ¶
func SendIoMessageWithConn(conn net.Conn, ttyMsg *TtyMessage) error
SendIoMessageWithConn sends data to the specified IO channel.
func SetLogger ¶
func SetLogger(logger logrus.FieldLogger)
SetLogger sets the logger for hyperstart package.
Types ¶
type Capabilities ¶
type Capabilities struct {
// Bounding is the set of capabilities checked by the kernel.
Bounding []string `json:"bounding"`
// Effective is the set of capabilities checked by the kernel.
Effective []string `json:"effective"`
// Inheritable is the capabilities preserved across execve.
Inheritable []string `json:"inheritable"`
// Permitted is the limiting superset for effective capabilities.
Permitted []string `json:"permitted"`
// Ambient is the ambient set of capabilities that are kept.
Ambient []string `json:"ambient"`
}
Capabilities specify the capabilities to keep when executing the process inside the container.
type Constraints ¶
type Constraints struct {
// CPUQuota specifies the total amount of time in microseconds
// The number of microseconds per CPUPeriod that the container is guaranteed CPU access
CPUQuota int64
// CPUPeriod specifies the CPU CFS scheduler period of time in microseconds
CPUPeriod uint64
CPUShares uint64
}
Constraints describes the constrains for a container
type Container ¶
type Container struct {
ID string `json:"id"`
Rootfs string `json:"rootfs"`
Fstype string `json:"fstype,omitempty"`
Image string `json:"image"`
SCSIAddr string `json:"scsiAddr,omitempty"`
Volumes []*VolumeDescriptor `json:"volumes,omitempty"`
Fsmap []*FsmapDescriptor `json:"fsmap,omitempty"`
Sysctl map[string]string `json:"sysctl,omitempty"`
Process *Process `json:"process"`
RestartPolicy string `json:"restartPolicy"`
Initialize bool `json:"initialize"`
SystemMountsInfo SystemMountsInfo `json:"systemMountsInfo"`
Constraints Constraints `json:"constraints"`
}
Container describes a container running on a sandbox.
type DecodedMessage ¶
DecodedMessage is the structure holding messages coming from CTL channel.
func ReadCtlMessage ¶
func ReadCtlMessage(conn net.Conn) (*DecodedMessage, error)
ReadCtlMessage reads an hyperstart message from conn and returns a decoded message.
This is a low level function, for a full and safe transaction on the hyperstart control serial link, use SendCtlMessage.
type EnvironmentVar ¶
EnvironmentVar holds an environment variable and its value.
type ExecCommand ¶
type ExecCommand struct {
Container string `json:"container,omitempty"`
Process Process `json:"process"`
}
ExecCommand is the structure corresponding to the format expected by hyperstart to execute a command on the guest.
type FileCommand ¶
FileCommand is the structure corresponding to the format expected by hyperstart to interact with files.
type FsmapDescriptor ¶
type FsmapDescriptor struct {
Source string `json:"source"`
Path string `json:"path"`
ReadOnly bool `json:"readOnly"`
DockerVolume bool `json:"dockerVolume"`
AbsolutePath bool `json:"absolutePath"`
SCSIAddr string `json:"scsiAddr"`
}
FsmapDescriptor describes a filesystem map related to a container.
type Hyperstart ¶
type Hyperstart struct {
// contains filtered or unexported fields
}
Hyperstart is the base structure for hyperstart.
func NewHyperstart ¶
func NewHyperstart(ctlSerial, ioSerial, sockType string) *Hyperstart
NewHyperstart returns a new hyperstart structure.
func (*Hyperstart) CheckReturnedCode ¶
func (h *Hyperstart) CheckReturnedCode(recvMsg *DecodedMessage, expectedCode uint32) error
CheckReturnedCode ensures we did not receive an ERROR code.
func (*Hyperstart) CloseSockets ¶
func (h *Hyperstart) CloseSockets() error
CloseSockets closes both CTL and IO sockets.
func (*Hyperstart) CodeFromCmd ¶
func (h *Hyperstart) CodeFromCmd(cmd string) (uint32, error)
CodeFromCmd translates a string command to its corresponding code.
func (*Hyperstart) GetCtlSock ¶
func (h *Hyperstart) GetCtlSock() net.Conn
GetCtlSock returns the internal CTL sock.
func (*Hyperstart) GetCtlSockPath ¶
func (h *Hyperstart) GetCtlSockPath() string
GetCtlSockPath returns the internal CTL sock path.
func (*Hyperstart) GetIoSock ¶
func (h *Hyperstart) GetIoSock() net.Conn
GetIoSock returns the internal IO sock.
func (*Hyperstart) GetIoSockPath ¶
func (h *Hyperstart) GetIoSockPath() string
GetIoSockPath returns the internal IO sock path.
func (*Hyperstart) GetSockType ¶
func (h *Hyperstart) GetSockType() string
GetSockType returns the internal sock type.
func (*Hyperstart) IsStarted ¶
func (h *Hyperstart) IsStarted() bool
IsStarted returns about connection status.
func (*Hyperstart) OpenSockets ¶
func (h *Hyperstart) OpenSockets() error
OpenSockets opens both CTL and IO sockets.
func (*Hyperstart) OpenSocketsNoMulticast ¶
func (h *Hyperstart) OpenSocketsNoMulticast() error
OpenSocketsNoMulticast opens both CTL and IO sockets, without starting the multicast.
func (*Hyperstart) ReadIoMessage ¶
func (h *Hyperstart) ReadIoMessage() (*TtyMessage, error)
ReadIoMessage returns data coming from the IO channel.
func (*Hyperstart) SendCtlMessage ¶
func (h *Hyperstart) SendCtlMessage(cmd string, data []byte) (*DecodedMessage, error)
SendCtlMessage sends a message to the CTL channel.
This function does a full transaction over the CTL channel: it will rely on the multicaster to register a listener reading over the CTL channel. Then it writes a command and waits for the multicaster to send hyperstart's answer back before it can return. Several concurrent calls to SendCtlMessage are allowed, the function ensuring proper serialization of the communication by making the listener registration and the command writing an atomic operation protected by a mutex. Waiting for the reply from multicaster doesn't need to be protected by this mutex.
func (*Hyperstart) SendIoMessage ¶
func (h *Hyperstart) SendIoMessage(ttyMsg *TtyMessage) error
SendIoMessage sends data to the IO channel.
func (*Hyperstart) SetDeadline ¶
func (h *Hyperstart) SetDeadline(t time.Time) error
SetDeadline sets a timeout for CTL connection.
func (*Hyperstart) WaitForPAE ¶
func (h *Hyperstart) WaitForPAE(containerID, processID string) (*PAECommand, error)
WaitForPAE waits for a PROCESSASYNCEVENT message on CTL channel.
func (*Hyperstart) WaitForReady ¶
func (h *Hyperstart) WaitForReady() error
WaitForReady waits for a READY message on CTL channel.
func (*Hyperstart) WriteCtlMessage ¶
func (h *Hyperstart) WriteCtlMessage(conn net.Conn, m *DecodedMessage) error
WriteCtlMessage writes an hyperstart message to conn.
This is a low level function, for a full and safe transaction on the hyperstart control serial link, use SendCtlMessage.
type KillCommand ¶
type KillCommand struct {
Container string `json:"container"`
Signal syscall.Signal `json:"signal"`
AllProcesses bool `json:"allProcesses"`
}
KillCommand is the structure corresponding to the format expected by hyperstart to kill a container on the guest.
type NetworkIface ¶
type NetworkIface struct {
Device string `json:"device,omitempty"`
NewDevice string `json:"newDeviceName,omitempty"`
IPAddresses []IPAddress `json:"ipAddresses"`
MTU int `json:"mtu"`
MACAddr string `json:"macAddr"`
}
NetworkIface describes a network interface to setup on the host.
type PAECommand ¶
type PAECommand struct {
Container string `json:"container"`
Process string `json:"process"`
Event string `json:"event"`
Info string `json:"info,omitempty"`
Status int `json:"status,omitempty"`
}
PAECommand is the structure hyperstart can expects to receive after a process has been started/executed on a container.
type Process ¶
type Process struct {
// Args specifies the binary and arguments for the application to execute.
Args []string `json:"args"`
// Rlimits specifies rlimit options to apply to the process.
Rlimits []Rlimit `json:"rlimits,omitempty"`
// Envs populates the process environment for the process.
Envs []EnvironmentVar `json:"envs,omitempty"`
AdditionalGroups []string `json:"additionalGroups,omitempty"`
// Workdir is the current working directory for the process and must be
// relative to the container's root.
Workdir string `json:"workdir"`
User string `json:"user,omitempty"`
Group string `json:"group,omitempty"`
// Sequeue number for stdin and stdout
Stdio uint64 `json:"stdio,omitempty"`
// Sequeue number for stderr if it is not shared with stdout
Stderr uint64 `json:"stderr,omitempty"`
// NoNewPrivileges indicates that the process should not gain any additional privileges
Capabilities Capabilities `json:"capabilities"`
NoNewPrivileges bool `json:"noNewPrivileges"`
// Capabilities specifies the sets of capabilities for the process(es) inside the container.
// Terminal creates an interactive terminal for the process.
Terminal bool `json:"terminal"`
}
Process describes a process running on a container inside a sandbox.
type PsCommand ¶
type PsCommand struct {
Container string `json:"container"`
Format string `json:"format"`
PsArgs []string `json:"psargs"`
}
PsCommand is the structure corresponding to the format expected by hyperstart to list processes of a container on the guest.
type RemoveCommand ¶
type RemoveCommand struct {
Container string `json:"container"`
}
RemoveCommand is the structure corresponding to the format expected by hyperstart to remove a container on the guest.
type Rlimit ¶
type Rlimit struct {
// Type of the rlimit to set
Type string `json:"type"`
// Hard is the hard limit for the specified type
Hard uint64 `json:"hard"`
// Soft is the soft limit for the specified type
Soft uint64 `json:"soft"`
}
Rlimit describes a resource limit.
type Route ¶
type Route struct {
Dest string `json:"dest"`
Gateway string `json:"gateway,omitempty"`
Device string `json:"device,omitempty"`
}
Route describes a route to setup on the host.
type Sandbox ¶
type Sandbox struct {
Hostname string `json:"hostname"`
Containers []Container `json:"containers,omitempty"`
Interfaces []NetworkIface `json:"interfaces,omitempty"`
DNS []string `json:"dns,omitempty"`
Routes []Route `json:"routes,omitempty"`
}
Sandbox describes the sandbox configuration to start inside the VM.
type SystemMountsInfo ¶
type SystemMountsInfo struct {
// Indicates if /dev has been passed as a bind mount for the host /dev
BindMountDev bool `json:"bindMountDev"`
// Size of /dev/shm assigned on the host.
DevShmSize int `json:"devShmSize"`
}
SystemMountsInfo describes additional information for system mounts that the agent needs to handle
type TtyMessage ¶
TtyMessage is the structure holding messages coming from TTY channel.
func ReadIoMessageWithConn ¶
func ReadIoMessageWithConn(conn net.Conn) (*TtyMessage, error)
ReadIoMessageWithConn returns data coming from the specified IO channel.
type VolumeDescriptor ¶
type VolumeDescriptor struct {
Device string `json:"device"`
Addr string `json:"addr,omitempty"`
Mount string `json:"mount"`
Fstype string `json:"fstype,omitempty"`
ReadOnly bool `json:"readOnly"`
DockerVolume bool `json:"dockerVolume"`
}
VolumeDescriptor describes a volume related to a container.