storage

package
v0.0.0-...-e02976a Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0, BSD-2-Clause Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CowKindVolume   = cow.KindVolume
	CowKindSnapshot = cow.KindSnapshot
)
View Source
const (
	// S3MetadataBaseVolumeName is the per-node, local-only cubecow volume
	// that Cubelet formats as ext4 during S3 init.
	S3MetadataBaseVolumeName = "cubelet-s3-metadata-base"
	// S3MetadataBaseSnapshotName is the RO snapshot of the base volume.
	// Package metadata disks are writable volumes cloned from this snap
	// (or from a parent package metadata volume via snap→clone).
	S3MetadataBaseSnapshotName = "cubelet-s3-metadata-base-snap"
)
View Source
const (
	// SnapshotKindNormal is the on-disk directory for ordinary snapshots.
	SnapshotKindNormal = "snapshots"
	// SnapshotKindPause is the on-disk directory for pause temporary snapshots.
	SnapshotKindPause = "pause-snapshots"
	// SnapshotMetadataDir holds catalog.json, sandbox_spec.json, hypervisor state.
	SnapshotMetadataDir = "metadata"
	// SnapshotMemoryDir holds S3 memory package placeholders (no host .dev files).
	SnapshotMemoryDir = "memory"
	// SnapshotDiskDir is the S3 package disk role directory (empty placeholder;
	// rootfs identity lives in catalog.json, not a host-local .dev file).
	SnapshotDiskDir = "disk"
	// SnapshotObjectsDir is the XFS cubecow object pool (files, not metadata).
	SnapshotObjectsDir = "objects"

	// Deprecated aliases kept so existing S3 helpers keep compiling.
	S3SnapshotRootName    = "s3"
	S3SnapshotMemoryDir   = SnapshotMemoryDir
	S3SnapshotDiskDir     = SnapshotDiskDir
	S3SnapshotMetadataDir = SnapshotMetadataDir
)
View Source
const (
	// CatalogKindRuntimeSnapshot is produced by CommitSandbox (taking a
	// snapshot of a running sandbox).
	CatalogKindRuntimeSnapshot = "runtime_snapshot"
	// CatalogKindTemplate is produced by AppSnapshot (building a template
	// from an image / one-shot sandbox).
	CatalogKindTemplate = "template"
	// CatalogKindPauseSnapshot is produced by Pause when the MicroVM is
	// snapshotted into CubeCow and the shim exits. Resume recreates the
	// sandbox from this catalog entry with the same sandboxID.
	CatalogKindPauseSnapshot = "pause_snapshot"
)

Catalog entry kinds. See SnapshotCatalogEntry.Kind.

View Source
const ExtInfoRemoteUUIDs = "remote_uuids"

ExtInfoRemoteUUIDs is the Update/Pause ext_info key carrying remote_uuids JSON.

View Source
const StorageBackendCow = "cubecow"

StorageBackendCow is the canonical value of `storage_backend` for the cubecow (reflink-only copy-on-write) backend. cubelet refuses to boot when `storage_backend` is set to anything else under this build.

Variables

View Source
var DefaultEmptyDirFormats = []string{"512Mi", "others"}

DefaultEmptyDirFormats is the fallback list of format roots used by CleanupOrphanStorageFiles when callers do not supply their own.

View Source
var ErrCowObjectAlreadyExists = errors.New("cubecow object already exists")
View Source
var ErrCowObjectMissing = errors.New("cubecow object missing")
View Source
var ErrS3NotConfigured = errors.New("s3 storage is not configured (set [cow.s3] enable = true to enable CubeS3lvol)")

ErrS3NotConfigured is returned for backend=s3 requests when the operator has not opted into CubeS3lvol ([cow.s3] enable is false).

View Source
var ErrS3NotReady = errors.New("s3 storage is not ready (initializing)")

ErrS3NotReady is returned for backend=s3 requests while the S3 cubecow handle and metadata base are still initializing (or retrying).

View Source
var ErrSnapshotCatalogNotFound = errors.New("snapshot catalog not found")

ErrSnapshotCatalogNotFound is returned when no catalog can be located for the given snapshot id under any registered snapshot root.

Functions

func ActivateSnapshot

func ActivateSnapshot(ctx context.Context, backend, snapshotID string) error

ActivateSnapshot opens a local snapshot's cubecow objects on the Store for backend. Missing objects fail; this does not fetch from remote (use FetchSnapshot for that). Does not start a sandbox. Callers decide when to activate versus clone-to-volume first.

func ActiveCowStore

func ActiveCowStore() cow.Store

ActiveCowStore returns the default (XFS) CoW Store, or nil when storage is not initialized / not using a CoW backend. Prefer StoreFor when the request carries an explicit backend type (xfs|s3).

func ActiveS3CowStore

func ActiveS3CowStore() cow.Store

ActiveS3CowStore returns the S3 CoW Store, or nil when unset.

func AddSnapshotCatalogRoot

func AddSnapshotCatalogRoot(root string)

AddSnapshotCatalogRoot adds an XFS snapshot root if not already present.

func AddSnapshotCatalogRootFor

func AddSnapshotCatalogRootFor(backend, root string)

AddSnapshotCatalogRootFor adds a snapshot root to one CoW backend.

func BackendStorageRoot

func BackendStorageRoot(backend string) string

BackendStorageRoot is <work>/xfs or <work>/s3.

func CleanupCowTemplateObjects

func CleanupCowTemplateObjects(ctx context.Context, refs []CowObjectRef) error

func CleanupObjects

func CleanupObjects(ctx context.Context, refs []CowObjectRef) error

CleanupObjects best-effort deletes the given CoW object refs on the default Store.

func CleanupObjectsFor

func CleanupObjectsFor(ctx context.Context, backend string, refs []CowObjectRef) error

CleanupObjectsFor is CleanupObjects on the Store selected by backend.

The rootfs object goes first and a failure on it stops the sweep. rootfs is what proves the package exists — every other object name can be re-derived from the package id, but only while the package is still whole. Deleting memory and metadata under a rootfs that refused to go (an exported snapshot stays undeletable until its export is released) turns a retryable failure into a half package that no retry can repair.

func CleanupTemplateLocalData

func CleanupTemplateLocalData(ctx context.Context, templateID, snapshotPath string) error

func CloneS3MetadataFromParent

func CloneS3MetadataFromParent(ctx context.Context, backend, parentID, childID, mountPath string) error

CloneS3MetadataFromParent creates the child package/sandbox metadata disk as a snapshot of the parent's metadata volume (template / snapshot / pause). If the parent volume is missing, falls back to cloning the node-local base. Pause resume uses this with childID=sandboxID so the pause package can be deleted afterwards.

func CubeletStorageWorkPath

func CubeletStorageWorkPath() string

CubeletStorageWorkPath is Cubelet storage's on-disk work directory (config data_path, typically /data/cubelet/storage).

func DeactivateCowObject

func DeactivateCowObject(ctx context.Context, name, kind string) error

func DeactivateObject

func DeactivateObject(ctx context.Context, name, kind string) error

DeactivateObject deactivates a CoW volume/snapshot on the default Store.

func DeactivateObjectFor

func DeactivateObjectFor(ctx context.Context, backend, name, kind string) error

DeactivateObjectFor is DeactivateObject on the Store for backend.

func DeleteCowObject

func DeleteCowObject(ctx context.Context, name, kind string) error

func DeleteObject

func DeleteObject(ctx context.Context, name, kind string) error

DeleteObject deletes a CoW volume/snapshot by name and kind on the default Store.

func DeleteObjectFor

func DeleteObjectFor(ctx context.Context, backend, name, kind string) error

DeleteObjectFor is DeleteObject on the Store for backend.

func DeleteSnapshotCatalog

func DeleteSnapshotCatalog(snapshotID string)

DeleteSnapshotCatalog removes the in-memory cache entry for snapshotID from every backend namespace.

func DeleteSnapshotCatalogFor

func DeleteSnapshotCatalogFor(backend, snapshotID string)

DeleteSnapshotCatalogFor removes the in-memory cache entry from one backend.

func Engine

func Engine() *cubecow.Engine

func EnsureS3MetadataBase

func EnsureS3MetadataBase(ctx context.Context) error

EnsureS3MetadataBase creates the 8MiB base volume and mkfs.ext4's it on first use, then snapshots it and deactivates the volume (no further host IO). Restart of an older Cubelet that left the base activated is reconciled on this path. Missing volumes are recreated.

func EnsureS3MetadataReady

func EnsureS3MetadataReady(ctx context.Context) error

EnsureS3MetadataReady creates (or reconciles) the node-local 8MiB metadata base. Nothing else is done at startup: every package disk is derived and mounted by the request that reads it, and a restarted Cubelet has no way to tell a leftover from a disk a live sandbox is running on.

func EnsureS3SnapshotLayout

func EnsureS3SnapshotLayout(home string) error

EnsureS3SnapshotLayout creates memory/disk/metadata under home.

func EnsureShimSpecDirLink(home, specDir string) error

EnsureShimSpecDirLink exposes <home>/<specDir> for the installed shim, which always loads {base}/{cpu}C{mem}M/metadata.json. Package files stay under metadata/; the link is relative so the home can be renamed.

func EnsureSnapshotPackage

func EnsureSnapshotPackage(backend, home string) error

EnsureSnapshotPackage creates the on-disk dirs for one snapshot home. S3: memory/disk/metadata. XFS: metadata only (files live in objects/).

func FinalizeS3PackageSnapshots

func FinalizeS3PackageSnapshots(ctx context.Context, backend, snapshotID string) error

FinalizeS3PackageSnapshots is a Pause/Commit/AppSnapshot packaging step: flush+umount the package metadata mount, seal RW memory/metadata work volumes into RO snapshots, deactivate the sealed snaps (no host IO until a later restore ResolveDevPath/clone), and delete the work volumes (snapshots remain; volumes follow the sandbox/build lifecycle).

Metadata must be umounted before seal: CreateSnapshotFromVolume captures the block device as-is, and a live mount can leave metadata.json/catalog.json in the page cache so the sealed snap is missing them (shim then fails restore). Catalog is rewritten to snap names while still mounted, then umount flushes. Rootfs is already a snapshot from CommitTemplateRootfs. XFS is a no-op.

func GetCowMetrics

func GetCowMetrics(ctx context.Context) (map[string]uint64, error)

func GetPCIDiskInfo

func GetPCIDiskInfo(ctx context.Context, id string) (*disk.CubePCIDiskInfo, error)

func InspectStorageVolumes

func InspectStorageVolumes() (map[string]*StorageInfo, error)

InspectStorageVolumes returns every sandbox storage record cubelet currently owns, with cubecow device paths re-resolved through the live engine. It is the canonical data source for `cubecli storage ls` and any other tool that needs an authoritative cross-sandbox view.

func IsCowBackend

func IsCowBackend() bool

func IsS3Backend

func IsS3Backend(backend string) bool

IsS3Backend reports whether backend names the S3 CoW backend. Callers outside this package use it to keep S3-only rules — host activation, and snapshots living in s3lvol rather than as reflink files — off the XFS paths.

func IsS3MetadataBaseName

func IsS3MetadataBaseName(name string) bool

IsS3MetadataBaseName reports the node-local metadata base volume or its RO snapshot. Neither must be exported or fetched; they stay on this Cubelet.

func LoadPauseSandboxSpec

func LoadPauseSandboxSpec(snapshotPath string) (*cubebox.RunCubeSandboxRequest, error)

LoadPauseSandboxSpec reads sandbox_spec.json from a pause snapshot directory. For S3 packages the file lives under metadata/; callers may pass either the metadata dir or the snapshot home.

func MountRollbackSnapshotMetadata

func MountRollbackSnapshotMetadata(ctx context.Context, backend, snapshotID, sandboxID string) (string, error)

MountRollbackSnapshotMetadata clones the snapshot's sealed metadata disk into a volume owned by this sandbox and mounts it, returning the directory holding snapshot/{config,state}.json. Callers pass that directory to the shim instead of the package's own MetaDir, which Finalize left unmounted.

XFS returns an empty path and no error: there the package directory is a plain directory that is always readable.

func MountS3MetadataAt

func MountS3MetadataAt(ctx context.Context, backend, snapshotID, mountPath string) error

MountS3MetadataAt mounts the package metadata disk at mountPath. IO always goes through a RW volume (s3-meta-<id>). If only the sealed snap remains, it is cloned to that volume first — never activate/mount the package snap for metadata IO. After Fetch, import_lvol may already be a volume under the snap name; that name is used only when cloning into s3-meta-<id> is not possible.

func ObjectMetrics

func ObjectMetrics(ctx context.Context) (map[string]uint64, error)

ObjectMetrics returns metrics from the default (XFS) cow.Store.

func ObjectMetricsFor

func ObjectMetricsFor(ctx context.Context, backend string) (map[string]uint64, error)

ObjectMetricsFor returns metrics from the Store selected by backend.

func PersistSandboxRootfs

func PersistSandboxRootfs(ctx context.Context, sandboxID string, rootfs *CowSnapshotObject) error

PersistSandboxRootfs records the live sandbox rootfs after rollback.

func PersistSandboxRootfsAfterRollback

func PersistSandboxRootfsAfterRollback(ctx context.Context, sandboxID string, rootfs *CowSnapshotObject) error

func PrepareS3MetadataMount

func PrepareS3MetadataMount(ctx context.Context, backend, snapshotID, mountPath string) error

PrepareS3MetadataMount ensures the node-local base volume+snapshot exist, clones a writable package metadata volume from the base snapshot, and mounts it at mountPath (the designed metadata/ directory). XFS is a no-op.

func ReadDir

func ReadDir(name string) ([]os.DirEntry, error)

func RefreshStorageInfoPathsWithEngine

func RefreshStorageInfoPathsWithEngine(ctx context.Context, info *StorageInfo, engine *cubecow.Engine) error

func ReleaseRollbackReplacedVolumes

func ReleaseRollbackReplacedVolumes(ctx context.Context, backend, sandboxID string, oldRootfs *CowSnapshotObject) error

ReleaseRollbackReplacedVolumes deletes the sandbox volumes rollback replaced: the previous rootfs generation, and any imported memory disk a cross-node restore left behind. Package snapshots are not touched — they outlive the sandbox. Missing storage metadata is ignored so a unit test without BoltDB can still assert the cubecow deletes.

func ReleaseRollbackSnapshotMetadata

func ReleaseRollbackSnapshotMetadata(ctx context.Context, backend, sandboxID string) error

ReleaseRollbackSnapshotMetadata unmounts and deletes the copy MountRollbackSnapshotMetadata made. The package's sealed metadata snapshot is left alone: it belongs to the snapshot, which outlives this sandbox.

func ReleaseS3MetadataDerivedVolume

func ReleaseS3MetadataDerivedVolume(ctx context.Context, backend, snapshotID string) error

ReleaseS3MetadataDerivedVolume unmounts and deletes only the RW clone that was made to read a package's metadata, leaving the sealed snapshot in place. Callers that merely borrow a package (rollback) must use this: the sealed snap belongs to the snapshot, not to the operation reading it.

func ReleaseS3MetadataVolume

func ReleaseS3MetadataVolume(ctx context.Context, backend, snapshotID string) error

ReleaseS3MetadataVolume unmounts and deletes the derived metadata volume together with the package's sealed metadata snapshot. Use it when the package itself is going away. The node-local base is never deleted.

func ResolveCowDevPath

func ResolveCowDevPath(ctx context.Context, name, kind string) (string, error)

func ResolveObjectPath

func ResolveObjectPath(ctx context.Context, name, kind string) (string, error)

ResolveObjectPath resolves a CoW object to a device/file path on the default Store.

func ResolveObjectPathFor

func ResolveObjectPathFor(ctx context.Context, backend, name, kind string) (string, error)

ResolveObjectPathFor is ResolveObjectPath on the Store for backend.

func RestoreSnapshot

func RestoreSnapshot(ctx context.Context, backend, snapshotID string) error

RestoreSnapshot is the previous name of ActivateSnapshot.

func RollbackMetadataOwnerID

func RollbackMetadataOwnerID(sandboxID string) string

RollbackMetadataOwnerID names the metadata copy a rollback reads after the sandbox performing it, not after the snapshot it comes from. Two sandboxes rolling back to the same snapshot therefore get a disk each instead of fighting over one, and destroy knows which one to reclaim.

func S3CatalogFilePath

func S3CatalogFilePath(home string) string

func S3MetadataCatalogKind

func S3MetadataCatalogKind(backend string) string

S3MetadataCatalogKind is volume while metadata is still being written; FinalizeS3PackageSnapshots switches the catalog entry to snapshot.

func S3MetadataCatalogVol

func S3MetadataCatalogVol(backend, snapshotID string) string

S3MetadataCatalogVol is the catalog metadata_vol for an S3 package. Before finalize this is the RW work volume; FinalizeS3PackageSnapshots rewrites it to S3MetadataSnapshotName for export.

func S3MetadataSnapshotName

func S3MetadataSnapshotName(snapshotID string) string

S3MetadataSnapshotName is the RO sealed snapshot of the package metadata volume. Only this name is exported/fetched across nodes.

func S3MetadataVolumeName

func S3MetadataVolumeName(snapshotID string) string

S3MetadataVolumeName is the writable cubecow volume for one template / pause / snapshot package metadata disk (cloned from the base snapshot).

func S3SnapshotDiskDirPath

func S3SnapshotDiskDirPath(home string) string

func S3SnapshotHome

func S3SnapshotHome(snapshotID string) string

S3SnapshotHome is the default (normal) S3 package directory.

func S3SnapshotMemoryDirPath

func S3SnapshotMemoryDirPath(home string) string

func S3SnapshotMetaDir

func S3SnapshotMetaDir(home string) string

func S3SnapshotRoot

func S3SnapshotRoot() string

S3SnapshotRoot is the S3 backend root (<work>/s3). Catalogs live in the snapshots/pause-snapshots children.

func SandboxMemoryName

func SandboxMemoryName(sandboxID string) string

SandboxMemoryName is the private memory image a restore owns: imported cross-node, or cloned from the pause package on a same-node Resume.

func SandboxObjectNamePrefix

func SandboxObjectNamePrefix(sandboxID string) string

SandboxObjectNamePrefix is what every disk minted for a sandbox is named after. Ownership is decided on this prefix, so a disk that belongs to a sandbox must be named through the helpers below and nothing else may be.

func SandboxRootfsName

func SandboxRootfsName(sandboxID string, gen uint32) string

SandboxRootfsName is the private rootfs a sandbox runs on, however it was produced: cloned from a local package, or imported from S3 on a node that has none. The name is what destroy keys on.

func SetSnapshotCatalogRoots

func SetSnapshotCatalogRoots(roots ...string)

SetSnapshotCatalogRoots replaces XFS snapshot catalog roots.

func SetSnapshotCatalogRootsFor

func SetSnapshotCatalogRootsFor(backend string, roots ...string)

SetSnapshotCatalogRootsFor replaces catalog roots for one CoW backend.

func SnapshotHome

func SnapshotHome(backend, kind, snapshotID string) string

SnapshotHome is <kind-root>/<snapshotID>.

func SnapshotKindRoot

func SnapshotKindRoot(backend, kind string) string

SnapshotKindRoot is <work>/<backend>/{snapshots|pause-snapshots}.

func SnapshotMetaDir

func SnapshotMetaDir(backend, kind, snapshotID string) string

SnapshotMetaDir is <home>/metadata.

func SnapshotUploadStatus

func SnapshotUploadStatus(ctx context.Context, backend, snapshotID string) (*cow.RemoteStatus, error)

SnapshotUploadStatus returns upload state from cubecow export_status (NONE→pending, empty/INPROGRESS→running, DONE→ready). XFS is a no-op ready.

func StoreFor

func StoreFor(backend string) (cow.Store, error)

StoreFor returns the live XFS or S3 cow.Store for backend (request `type`). XFS is ready after plugin init; S3 returns ErrS3NotConfigured when [cow.s3] enable is false, or ErrS3NotReady until the background s3lvol init loop publishes the S3 handle.

func TemplateBuildRootfsName

func TemplateBuildRootfsName(templateID string) string

TemplateBuildRootfsName returns the deterministic cubecow volume name used for a template's temporary writable working layer during AppSnapshot. Exposed so non-storage callers (e.g. AppSnapshot handler writing snapshot catalog) can record the name without redeclaring the format string.

func UnmountS3Metadata

func UnmountS3Metadata(mountPath string) error

UnmountS3Metadata unmounts a metadata mount point if it is mounted.

func UploadSnapshot

func UploadSnapshot(ctx context.Context, backend, snapshotID string) (*cow.RemoteUUIDs, error)

UploadSnapshot publishes snapshot disks to the remote store (cubecow_export_snapshot). XFS is a successful no-op (no remote upload).

func WriteSnapshotCatalog

func WriteSnapshotCatalog(entry *SnapshotCatalogEntry) error

WriteSnapshotCatalog persists entry under <SnapshotPath>/catalog.json in the XFS catalog namespace.

func WriteSnapshotCatalogFor

func WriteSnapshotCatalogFor(backend string, entry *SnapshotCatalogEntry) error

WriteSnapshotCatalogFor persists catalog.json in the given backend namespace.

func XFSObjectsDir

func XFSObjectsDir() string

XFSObjectsDir is <work>/xfs/objects (cubecow reflink pool).

Types

type BackendFileInfo

type BackendFileInfo struct {
	Name string

	SizeLimit int64

	FSQuota int64

	FilePath string

	VolumeName string

	Kind string

	Gen uint32

	Type string

	SourcePath string

	SizeLimitQ string

	Medium cubebox.StorageMedium

	BDF string
}

type CleanupOrphanReport

type CleanupOrphanReport struct {
	Format   string
	FilePath string
	Removed  bool
	Err      error
}

CleanupOrphanReport describes the outcome of a single orphan file cleanup attempt produced by CleanupOrphanStorageFiles.

func CleanupOrphanStorageFiles

func CleanupOrphanStorageFiles(formats []string, dryRun bool) ([]CleanupOrphanReport, error)

CleanupOrphanStorageFiles scans the configured emptydir format roots and drops any file that has no live sandbox owner. When dryRun is true cubelet only reports the files it would delete. formats may be nil, in which case DefaultEmptyDirFormats is used.

type Config

type Config struct {
	RootPath string `toml:"root_path"`
	DataPath string `toml:"data_path"`

	DiskSize string `toml:"disksize"`

	WarningPercent int64 `toml:"warningPercent"`

	PoolDefaultFormatSizeList []string `toml:"pool_default_format_size_list"`

	BaseDiskUUID string `toml:"base_disk_uuid"`

	PoolSize int `toml:"pool_size"`

	PoolWorkers int `toml:"pool_worker_num"`

	FAdviseSize int `toml:"fadvise_size"`

	PoolType poolType `toml:"pool_type"`

	PoolTriggerIntervalInMs int `toml:"pool_trigger_interval_in_ms"`

	PoolTriggerBurst int `toml:"pool_trigger_burst"`

	DisableDiskCheck bool `toml:"disable_disk_check"`

	FreeBlocksThreshold int32 `toml:"free_blocks_threshold"`

	FreeInodesThreshold int32            `toml:"free_inodes_threshold"`
	ReconcileInterval   tomlext.Duration `toml:"reconcile_interval"`

	StorageBackend string          `toml:"storage_backend"`
	Cow            CowInlineConfig `toml:"cow"`

	// CmdTimeout overrides the per-command timeout for utils.ExecV
	// invocations in shell.go (cp / truncate / e2fsck / resize2fs /
	// mkfs.ext4). Defaults to defaultCmdTimeout when zero. The slow
	// ext4-create path on multi-GiB images can need noticeably more
	// than the 3s default; this knob lets operators bump it without
	// recompiling.
	CmdTimeout tomlext.Duration `toml:"cmd_timeout"`

	// VolumePlugins lists external volume plugin configurations.
	// Built-in plugins are registered in code and do not need entries here.
	//
	// Example:
	//   [[plugins."io.cubelet.internal.v1.storage".volume_plugins]]
	//     name        = "nfs"
	//     type        = "binary"
	//     binary_path = "/usr/local/bin/cube-volume-nfs"
	VolumePlugins []volpkg.PluginConfig `toml:"volume_plugins"`

	// VolumePluginBaseDir is the parent directory that every plugin_volume
	// Attach must mount its volume under. Cubelet passes this path to the
	// plugin (AttachRequest.VolumeBaseDir / --volume-base-dir) and rejects any
	// attach whose returned host_path is not located inside it. Defaults to
	// defaultVolumePluginBaseDir ("/data/cube-shared/volume") when empty.
	VolumePluginBaseDir string `toml:"volume_plugin_base_dir"`
}

func (*Config) BuildCowInitJSON

func (c *Config) BuildCowInitJSON() ([]byte, error)

func (*Config) BuildS3CowInitJSON

func (c *Config) BuildS3CowInitJSON() ([]byte, error)

func (*Config) PrepareCowInlineConfig

func (c *Config) PrepareCowInlineConfig() error

PrepareCowInlineConfig stamps cubelet-owned defaults (currently the reflink backend kind and its `root_dir` derived from `data_path`) onto the config so BuildCowInitJSON has everything cubecow needs.

type CowBackendConfig

type CowBackendConfig struct {
	Kind    string `toml:"-"`
	Reflink CowReflinkBackendConfig
	S3      CowS3BackendConfig
}

CowBackendConfig is filled in by cubelet at init time, never by the user, and shipped to cubecow as the `[backend]` block.

type CowInlineConfig

type CowInlineConfig struct {
	Log     CowLogConfig     `toml:"log"`
	Backend CowBackendConfig `toml:"-"`
	S3      CowS3UserConfig  `toml:"s3"`
}

CowInlineConfig mirrors the cubecow `AppConfig` schema. Cubelet owns the cubecow init payload and starts one handle per backend.kind. Users may tune `[log]` and `[cow.s3]` (s3lvol enable / socket); reflink `root_dir` and s3 `state_dir` are derived from `data_path`.

type CowLogConfig

type CowLogConfig struct {
	Level    *string `toml:"level"`
	Format   *string `toml:"format"`
	File     *string `toml:"file"`
	Rotation *string `toml:"rotation"`
}

type CowObjectMissingError

type CowObjectMissingError struct {
	VolumeName string
	Kind       string
	Cause      error
}

func (*CowObjectMissingError) Error

func (e *CowObjectMissingError) Error() string

func (*CowObjectMissingError) Is

func (e *CowObjectMissingError) Is(target error) bool

func (*CowObjectMissingError) Unwrap

func (e *CowObjectMissingError) Unwrap() error

type CowObjectRef

type CowObjectRef struct {
	Name string
	Kind string
	Role string
}

func AppendS3SealedPackageCleanupRefs

func AppendS3SealedPackageCleanupRefs(templateID string, refs []CowObjectRef) []CowObjectRef

AppendS3SealedPackageCleanupRefs adds the sealed package names that Finalize leaves behind (memory-snap, metadata work/snap). Catalog entries often list only the live MemoryVol and miss the -snap after umount.

func DefaultTemplateObjectRefs

func DefaultTemplateObjectRefs(templateID string) []CowObjectRef

type CowObjectStatus

type CowObjectStatus struct {
	Name         string
	Kind         string
	Role         string
	Exists       bool
	DevicePath   string
	SizeBytes    uint64
	ErrorMessage string
}

func InspectCowObjects

func InspectCowObjects(ctx context.Context, refs []CowObjectRef) ([]CowObjectStatus, error)

func InspectObjects

func InspectObjects(ctx context.Context, refs []CowObjectRef) ([]CowObjectStatus, error)

InspectObjects reports existence/device path for CoW object refs on the default Store.

func InspectObjectsFor

func InspectObjectsFor(ctx context.Context, backend string, refs []CowObjectRef) ([]CowObjectStatus, error)

InspectObjectsFor is InspectObjects on the Store selected by backend.

type CowReflinkBackendConfig

type CowReflinkBackendConfig struct {
	RootDir *string `toml:"-"`
}

CowReflinkBackendConfig is the `[backend.reflink]` payload. cubelet always derives `RootDir` from `data_path` so reflink files live on the same FICLONE-capable filesystem as the rest of cubelet's state.

type CowRollbackSnapshotRefs

type CowRollbackSnapshotRefs struct {
	Rootfs *CowSnapshotObject
	Memory *CowSnapshotObject
}

func ResolveRollbackRefs

func ResolveRollbackRefs(ctx context.Context, rootfsVol, memoryVol, memoryKind string) (*CowRollbackSnapshotRefs, error)

ResolveRollbackRefs resolves rootfs/memory objects for rollback on the default Store.

func ResolveRollbackRefsFor

func ResolveRollbackRefsFor(ctx context.Context, backend, rootfsVol, memoryVol, memoryKind string) (*CowRollbackSnapshotRefs, error)

ResolveRollbackRefsFor is ResolveRollbackRefs on the Store selected by backend.

func ResolveSnapshotForRollback

func ResolveSnapshotForRollback(ctx context.Context, rootfsVol, memoryVol, memoryKind string) (*CowRollbackSnapshotRefs, error)

ResolveSnapshotForRollback resolves the cubecow objects that back a snapshot for the purposes of rollback. memoryKind is honored so that snapshot replicas whose memory blob was produced by reflink-clone (kind=snapshot, used for incremental memory snapshots) work alongside the legacy empty-volume layout (kind=volume).

type CowS3BackendConfig

type CowS3BackendConfig struct {
	SocketPath         *string
	StateDir           *string
	RPCTimeoutMS       *uint64
	RPCConnectBudgetMS *uint64
	SizePolicy         *string
}

CowS3BackendConfig is the `[backend.s3]` payload stamped onto the S3 cubecow handle.

type CowS3UserConfig

type CowS3UserConfig struct {
	Enable             bool    `toml:"enable"`
	SocketPath         *string `toml:"socket_path"`
	StateDir           *string `toml:"state_dir"`
	RPCTimeoutMS       *uint64 `toml:"rpc_timeout_ms"`
	RPCConnectBudgetMS *uint64 `toml:"rpc_connect_budget_ms"`
	SizePolicy         *string `toml:"size_policy"`
}

CowS3UserConfig is the operator-facing `[cow.s3]` block.

type CowSnapshotObject

type CowSnapshotObject struct {
	Name      string
	MountName string
	Kind      string
	DevPath   string
	SizeBytes uint64
	Gen       uint32
}

func CommitMemoryFromBase

func CommitMemoryFromBase(ctx context.Context, source *CowSnapshotObject, id string, sizeBytes uint64) (*CowSnapshotObject, error)

CommitMemoryFromBase clones source memory into tpl-<id>-memory via the default Store.

func CommitMemoryFromBaseFor

func CommitMemoryFromBaseFor(ctx context.Context, backend string, source *CowSnapshotObject, id string, sizeBytes uint64) (*CowSnapshotObject, error)

CommitMemoryFromBaseFor is CommitMemoryFromBase on the Store for backend.

func CommitRootfs

func CommitRootfs(ctx context.Context, source *CowSnapshotObject, id string) (*CowSnapshotObject, error)

CommitRootfs commits source rootfs into tpl-<id>-rootfs on the default (XFS) Store.

func CommitRootfsFor

func CommitRootfsFor(ctx context.Context, backend string, source *CowSnapshotObject, id string) (*CowSnapshotObject, error)

CommitRootfsFor is CommitRootfs on the Store selected by backend (request `type`).

func CommitRootfsFromBuild

func CommitRootfsFromBuild(ctx context.Context, id string) (*CowSnapshotObject, error)

CommitRootfsFromBuild commits tpl-<id>-build-rootfs into tpl-<id>-rootfs.

func CommitRootfsFromBuildFor

func CommitRootfsFromBuildFor(ctx context.Context, backend, id string) (*CowSnapshotObject, error)

CommitRootfsFromBuildFor is CommitRootfsFromBuild on the Store for backend.

func CommitTemplateMemoryFromBase

func CommitTemplateMemoryFromBase(ctx context.Context, source *CowSnapshotObject, templateID string, sizeBytes uint64) (*CowSnapshotObject, error)

func CommitTemplateRootfs

func CommitTemplateRootfs(ctx context.Context, source *CowSnapshotObject, templateID string) (*CowSnapshotObject, error)

func CreateMemoryVolume

func CreateMemoryVolume(ctx context.Context, id string, sizeBytes uint64) (*CowSnapshotObject, error)

CreateMemoryVolume creates empty tpl-<id>-memory via the default (XFS) Store.

func CreateMemoryVolumeFor

func CreateMemoryVolumeFor(ctx context.Context, backend, id string, sizeBytes uint64) (*CowSnapshotObject, error)

CreateMemoryVolumeFor is CreateMemoryVolume on the Store for backend.

func CreateTemplateMemoryVolume

func CreateTemplateMemoryVolume(ctx context.Context, templateID string, sizeBytes uint64) (*CowSnapshotObject, error)

func CreateTemplateRootfsFromBuild

func CreateTemplateRootfsFromBuild(ctx context.Context, templateID string) (*CowSnapshotObject, error)

func DeriveRollbackRootfs

func DeriveRollbackRootfs(ctx context.Context, sandboxID, snapshotRootfsVol string, newGen uint32, desiredSizeBytes uint64) (*CowSnapshotObject, error)

DeriveRollbackRootfs creates sb-<id>-rootfs-genN from a snapshot rootfs on the default Store.

func DeriveRollbackRootfsFor

func DeriveRollbackRootfsFor(ctx context.Context, backend, sandboxID, snapshotRootfsVol string, newGen uint32, desiredSizeBytes uint64) (*CowSnapshotObject, error)

DeriveRollbackRootfsFor is DeriveRollbackRootfs on the Store selected by backend.

func GetImportedSandboxMemoryFor

func GetImportedSandboxMemoryFor(ctx context.Context, backend, sandboxID string) (*CowSnapshotObject, error)

GetImportedSandboxMemoryFor returns the sandbox-private memory disk Create minted (cross-node import or same-node S3 pause-resume clone). Empty / missing is not an error: XFS template start and XFS Resume never create one.

func GetSandboxRootfs

func GetSandboxRootfs(ctx context.Context, sandboxID, preferredVolumeName string) (*CowSnapshotObject, error)

GetSandboxRootfs resolves the live sandbox rootfs CoW object on the default Store.

func GetSandboxRootfsFor

func GetSandboxRootfsFor(ctx context.Context, backend, sandboxID, preferredVolumeName string) (*CowSnapshotObject, error)

GetSandboxRootfsFor is GetSandboxRootfs on the Store selected by backend.

func GetSandboxRootfsForSnapshot

func GetSandboxRootfsForSnapshot(ctx context.Context, sandboxID, preferredVolumeName string) (*CowSnapshotObject, error)

func RollbackDeriveNewGen

func RollbackDeriveNewGen(ctx context.Context, sandboxID, snapshotRootfsVol string, newGen uint32, desiredSizeBytes uint64) (*CowSnapshotObject, error)

type CowVolumeManager

type CowVolumeManager = XfsCow

CowVolumeManager is a historical alias for XfsCow.

type HostDirBackendInfo

type HostDirBackendInfo struct {
	VolumeName string `json:"volume_name"`

	ShareDir string `json:"share_dir"`

	BindPath string `json:"bind_path"`

	ReadOnly bool `json:"read_only"`
}

type HostStorageMeta

type HostStorageMeta struct {
	InstanceID string
	IP         string
}

type PluginVolumeBackendInfo

type PluginVolumeBackendInfo struct {
	// VolumeID is the CubeMaster VolumeRecord identifier.
	VolumeID string `json:"volume_id"`
	// Driver is the PluginVolumeSource.driver value used at Attach time.
	Driver string `json:"driver"`
	// HostPath is the host-side path returned by VolumePlugin.Attach.
	HostPath string `json:"host_path"`
	// Metadata is the opaque map returned by VolumePlugin.Attach and passed
	// verbatim back to VolumePlugin.Detach.
	Metadata map[string]string `json:"metadata,omitempty"`
	// BindPath is the per-sandbox bind-mount target created during Attach
	// (e.g. /data/cubelet/hostdir/<sandboxID>/rw/<volName>).
	// Stored so that Detach can unmount it without reconstructing the path.
	BindPath string `json:"bind_path,omitempty"`
}

PluginVolumeBackendInfo is persisted inside StorageInfo.PluginVolumeBackendInfos for every volume that was attached via the VolumePlugin framework. It carries exactly what is needed to call VolumePlugin.Detach later.

type Pool

type Pool interface {
	Get(ctx context.Context, size int64) (*devInfo, error)
	GetSync(ctx context.Context, size int64) (*devInfo, error)
	Close()
	InitBaseFile(ctx context.Context) error
}

type S3Cow

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

S3Cow is the S3-backed CoW Store. It talks to a dedicated cubecow handle started with backend.kind=s3 (same C API as XFS; cubecow selects S3LVOL / RCOW from that handle's config). The original XfsCow implementation is intentionally left untouched.

func (*S3Cow) Activate

func (m *S3Cow) Activate(ctx context.Context, snapshotID string) error

Activate implements cow.Activator. Opens cubecow objects that already exist locally. Missing objects fail — there is no remote ingest. Does not start a sandbox. Callers decide which package objects to open (via catalog/refs); this method does not apply role-specific policy.

func (*S3Cow) CloneSandboxMemory

func (m *S3Cow) CloneSandboxMemory(ctx context.Context, sandboxID, sourceName string) (*cowVolume, error)

func (*S3Cow) CommitTemplateMemory

func (m *S3Cow) CommitTemplateMemory(ctx context.Context, sourceName, templateID string, sizeBytes uint64) (*cowVolume, error)

CommitTemplateMemory derives a writable memory volume for templateID from a RO memory snapshot (create_volume_from_snapshot). A live sandbox volume (imported / cloned sb-*-memory) is snapshotted first, then cloned.

func (*S3Cow) CommitTemplateRootfs

func (m *S3Cow) CommitTemplateRootfs(ctx context.Context, sourceName, templateID string) (*cowVolume, error)

func (*S3Cow) CreateDefaultMediumVolume

func (m *S3Cow) CreateDefaultMediumVolume(ctx context.Context, sandboxID, volumeName string, sizeBytes uint64) (*cowVolume, error)

func (*S3Cow) CreateMemoryVolume

func (m *S3Cow) CreateMemoryVolume(ctx context.Context, templateID string, sizeBytes uint64) (*cowVolume, error)

func (*S3Cow) CreateSandboxRootfsFromTemplate

func (m *S3Cow) CreateSandboxRootfsFromTemplate(ctx context.Context, sandboxID, templateID string, gen uint32, desiredSizeBytes uint64) (*cowVolume, error)

func (*S3Cow) CreateTemplateBuildRootfs

func (m *S3Cow) CreateTemplateBuildRootfs(ctx context.Context, templateID string, sizeBytes uint64) (*cowVolume, error)

func (*S3Cow) DeactivateByKind

func (m *S3Cow) DeactivateByKind(ctx context.Context, name, kind string) error

func (*S3Cow) DeleteByKind

func (m *S3Cow) DeleteByKind(ctx context.Context, name, kind string) error

DeleteByKind removes a cubecow object, treating a snapshot that s3lvol refuses as busy as removed. See [isS3DeleteBusy].

func (*S3Cow) GetMetrics

func (m *S3Cow) GetMetrics(ctx context.Context) (map[string]uint64, error)

func (*S3Cow) GetSizeBytes

func (m *S3Cow) GetSizeBytes(ctx context.Context, name string) (uint64, error)

func (*S3Cow) GetVolumeInfo

func (m *S3Cow) GetVolumeInfo(ctx context.Context, name string) (*cubecow.Volume, error)

func (*S3Cow) Name

func (m *S3Cow) Name() string

Name implements cow.Store.

func (*S3Cow) ResolveDevPath

func (m *S3Cow) ResolveDevPath(ctx context.Context, name, kind string) (string, error)

func (*S3Cow) RollbackDeriveNewGen

func (m *S3Cow) RollbackDeriveNewGen(ctx context.Context, sandboxID, snapshotRootfsVol string, gen uint32, desiredSizeBytes uint64) (*cowVolume, error)

func (*S3Cow) Upload

func (m *S3Cow) Upload(ctx context.Context, snapshotID string) (*cow.RemoteUUIDs, error)

Upload implements cow.Uploader. Calls cubecow_export_snapshot per snapshot disk (rootfs / memory / metadata). Failure returns an error and does not persist remote_uuids — Master treats that as upload failed. Success returns real export uuids and records local state as running; terminal ready comes later from cubecow export_status via UploadStatus.

func (*S3Cow) UploadStatus

func (m *S3Cow) UploadStatus(ctx context.Context, snapshotID string) (*cow.RemoteStatus, error)

UploadStatus implements cow.Uploader. Aggregates cubecow_get_volume_info export_status: NONE → pending, empty/INPROGRESS → running, DONE → ready.

type SandboxImport

type SandboxImport struct {
	SandboxID string
	UUIDs     *cow.RemoteUUIDs
}

SandboxImport materializes the disks a sandbox runs on when Master placed it on a node that holds no copy of the template, snapshot or pause package it restores from.

Every disk lands under a name derived from the sandbox id, so a cross-node sandbox owns what it runs on exactly like a same-node one owns the clones it makes off the local package: destroy deletes by those names, and no later create is left short of something this one consumed. import_lvol already yields a RW volume — what cloning would have produced — so the import writes straight onto the final name and nothing has to be moved, promoted or sealed afterwards.

Deliberately nothing package-shaped is built here. A package is the static set of snapshot objects belonging to the node that created it, and a node that merely runs a restore has no owner for one: Master never learns the copy exists, sandbox destroy must not take shared state with it, and Cubelet has no package refcount — so it would sit there forever. The description a package carries (sandbox_spec.json and the run-template config) is not lost by skipping it: the metadata disk imported below is a byte copy of the package's own, and the description travels on it.

func CrossNodeSandboxImport

func CrossNodeSandboxImport(ann map[string]string) *SandboxImport

CrossNodeSandboxImport reports the imports a create owes, or nil when this node can derive the sandbox's disks locally.

Everything it needs is in the request, so each step of a create can ask again instead of passing state along, and every step names the same disks. The sandbox id is read from the request rather than taken as an argument because the create workflow runs id assignment in parallel with the step that first needs these disks; the id is settled before the workflow starts (see prepareCrossNodeRestore in the cubebox service).

Master sends remote_uuids on every S3 restore, same-node ones included, so uuids alone only say where the package could be fetched from. cross_node is Master's verdict that it placed this restore off the package's node, and only that verdict turns clones into imports.

func (*SandboxImport) EnsureMetadata

func (s *SandboxImport) EnsureMetadata(ctx context.Context) (string, error)

EnsureMetadata imports the metadata disk under the sandbox's own name and mounts it, returning the directory.

Idempotent by design, because the two restore paths reach it at different times: a Resume must read sandbox_spec.json before the thin request can even be expanded, so it lands at the Create entry, while a create from a snapshot does not know its sandbox id until createid has run and gets here on the way to the run template.

func (*SandboxImport) Memory

func (s *SandboxImport) Memory(ctx context.Context) (string, string, error)

Memory imports the package memory image as this sandbox's disk. A rootfs-only package has none, and reports an empty name rather than an error so the caller can cold-start.

func (*SandboxImport) MetadataDir

func (s *SandboxImport) MetadataDir() string

MetadataDir is where the sandbox's metadata disk is mounted. It doubles as the directory the restore reads its description from, which is why it is laid out like a package home even though no package lives on this node.

func (*SandboxImport) Rootfs

func (s *SandboxImport) Rootfs(ctx context.Context, gen uint32) (string, string, error)

Rootfs imports the package rootfs as this sandbox's disk, returning the cubecow name it landed under and its device path.

type SnapshotCatalogEntry

type SnapshotCatalogEntry struct {
	SnapshotID   string `json:"snapshot_id"`
	InstanceType string `json:"instance_type,omitempty"`
	SpecDir      string `json:"spec_dir,omitempty"`
	SnapshotPath string `json:"snapshot_path"`
	MetaDir      string `json:"meta_dir"`
	RootfsVol    string `json:"rootfs_vol"`
	RootfsKind   string `json:"rootfs_kind"`
	MemoryVol    string `json:"memory_vol"`
	MemoryKind   string `json:"memory_kind"`
	// MetadataVol/Kind is the S3 package metadata volume (cloned from the
	// node-local base snapshot or a parent package metadata volume).
	// Empty on XFS (plain directory). The node-local base volume/snapshot
	// itself is never recorded here and is never exported.
	MetadataVol  string `json:"metadata_vol,omitempty"`
	MetadataKind string `json:"metadata_kind,omitempty"`
	// BuildRootfsVol/Kind track the temporary writable working layer created
	// during template build (AppSnapshot path). They must be cleaned up at
	// template delete time. Empty for runtime snapshots (CommitSandbox), which
	// never produce a build artifact.
	BuildRootfsVol  string `json:"build_rootfs_vol,omitempty"`
	BuildRootfsKind string `json:"build_rootfs_kind,omitempty"`
	RootfsSizeBytes uint64 `json:"rootfs_size_bytes,omitempty"`
	// ComponentVersions: inventory dir name → version string (no absolute paths).
	ComponentVersions map[string]string `json:"component_versions,omitempty"`
	// Kind distinguishes the producer/semantics of this catalog entry so
	// CleanupTemplate/GetLocalSnapshot consumers can branch where needed.
	// Empty == legacy entry (pre-v4) and should be treated as a runtime
	// snapshot for backward compatibility.
	Kind      string `json:"kind,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
	// Backend is xfs|s3. Empty on legacy catalog.json means xfs.
	Backend string `json:"backend,omitempty"`
}

SnapshotCatalogEntry captures everything cubelet needs in order to roll back to a snapshot, restore-from-snapshot for a fresh sandbox, or clean up the underlying cubecow artifacts, without requiring master to carry physical cubecow/path references in its tables.

Persisted as catalog.json under <home>/metadata/. XFS and S3 both use that layout; the CoW backend is selected by the request, never by a field in this file.

Written by CommitSandbox (Kind=KindRuntimeSnapshot), AppSnapshot (Kind=KindTemplate), and Pause (Kind=pause_snapshot). Dev paths are re-resolved from cubecow on demand because they can change across activations. Unknown JSON fields are tolerated and missing fields decode as zero values so old catalog files keep working after schema extensions.

Runtime artifact identity belongs here, not in the rootfs artifact cache. In particular, future "redo snapshot" checks should compare the node's active kernel artifact identity with the identity recorded in this catalog entry; a kernel mismatch requires rebuilding the snapshot/template replica, but does not by itself require rebuilding the rootfs ext4 artifact.

func GetLocalSnapshot

func GetLocalSnapshot(ctx context.Context, snapshotID string) (*SnapshotCatalogEntry, error)

GetLocalSnapshot looks up the catalog for snapshotID in the XFS namespace.

func GetLocalSnapshotFor

func GetLocalSnapshotFor(ctx context.Context, backend, snapshotID string) (*SnapshotCatalogEntry, error)

GetLocalSnapshotFor looks up catalog.json in one CoW backend namespace.

func ListLocalSnapshots

func ListLocalSnapshots(ctx context.Context) ([]*SnapshotCatalogEntry, error)

ListLocalSnapshots returns every XFS catalog entry.

func ListLocalSnapshotsFor

func ListLocalSnapshotsFor(ctx context.Context, backend string) ([]*SnapshotCatalogEntry, error)

ListLocalSnapshotsFor returns catalog entries under one backend's roots.

func ReadSnapshotCatalogAt

func ReadSnapshotCatalogAt(snapshotPath string) (*SnapshotCatalogEntry, error)

ReadSnapshotCatalogAt loads catalog.json under snapshotPath when present. S3 packages store it in metadata/; this also looks there when the home directory is passed.

type SnapshotCatalogEntryResolved

type SnapshotCatalogEntryResolved struct {
	SnapshotCatalogEntry
	RootfsDev string `json:"rootfs_dev,omitempty"`
	MemoryDev string `json:"memory_dev,omitempty"`
}

SnapshotCatalogEntryResolved enriches a catalog entry with freshly re-resolved cubecow device paths.

func ResolveLocalSnapshot

func ResolveLocalSnapshot(ctx context.Context, snapshotID string) (*SnapshotCatalogEntryResolved, error)

ResolveLocalSnapshot returns the XFS catalog entry plus re-resolved device paths.

func ResolveLocalSnapshotFor

func ResolveLocalSnapshotFor(ctx context.Context, backend, snapshotID string) (*SnapshotCatalogEntryResolved, error)

ResolveLocalSnapshotFor resolves device paths on the Store for backend.

type StateRecoverer

type StateRecoverer interface {
	RecoverStorageState(ctx context.Context) error
	RecoverSandboxStorage(ctx context.Context, sandboxID string) error
}

type StorageInfo

type StorageInfo struct {
	Namespace string

	SandboxID string
	Volumes   map[string]*BackendFileInfo

	CubePCIDiskInfo *disk.CubePCIDiskInfo

	CubePCISystemDiskInfo *disk.CubePCISystemDiskInfo

	InstanceType string    `json:"instanceType,omitempty"`
	TemplateID   string    `json:"templateId,omitempty"`
	Backend      string    `json:"backend,omitempty"`
	CreateAt     time.Time `json:"createAt,omitempty"`
	UpdateAt     time.Time `json:"updateAt,omitempty"`

	HostDirBackendInfos map[string]*HostDirBackendInfo `json:"hostDirBackendInfos,omitempty"`

	RestoreMemoryVolURL string `json:"-"`

	// ImportedMemoryVol is the sandbox-private memory disk Create minted
	// (cross-node import or same-node S3 pause-resume clone). Destroy
	// deletes it. Empty means this restore still reads a package memory
	// snapshot (XFS template / resume / FromSnap always leave this empty).
	ImportedMemoryVol string `json:"importedMemoryVol,omitempty"`

	// PluginVolumeBackendInfos records the result of every plugin_volume attach.
	// Keyed by Volume.name (the RunCubeSandboxRequest name, not volumeID).
	// Persisted in the same DB bucket as the rest of StorageInfo so
	// Destroy / CleanUp can reconstruct what to detach.
	PluginVolumeBackendInfos map[string]*PluginVolumeBackendInfo `json:"pluginVolumeBackendInfos,omitempty"`
}

func (*StorageInfo) GetNICQueues

func (i *StorageInfo) GetNICQueues() int64

type XfsCow

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

XfsCow is the local XFS/reflink CoW Store implementation (cubecow). It is the concrete subclass of cow.Store used when storage_backend=cubecow.

func (*XfsCow) CloneSandboxMemory

func (m *XfsCow) CloneSandboxMemory(ctx context.Context, sandboxID, sourceName string) (*cowVolume, error)

CloneSandboxMemory is kept on the Store interface. XFS restore no longer calls it (see prefetchRestoreMemoryVolURL); S3 pause resume still does via S3Cow.

func (*XfsCow) CommitTemplateMemory

func (m *XfsCow) CommitTemplateMemory(ctx context.Context, sourceName, templateID string, sizeBytes uint64) (*cowVolume, error)

CommitTemplateMemory clones an existing memory object (sourceName) into the canonical template memory name for templateID via cubecow's CreateSnapshotFromVolume. Unlike CreateMemoryVolume which produces an empty volume, this preserves the source memory bytes so the hypervisor can perform an incremental (pagemap_anon) snapshot that only overwrites CoW anonymous pages while keeping the rest of the base memory intact.

activate=true is passed through so callers immediately receive a usable device path. With the reflink backend, activation is effectively a no-op (snapshots are addressable via their filesystem path).

func (*XfsCow) CommitTemplateRootfs

func (m *XfsCow) CommitTemplateRootfs(ctx context.Context, sourceName, templateID string) (*cowVolume, error)

func (*XfsCow) CreateDefaultMediumVolume

func (m *XfsCow) CreateDefaultMediumVolume(ctx context.Context, sandboxID, volumeName string, sizeBytes uint64) (*cowVolume, error)

func (*XfsCow) CreateMemoryVolume

func (m *XfsCow) CreateMemoryVolume(ctx context.Context, templateID string, sizeBytes uint64) (*cowVolume, error)

func (*XfsCow) CreateSandboxRootfsFromTemplate

func (m *XfsCow) CreateSandboxRootfsFromTemplate(ctx context.Context, sandboxID, templateID string, gen uint32, desiredSizeBytes uint64) (*cowVolume, error)

func (*XfsCow) CreateTemplateBuildRootfs

func (m *XfsCow) CreateTemplateBuildRootfs(ctx context.Context, templateID string, sizeBytes uint64) (*cowVolume, error)

func (*XfsCow) DeactivateByKind

func (m *XfsCow) DeactivateByKind(ctx context.Context, name, kind string) error

func (*XfsCow) DeleteByKind

func (m *XfsCow) DeleteByKind(ctx context.Context, name, kind string) error

func (*XfsCow) GetMetrics

func (m *XfsCow) GetMetrics(ctx context.Context) (map[string]uint64, error)

func (*XfsCow) GetSizeBytes

func (m *XfsCow) GetSizeBytes(ctx context.Context, name string) (uint64, error)

func (*XfsCow) GetVolumeInfo

func (m *XfsCow) GetVolumeInfo(ctx context.Context, name string) (*cubecow.Volume, error)

func (*XfsCow) Name

func (m *XfsCow) Name() string

Name implements cow.Store.

func (*XfsCow) ResolveDevPath

func (m *XfsCow) ResolveDevPath(ctx context.Context, name, kind string) (string, error)

func (*XfsCow) RollbackDeriveNewGen

func (m *XfsCow) RollbackDeriveNewGen(ctx context.Context, sandboxID, snapshotRootfsVol string, gen uint32, desiredSizeBytes uint64) (*cowVolume, error)

Directories

Path Synopsis
cow
Package cow declares the Cubelet CoW object-store abstraction.
Package cow declares the Cubelet CoW object-store abstraction.
s3
Package s3 holds the canonical backend name for the S3 CoW Store.
Package s3 holds the canonical backend name for the S3 CoW Store.
xfscow
Package xfscow is the local XFS/reflink CoW Store implementation.
Package xfscow is the local XFS/reflink CoW Store implementation.

Jump to

Keyboard shortcuts

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