runner

package
v0.0.0-...-8291241 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUserID = errors.New("invalid userid")

Functions

func Attach

func Attach(codeID, userid string, tcmd *exec.Cmd) chan struct{}

Attach registers a command for profiling

func CPUTime

func CPUTime(procid int) (ms int)

CPUTime returns the cpu time in MS

func Childrens

func Childrens(process int) []int

Childrens returns all children pids recursively

func Connect2

func Connect2(runnerip net.IP) (net.Conn, error)

Use Connect2Any and Connect2 functions to connect to a runner because they will handle wether the runner is local and in the same process or on a remote server

func Connect2Any

func Connect2Any() (net.Conn, error)

Use Connect2Any and Connect2 functions to connect to a runner because they will handle wether the runner is local and in the same process or on a remote server

func DelSubvolume

func DelSubvolume(name string) error

func DelSubvolumeAbsolute

func DelSubvolumeAbsolute(p string) error

func GetBTRFSStats

func GetBTRFSStats() ([]*btrfs.Stats, error)

func Init

func Init() error

Init must be called after objectstorage initialization

func IsBTRFSMounted

func IsBTRFSMounted(folder string) bool

func MemInfo

func MemInfo(procid int) (size, resident, shared int)

MemInfo returns info about memory for given procid

func NetInfo

func NetInfo(procid int) (ino, outo int)

NetInfo is used to get net i/o stats for a given process

func NewSubvolume

func NewSubvolume(name string, size string) (string, error)

NewSubvolume creates new btrfs subvolume with given quota

func NewSubvolumeAbsolute

func NewSubvolumeAbsolute(p string, size string) (string, error)

NewSubvolumeAbsolute does the same as NewSubvolume but with a subvolume absolute path

func PipeReadStream

func PipeReadStream(connR *bufio.Reader, w io.Writer) error

func PutConnection

func PutConnection(c net.Conn)

func ReadAllStream

func ReadAllStream(connR *bufio.Reader) ([]byte, error)

func ReadResponse

func ReadResponse(connR *bufio.Reader) (success bool, payload []byte, err error)

func Running

func Running(pid int) bool

Running cheks if pid is running

func SetQuota

func SetQuota(subvolume string, size string) error

SetQuota changes btrfs subvolume quota

func Snapshot

func Snapshot(src string, size string) (string, error)

func SnapshotAbsolute

func SnapshotAbsolute(src, dest string, size string) error

func Stop

func Stop()

func StreamReadWebsocket

func StreamReadWebsocket(r *websocket.Conn, connW *bufio.Writer) error

func StreamReader

func StreamReader(connW *bufio.Writer, r io.Reader) error

func StreamWriteWebsocket

func StreamWriteWebsocket(wr *websocket.Conn, connR *bufio.Reader) error

sockMessType is either websocket.TextMessage or websocket.BinaryMessage

func WriteCommand

func WriteCommand(connW *bufio.Writer, cmd []byte) error

Types

type BuildCommand

type BuildCommand struct {
	CodeID   string
	Image    string
	BuildCmd []string
	Env      []string
}

source code remain in the execution image you can manually delete it in build command

type DecrReq

type DecrReq struct {
	Monthyear  string
	CodeID     string
	UserID     string
	DurationMS int
	RAMGBS     float64 // ram gigabytes-seconds
	CPUS       int     // CPU seconds
	NetIngress float64 // bytes
	NetEgress  float64 // bytes
}

type ExecutionCommand

type ExecutionCommand struct {
	ExeID      string
	CodeID     string
	UserID     string
	Image      string
	ExeCmd     []string
	Env        []string
	TimeoutSec int
}

type LogCommand

type LogCommand struct {
	ExeID  string
	UserID string
}

type MessageKind

type MessageKind byte
const (
	ProxyKind   MessageKind = 1
	ExecuteKind MessageKind = 2
	BuildKind   MessageKind = 3
	GCExeKind   MessageKind = 4
	LogKind     MessageKind = 5
)

type OverlayDir

type OverlayDir struct {
	UpperDir   string
	WorkDir    string
	MountPoint string

	Mounted bool
	// contains filtered or unexported fields
}

OverlayDir is a ready to mount overlaydir and tmp dir

func NewOverlayDir

func NewOverlayDir(uid string) *OverlayDir

NewOverlayDir returns a ready to mount OverlayDir uid is the id of a btrfs subvolume

func (*OverlayDir) Kill

func (o *OverlayDir) Kill()

Kill destroys an OverlayDir and its work folder

func (*OverlayDir) Mount

func (o *OverlayDir) Mount(lowerdirs []string) error

Mount an overlayfs with specified underlying directories

func (*OverlayDir) Resize

func (o *OverlayDir) Resize(sizeM int) error

Resize changes quota for an existing overlaydir

func (*OverlayDir) Umount

func (o *OverlayDir) Umount()

type ProxyCommand

type ProxyCommand struct {
	ExeID string

	ReqType    RequestType
	Headers    map[string][]string
	Trailers   map[string][]string
	Method     string
	RemoteAddr string
	IsHTTPS    bool
	URL        string // with https replaced by http and port 8080
}

ProxyCommand is to be used for established http and websocket connections Multipart should work by streaming the entire body without calling parsemultipartform on the LB side

type RequestType

type RequestType uint8
const (
	HTTPRequest      RequestType = 1
	WebsocketRequest RequestType = 2
	SSHRequest       RequestType = 3
)

type ResponseHead

type ResponseHead struct {
	Headers    map[string][]string
	Status     string
	StatusCode int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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