plugins

package
v0.9.280 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BINARY_PERMS       = 0o755
	LIBRARY_PERMS      = 0o644
	DOWNLOAD_DIR_PERMS = 0o755
)

Variables

View Source
var LibDir, BinDir string
View Source
var Load = sync.OnceValue(loadPlugins)
View Source
var Registry = []Plugin{

	{
		Name:     "criu",
		Type:     EXTERNAL,
		Binaries: []Binary{{Name: "criu"}},
	},
	{
		Name:      "cloud-hypervisor",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-cloud-hypervisor.so"}},
	},
	{
		Name:      "criu/cuda",
		Type:      EXTERNAL,
		Binaries:  []Binary{{Name: "cuda-checkpoint", InstallDir: "/usr/local/bin"}},
		Libraries: []Binary{{Name: "cuda_plugin.so", InstallDir: "/usr/lib/criu"}},
	},

	{
		Name:      "runc",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-runc.so"}},
	},
	{
		Name:      "containerd",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-containerd.so"}},
	},
	{
		Name:      "crio",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-crio.so"}},
	},
	{
		Name:      "kata",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-kata.so"}},
	},

	{
		Name:      "storage/cedana",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-storage-cedana.so"}},
	},
	{
		Name:      "storage/s3",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-storage-s3.so"}},
	},
	{
		Name:      "storage/gcs",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-storage-gcs.so"}},
	},

	{
		Name:      "gpu",
		Type:      EXTERNAL,
		Libraries: []Binary{{Name: "libcedana-gpu.so"}},
		Binaries:  []Binary{{Name: "cedana-gpu-controller"}},
	},
	{
		Name:      "gpu/tracer",
		Type:      EXTERNAL,
		Libraries: []Binary{{Name: "libcedana-gpu-tracer.so"}},
	},
	{
		Name:     "streamer",
		Type:     EXTERNAL,
		Binaries: []Binary{{Name: "cedana-image-streamer"}},
	},
	{
		Name:      "k8s",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-k8s.so"}},
		Binaries:  []Binary{},
	},
	{
		Name:      "containerd/runtime-runc",
		Type:      EXTERNAL,
		Libraries: []Binary{},
		Binaries:  []Binary{{Name: "cedana-shim-runc-v2"}},
	},
	{
		Name:      "slurm",
		Type:      SUPPORTED,
		Libraries: []Binary{{Name: "libcedana-slurm.so"}},
		Binaries:  []Binary{{Name: "libslurm-cedana.so", InstallDir: "/usr/lib64/slurm"}},
	},
}

Local registry of plugins that are supported by Cedana XXX: This list is needed locally so when all plugins are loaded, we only want to attempt to load the ones that are 'Supported'. GPU plugin, for example, is not 'External' and thus cannot be loaded by Go, so we shouldn't try, as it's undefined behavior.

Functions

func RecoverFromPanic

func RecoverFromPanic(plugin string)

RecoverFromPanic is a helper function to recover from panics in plugins and log the error. It should only be used with defer.

Types

type Binary

type Binary struct {
	Name       string `json:"name"`
	Checksum   string `json:"checksum"`     // MD5
	InstallDir string `json:"install_path"` // Fixed path where the binary must be installed
}

type Feature

type Feature[T any] struct {
	Symbol      string
	Description string
}

Feature is a typed symbol that a plugin can export with a description of what it does/used for.

func (Feature[T]) IfAvailable

func (feature Feature[T]) IfAvailable(
	do func(pluginName string, sym T) error,
	filter ...string,
) error

IfAvailable checks if a feature is available in any of the plugins, and if it is, it calls the provided function with the plugin name and the feature. Always goes through all plugins, even if one of them fails. Later, the errors are returned together, if any. If no filter is provided, all plugins are checked.

func (Feature[T]) IsAvailable

func (feature Feature[T]) IsAvailable(filter ...string) (bool, error)

IsAvailable checks if a feature is available in any of the plugins. If no filter is provided, all plugins are checked. Also returns an error if the symbol is present but incompatible.

func (Feature[T]) String

func (feature Feature[T]) String() string

type LocalManager

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

func NewLocalManager

func NewLocalManager() *LocalManager

func (*LocalManager) Get

func (m *LocalManager) Get(name string) *Plugin

func (*LocalManager) Getf added in v0.9.268

func (m *LocalManager) Getf(format string, a ...any) *Plugin

func (*LocalManager) Install

func (m *LocalManager) Install(names []string) (chan int, chan string, chan error)

func (*LocalManager) IsInstalled

func (m *LocalManager) IsInstalled(name string) bool

func (*LocalManager) List

func (m *LocalManager) List(latest bool, filter ...string) (list []Plugin, err error)

List returns a list of plugins that are available. If filter is provided, only plugins with the specified names are returned.

func (*LocalManager) Remove

func (m *LocalManager) Remove(names []string) (chan int, chan string, chan error)

type Manager

type Manager interface {
	// List all plugins
	List(latest bool, filter ...string) ([]Plugin, error)

	// Install a list of plugins
	Install(names []string) (installed chan int, msgs chan string, errs chan error)

	// Remove a list of plugins
	Remove(names []string) (removed chan int, msgs chan string, errs chan error)

	// Get a plugin by name
	Get(name string) *Plugin

	//  Get by formatted name
	Getf(format string, a ...any) *Plugin

	// Check if a plugin is installed
	IsInstalled(name string) bool
}

type ManagerUnimplemented

type ManagerUnimplemented struct{}

func (*ManagerUnimplemented) Get

func (m *ManagerUnimplemented) Get(_ string) *Plugin

func (*ManagerUnimplemented) Getf added in v0.9.268

func (m *ManagerUnimplemented) Getf(format string, a ...any) *Plugin

func (*ManagerUnimplemented) Install

func (m *ManagerUnimplemented) Install(_ []string) (chan int, chan string, chan error)

func (*ManagerUnimplemented) IsInstalled

func (m *ManagerUnimplemented) IsInstalled(_ string) bool

func (*ManagerUnimplemented) List

func (m *ManagerUnimplemented) List(_ ...Status) ([]Plugin, error)

func (*ManagerUnimplemented) Remove

func (m *ManagerUnimplemented) Remove(_ []string) (chan int, chan string, chan error)

type Plugin

type Plugin struct {
	Name             string    `json:"name"`
	Type             Type      `json:"type"`
	Status           Status    `json:"status"`
	Version          string    `json:"version"`
	AvailableVersion string    `json:"latest_version"`
	Libraries        []Binary  `json:"libraries"`
	Binaries         []Binary  `json:"binaries"`
	Size             int64     `json:"size"` // in bytes
	PublishedAt      time.Time `json:"published_at"`
}

Represents plugin information

func (*Plugin) BinaryPaths

func (p *Plugin) BinaryPaths() []string

BinaryPaths returns the full paths of the plugin binaries

func (*Plugin) Checksum

func (p *Plugin) Checksum() string

Checksum returns the concatenated checksum of all libraries and binaries

func (*Plugin) IsInstalled

func (p *Plugin) IsInstalled() bool

func (*Plugin) LibraryPaths

func (p *Plugin) LibraryPaths() []string

LibraryPaths returns the full paths of the plugin libraries

func (*Plugin) SyncInstalled

func (p *Plugin) SyncInstalled()

Syncs plugin information with local info, whether it is installed or not. Also fetches the local installed version.

func (*Plugin) SyncVersion

func (p *Plugin) SyncVersion()

SyncVersion fetches the version of the locally installed plugin

type PropagatorManager

type PropagatorManager struct {
	config.Connection

	*LocalManager
	// contains filtered or unexported fields
}

func NewPropagatorManager

func NewPropagatorManager(connection config.Connection, compatibility string) *PropagatorManager

func (*PropagatorManager) Install

func (m *PropagatorManager) Install(names []string) (chan int, chan string, chan error)

func (*PropagatorManager) List

func (m *PropagatorManager) List(latest bool, filter ...string) ([]Plugin, error)

type Status

type Status int
const (
	UNKNOWN Status = iota
	AVAILABLE
	INSTALLED
	OUTDATED
)

func (Status) String

func (s Status) String() string

type Type

type Type int
const (
	UNIMPLEMENTED Type = iota // Go plugin that is not yet implemented
	DEPRECATED                // Go plugin that is no longer maintained
	EXPERIMENTAL              // Go plugin that is not yet stable
	EXTERNAL                  // Not a Go plugin
	SUPPORTED                 // Go plugin that is supported by Cedana
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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