api

package
v0.9.99 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: AGPL-3.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNameLen = 4096

Variables

View Source
var AppFs = afero.NewOsFs()

wrapper over filesystem, useful for mocking in tests

Functions

func NewBoltConn

func NewBoltConn() (*bolt.DB, error)

func NewROnlyBoltConn added in v0.9.95

func NewROnlyBoltConn() (*bolt.DB, error)

func SendFile added in v0.9.5

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 added in v0.9.5

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

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

func StartGPUController added in v0.9.5

func StartGPUController(uid, gid uint32, logger *zerolog.Logger) (*exec.Cmd, error)

func StartGRPCServer

func StartGRPCServer() (*grpc.Server, error)

func WriteJSON added in v0.9.5

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 Client

type Client struct {
	CRIU *Criu
	// contains filtered or unexported fields
}

func InstantiateClient

func InstantiateClient() (*Client, error)

func (*Client) ContainerDump

func (c *Client) ContainerDump(imagePath, containerId string) error

func (*Client) ContainerRestore

func (c *Client) ContainerRestore(imgPath string, containerId string) error

func (*Client) Dump

func (c *Client) Dump(ctx context.Context, dir string, pid int32) error

func (*Client) Restore

func (c *Client) Restore(ctx context.Context, args *task.RestoreArgs) (*int32, error)

func (*Client) RuncDump

func (c *Client) RuncDump(ctx context.Context, root, containerId string, opts *container.CriuOpts) error

func (*Client) RuncRestore

func (c *Client) RuncRestore(ctx context.Context, imgPath, containerId string, isK3s bool, sources []string, opts *container.RuncOpts) error

func (*Client) SerializeStateToDir added in v0.9.5

func (c *Client) SerializeStateToDir(dir string, state *task.ProcessState) error

func (*Client) WriteOnlyFds

func (c *Client) WriteOnlyFds(openFds []*task.OpenFilesStat, pid int32) []string

WriteOnlyFds takes a snapshot of files that are open (in writeonly) by process PID and outputs full paths. For concurrent processes (multithreaded) this can be dangerous and lead to weird race conditions (maybe). To avoid actually using ptrace (TODO NR) we loop through the openFds of the process and check the flags.

type ClientLogs

type ClientLogs struct {
	Timestamp string `json:"timestamp"`
	Source    string `json:"source"`
	Level     string `json:"level"`
	Msg       string `json:"msg"`
}

type Criu added in v0.9.5

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) Dump added in v0.9.5

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

Dump dumps a process

func (*Criu) GetCriuVersion added in v0.9.5

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

func (*Criu) IsCriuAtLeast added in v0.9.5

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 added in v0.9.5

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

Restore restores a process

type DB

type DB struct {
}

func NewDB

func NewDB() *DB

func (*DB) CreateOrUpdateCedanaProcess

func (db *DB) CreateOrUpdateCedanaProcess(id string, state *task.ProcessState) error

KISS for now - but we may want to separate out into subbuckets as we add more checkpointing functionality (like incremental checkpointing or GPU checkpointing) structure is default -> xid, xid -> pid: state (arrows denote buckets)

func (*DB) GetLatestLocalCheckpoints

func (db *DB) GetLatestLocalCheckpoints(id string) ([]*string, error)

func (*DB) GetPID

func (db *DB) GetPID(id string) (int32, error)

func (*DB) GetStateFromID

func (db *DB) GetStateFromID(id string) (*task.ProcessState, error)

This automatically gets the latest entry in the job bucket

func (*DB) GetStateFromPID

func (db *DB) GetStateFromPID(pid int32) (*task.ProcessState, error)

func (*DB) UpdateProcessStateWithID

func (db *DB) UpdateProcessStateWithID(id string, state *task.ProcessState) error

func (*DB) UpdateProcessStateWithPID

func (db *DB) UpdateProcessStateWithPID(pid int32, state *task.ProcessState) error

type GrpcService

type GrpcService interface {
	Register(*grpc.Server) error
}

type KubernetesClient added in v0.9.5

type KubernetesClient struct {
}

type Notify added in v0.9.5

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

func (Notify) NetworkLock added in v0.9.5

func (n Notify) NetworkLock() error

NetworkLock NoNotify

func (Notify) NetworkUnlock added in v0.9.5

func (n Notify) NetworkUnlock() error

NetworkUnlock NoNotify

func (Notify) PostDump added in v0.9.5

func (n Notify) PostDump() error

func (Notify) PostRestore added in v0.9.5

func (n Notify) PostRestore(pid int32) error

PostRestore NoNotify

func (Notify) PostResume added in v0.9.5

func (n Notify) PostResume() error

PostResume NoNotify

func (Notify) PostSetupNamespaces added in v0.9.5

func (n Notify) PostSetupNamespaces() error

PostSetupNamespaces NoNotify

func (Notify) PreDump added in v0.9.5

func (n Notify) PreDump() error

func (Notify) PreRestore added in v0.9.5

func (n Notify) PreRestore() error

func (Notify) PreResume added in v0.9.5

func (n Notify) PreResume() error

func (Notify) SetupNamespaces added in v0.9.5

func (n Notify) SetupNamespaces(pid int32) error

SetupNamespaces NoNotify

type NotifyFunc added in v0.9.5

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

type OCIBundle added in v0.9.5

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 added in v0.9.5

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

NewBundle returns a new bundle on disk

type Server

type Server struct {
	Lis net.Listener
	// contains filtered or unexported fields
}

func (*Server) New

func (s *Server) New() (*grpc.Server, error)

type UploadResponse

type UploadResponse struct {
	UploadID  string `json:"upload_id"`
	PartSize  int    `json:"part_size"`
	PartCount int    `json:"part_count"`
}

Directories

Path Synopsis
gpu

Jump to

Keyboard shortcuts

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