api

package
v0.9.222 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 76 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CRIU_DUMP_LOG_FILE  = "cedana-dump.log"
	CRIU_DUMP_LOG_LEVEL = 4
	GHOST_LIMIT         = 10000000
	DUMP_FOLDER_PERMS   = 0o700

	K8S_RUNC_ROOT     = "/run/containerd/runc/k8s.io"
	DOCKER_RUNC_ROOT  = "/run/docker/runtime-runc/moby"
	DEFAULT_RUNC_ROOT = "/run/runc"
)
View Source
const (
	IMG_STREAMER_CAPTURE_SOCKET_NAME = "ced-capture.sock"
	IMG_STREAMER_SERVE_SOCKET_NAME   = "ced-serve.sock"
	O_DUMP                           = 577
	O_RSTR                           = 578
)
View Source
const (
	OUTPUT_FILE_PATH  string      = "/var/log/cedana-output.log"
	OUTPUT_FILE_PERMS os.FileMode = 0o777
	OUTPUT_FILE_FLAGS int         = os.O_WRONLY | os.O_CREATE | os.O_TRUNC
)
View Source
const (
	CRIU_RESTORE_LOG_FILE        = "cedana-restore.log"
	CRIU_RESTORE_LOG_LEVEL       = 4
	RESTORE_TEMPDIR              = "/tmp/cedana_restore"
	RESTORE_TEMPDIR_PERMS        = 0o755
	RESTORE_OUTPUT_LOG_PATH      = "/var/log/cedana-output-%s.log"
	KATA_RESTORE_OUTPUT_LOG_PATH = "/tmp/cedana-output-%s.log"
	KATA_TAR_FILE_RECEIVER_PORT  = 9998
)
View Source
const (
	ADDRESS                     = "0.0.0.0:8080"
	PROTOCOL                    = "tcp"
	CEDANA_CONTAINER_NAME       = "binary-container"
	SERVER_LOG_MODE             = os.O_APPEND | os.O_CREATE | os.O_WRONLY
	SERVER_LOG_PERMS            = 0o644
	GPU_CONTROLLER_LOG_PATH     = "/tmp/cedana-gpucontroller.log"
	VSOCK_PORT                  = 9999
	GPU_CONTROLLER_WAIT_TIMEOUT = 5 * time.Second
)
View Source
const (
	PROCESS_STREAMING_RATE_SECONDS = 30
	LOG_STREAMING_RATE_SECONDS     = 10
)
View Source
const CHECKPOINT_STATE_FILE = "checkpoint_state.json"
View Source
const CRIU_VERSION_MIN = 31700
View Source
const MaxNameLen = 4096

Variables

View Source
var Address = "0.0.0.0:8080"
View Source
var DB_BUCKET_JOBS = []byte("jobs")
View Source
var SystemIdentifier = fmt.Sprintf("%d-%d-%d", rand.Uint64(), rand.Uint64(), rand.Uint64())

SystemIdentifier initialization defaults to using rand so that in case we fail to find and update with proper machine id it still works

Functions

func CheckTCPConnections

func CheckTCPConnections(pid int32) (bool, error)

checks if the given process has any active tcp connections

func NewMemoryStorage added in v0.9.222

func NewMemoryStorage() (*memory.InMemoryCache, error)

func SendFile

func SendFile(socket *os.File, file *os.File) error

SendFile sends a file over the given AF_UNIX socket. file.Name() is also included so that if the other end uses RecvFile, the file will have the same name information.

func SendRawFd

func SendRawFd(socket *os.File, msg string, fd uintptr) error

SendRawFd sends a specific file descriptor over the given AF_UNIX socket.

func SetupCadvisor added in v0.9.222

func SetupCadvisor(ctx context.Context) (manager.Manager, error)

func StartServer

func StartServer(cmdCtx context.Context, opts *ServeOpts) error

Takes in a context that allows for cancellation from the cmdline

func WriteJSON

func WriteJSON(w io.Writer, v interface{}) error

WriteJSON writes the provided struct v to w using standard json marshaling without a trailing newline. This is used instead of json.Encoder because there might be a problem in json decoder in some cases, see: https://github.com/docker/docker/issues/14203#issuecomment-174177790

Types

type Bundle

type Bundle struct {
	ContainerID string
	Bundle      string
}

The bundle includes path to bundle and the runc/podman container id of the bundle. The bundle is a folder that includes the oci spec config.json as well as the rootfs used for setting up the container. Sometimes rootfs can be defined elsewhere. Podman adds extra directories and files in their bundle including a file called attach which is a unix socket for attaching stdin, stdout to the terminal

type Criu

type Criu struct{}

Code for interfacing with CRIU. We could use go-criu, but there are certain limitations in the abstractions presented. Most of the code found here is lifted from https://github.com/checkpoint-restore/go-criu/blob/master/main.go.

func (*Criu) Check

func (c *Criu) Check() (string, error)

func (*Criu) Dump

func (c *Criu) Dump(opts *rpc.CriuOpts, nfy *Notify) (*rpc.CriuResp, error)

Dump dumps a process

func (*Criu) GetCriuVersion

func (c *Criu) GetCriuVersion() (int, error)

func (*Criu) IsCriuAtLeast

func (c *Criu) IsCriuAtLeast(version int) (bool, error)

IsCriuAtLeast checks if the version is at least the same as the parameter version

func (*Criu) Restore

func (c *Criu) Restore(opts *rpc.CriuOpts, nfy *Notify, extraFiles []*os.File) (*rpc.CriuResp, error)

Restore restores a process

type Notify

type Notify struct {
	Logger         *zerolog.Logger
	PreDumpFunc    NotifyFunc
	PostDumpFunc   NotifyFunc
	PreRestoreFunc NotifyFunc
	PreResumeFunc  NotifyFunc
}

func (Notify) NetworkLock

func (n Notify) NetworkLock() error

NetworkLock NoNotify

func (Notify) NetworkUnlock

func (n Notify) NetworkUnlock() error

NetworkUnlock NoNotify

func (Notify) PostDump

func (n Notify) PostDump() error

func (Notify) PostRestore

func (n Notify) PostRestore(pid int32) error

PostRestore NoNotify

func (Notify) PostResume

func (n Notify) PostResume() error

PostResume NoNotify

func (Notify) PostSetupNamespaces

func (n Notify) PostSetupNamespaces() error

PostSetupNamespaces NoNotify

func (Notify) PreDump

func (n Notify) PreDump() error

func (Notify) PreRestore

func (n Notify) PreRestore() error

func (Notify) PreResume

func (n Notify) PreResume() error

func (Notify) SetupNamespaces

func (n Notify) SetupNamespaces(pid int32) error

SetupNamespaces NoNotify

type NotifyFunc

type NotifyFunc struct {
	Avail    bool
	Callback func() error
}

type OCIBundle

type OCIBundle struct {
	// ID of the bundle
	ID string
	// Path to the bundle
	Path string
	// Namespace of the bundle
	Namespace string
}

Bundle represents an OCI bundle

func NewBundle

func NewBundle(ctx context.Context, root, state, id string, spec typeurl.Any) (b *OCIBundle, err error)

NewBundle returns a new bundle on disk

type ServeOpts

type ServeOpts struct {
	GPUEnabled   bool
	CUDAVersion  string
	VSOCKEnabled bool
	CedanaURL    string
	GrpcPort     uint64
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, opts *ServeOpts) (*Server, error)

Directories

Path Synopsis
gpu
rpc

Jump to

Keyboard shortcuts

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