common

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceKernelName = "kernel"
	DeviceDiskName   = "disk"
	DeviceStateName  = "state"
	DeviceMemoryName = "memory"
	DeviceConfigName = "config"
	DeviceOCIName    = "oci"
)

Variables

View Source
var (
	ErrCouldNotCreateDeviceDirectory  = errors.New("could not create device directory")
	ErrCouldNotGetBaseDeviceStat      = errors.New("could not get base device statistics")
	ErrCouldNotCreateOverlayDirectory = errors.New("could not create overlay directory")
	ErrCouldNotCreateStateDirectory   = errors.New("could not create state directory")
)
View Source
var (
	ErrCouldNotGetNBDDeviceStat = errors.New("could not get NBD device stat")
	ErrCouldNotCreateDeviceNode = errors.New("could not create device node")
)
View Source
var (
	ErrMissingDevice                 = errors.New("missing resource")
	ErrCouldNotOpenPackageOutputFile = errors.New("could not open package output file")
	ErrCouldNotCreateCompressor      = errors.New("could not create compressor")
	ErrCouldNotStatDevice            = errors.New("could not stat device")
	ErrCouldNotCreateTarHeader       = errors.New("could not create tar header")
	ErrCouldNotWriteTarHeader        = errors.New("could not write tar header")
	ErrCouldNotOpenDevice            = errors.New("could not open device file")
	ErrCouldNotCopyToArchive         = errors.New("could not copy file to archive")
	ErrCouldNotOpenPackageInputFile  = errors.New("could not open package input file")
	ErrCouldNotCreateUncompressor    = errors.New("could not create uncompressor")
	ErrCouldNotReadNextHeader        = errors.New("could not read next header from archive")
	ErrCouldNotCreateOutputDir       = errors.New("could not create output directory")
	ErrCouldNotOpenOutputFile        = errors.New("could not open output file")
	ErrCouldNotCopyToOutput          = errors.New("could not copy file to output")
)
View Source
var (
	ErrCouldNotSuspendAndCloseAgentServer = errors.New("could not suspend and close agent server")
	ErrCouldNotMsyncRunner                = errors.New("could not msync runner")
)
View Source
var DeviceFilenames = map[string]string{
	DeviceKernelName: "vmlinux",
	DeviceDiskName:   "rootfs.ext4",
	DeviceStateName:  "state.bin",
	DeviceMemoryName: "memory.bin",
	DeviceConfigName: "config.json",
	DeviceOCIName:    "oci.ext4",
}
View Source
var (
	ErrCouldNotSuspendAndMsyncVM = errors.New("could not suspend and msync VM")
)

Functions

func ArchivePackage

func ArchivePackage(ctx context.Context, devices []PackagerDevice, packageOutputPath string) error

func CreateIncomingSiloDevSchema

func CreateIncomingSiloDevSchema(i *MigrateFromDevice, schema *config.DeviceSchema) (*config.DeviceSchema, error)

func CreateSiloDevSchema

func CreateSiloDevSchema(i *MigrateFromDevice) (*config.DeviceSchema, error)

*

  • This creates a Silo Dev Schema given a MigrateFromDevice
  • If you want to change the type of storage used, or Silo options, you can do so here. *

func ExposeSiloDeviceAsFile

func ExposeSiloDeviceAsFile(vmpath string, name string, devicePath string) error

expose a Silo Device as a file within the vm directory

func ExtractPackage

func ExtractPackage(ctx context.Context, packageInputPath string, devices []PackagerDevice) error

func MigrateFromFS

func MigrateFromFS(log types.Logger, met metrics.SiloMetrics, instanceID, vmpath string,
	devices []MigrateFromDevice, tweak func(index int, name string, schema *config.DeviceSchema) *config.DeviceSchema) (*devicegroup.DeviceGroup, error)

*

  • 'migrate' from the local filesystem. *

func MigrateFromPipe

func MigrateFromPipe(log types.Logger, met metrics.SiloMetrics, instanceID string, vmpath string,
	ctx context.Context, readers []io.Reader, writers []io.Writer, schemaTweak func(index int, name string, schema *config.DeviceSchema) *config.DeviceSchema,
	cdh func([]byte)) (*devicegroup.DeviceGroup, error)

*

  • Migrate FROM a pipe
  • NB: You should call dg.WaitForCompletion() later to ensure migrations are finished

func MigrateToPipe

func MigrateToPipe(ctx context.Context, readers []io.Reader, writers []io.Writer,
	dg *devicegroup.DeviceGroup, concurrency int, onProgress func(p map[string]*migrator.MigrationProgress),
	vmState *VMStateMgr, devices []MigrateToDevice, getCustomPayload func() []byte, met metrics.SiloMetrics, instanceID string) error

*

  • Migrate TO a pipe *

Types

type DeviceStatus

type DeviceStatus struct {
	TotalCycles                   int
	CycleThrottle                 time.Duration
	MaxDirtyBlocks                int
	CyclesBelowDirtyBlockTreshold int
	MinCycles                     int
	MaxCycles                     int
	Ready                         bool
	ReadyAndSentDirty             bool
}

type DirtyManager

type DirtyManager struct {
	VMState           *VMStateMgr
	Devices           map[string]*DeviceStatus
	ReadyDevices      map[string]*DeviceStatus
	ReadyDevicesLock  sync.Mutex
	AuthorityTransfer func() error
	// contains filtered or unexported fields
}

func NewDirtyManager

func NewDirtyManager(vmState *VMStateMgr, devices map[string]*DeviceStatus, authorityTransfer func() error) *DirtyManager

func (*DirtyManager) PostGetDirty

func (dm *DirtyManager) PostGetDirty(name string, blocks []uint) (bool, error)

func (*DirtyManager) PostMigrateDirty

func (dm *DirtyManager) PostMigrateDirty(name string, blocks []uint) (bool, error)

func (*DirtyManager) PreGetDirty

func (dm *DirtyManager) PreGetDirty(name string) error

type DrafterMetrics

type DrafterMetrics struct {
	MetricFlushDataOps           *prometheus.GaugeVec // Count of flushData operations
	MetricFlushDataTimeMS        *prometheus.GaugeVec // Total time for flushData operations
	MetricVMRunning              *prometheus.GaugeVec // 1 = VM is running
	MetricMigratingTo            *prometheus.GaugeVec // 1 = Migrating to
	MetricMigratingFrom          *prometheus.GaugeVec // 1 = Migrating from
	MetricMigratingFromWaitReady *prometheus.GaugeVec // 1 = Migrating from
}

func NewDrafterMetrics

func NewDrafterMetrics(reg *prometheus.Registry) *DrafterMetrics

type MigrateFromDevice

type MigrateFromDevice struct {
	Name      string `json:"name"`
	Base      string `json:"base"`
	Overlay   string `json:"overlay"`
	State     string `json:"state"`
	BlockSize uint32 `json:"blockSize"`
	Shared    bool   `json:"shared"`

	SharedBase bool `json:"sharedbase"`

	S3Sync        bool   `json:"s3sync"`
	S3AccessKey   string `json:"s3accesskey"`
	S3SecretKey   string `json:"s3secretkey"`
	S3Endpoint    string `json:"s3endpoint"`
	S3Secure      bool   `json:"s3secure"`
	S3Bucket      string `json:"s3bucket"`
	S3Concurrency int    `json:"s3concurrency"`
}

type MigrateToDevice

type MigrateToDevice struct {
	Name string `json:"name"`

	MaxDirtyBlocks int `json:"maxDirtyBlocks"`
	MinCycles      int `json:"minCycles"`
	MaxCycles      int `json:"maxCycles"`

	CycleThrottle time.Duration `json:"cycleThrottle"`
}

type PackagerDevice

type PackagerDevice struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type VMStateMgr

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

func NewDummyVMStateMgr

func NewDummyVMStateMgr(ctx context.Context) *VMStateMgr

func NewVMStateMgr

func NewVMStateMgr(ctx context.Context,
	suspendFunc func(ctx context.Context, timeout time.Duration) error,
	suspendTimeout time.Duration,
	msyncFunc func(ctx context.Context) error,
	onBeforeSuspend func(),
	onAfterSuspend func()) *VMStateMgr

func (*VMStateMgr) CheckSuspendedVM

func (sm *VMStateMgr) CheckSuspendedVM() bool

func (*VMStateMgr) GetSuspsnededVMCh

func (sm *VMStateMgr) GetSuspsnededVMCh() chan struct{}

func (*VMStateMgr) Msync

func (sm *VMStateMgr) Msync() error

func (*VMStateMgr) SuspendAndMsync

func (sm *VMStateMgr) SuspendAndMsync() error

Jump to

Keyboard shortcuts

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