disk

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskController

type DiskController struct {
	Log *slog.Logger
	EAC *entityserver_v1alpha.EntityAccessClient
	// contains filtered or unexported fields
}

DiskController manages disk entities and their lifecycle

func NewDiskController

func NewDiskController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, lsvdClient LsvdClient) *DiskController

NewDiskController creates a new disk controller

func NewDiskControllerWithClients

func NewDiskControllerWithClients(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, defaultClient, localReplicaClient, remoteOnlyClient LsvdClient) *DiskController

NewDiskControllerWithClients creates a new disk controller with separate clients for local and remote-only modes

func NewDiskControllerWithMountPath

func NewDiskControllerWithMountPath(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, lsvdClient LsvdClient, mountPath string) *DiskController

NewDiskControllerWithMountPath creates a new disk controller with custom mount path

func (*DiskController) Close

func (d *DiskController) Close() error

Close gracefully shuts down the disk controller

func (*DiskController) Create

func (d *DiskController) Create(ctx context.Context, disk *storage_v1alpha.Disk, meta *entity.Meta) error

Create handles creation of a new disk entity

func (*DiskController) Delete

func (d *DiskController) Delete(ctx context.Context, id entity.Id) error

Delete handles deletion of a disk entity

func (*DiskController) Init

func (d *DiskController) Init(ctx context.Context) error

Init initializes the disk controller

func (*DiskController) Start

func (d *DiskController) Start(ctx context.Context) error

Start starts the disk controller

func (*DiskController) Update

func (d *DiskController) Update(ctx context.Context, disk *storage_v1alpha.Disk, meta *entity.Meta) error

Update handles updates to an existing disk entity

type DiskLeaseController

type DiskLeaseController struct {
	Log *slog.Logger
	EAC *entityserver_v1alpha.EntityAccessClient
	// contains filtered or unexported fields
}

DiskLeaseController manages disk lease entities and exclusive access

Operational flow: 1. Disks are created in SegmentAccess when provisioned 2. When a lease is bound, the disk is initialized (lsvd.NewDisk), attached to NBD, formatted, and mounted 3. Leases control exclusive access to these mounted volumes 4. The lease.Mount.Path specifies where to mount within the sandbox's filesystem

func NewDiskLeaseController

func NewDiskLeaseController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, lsvdClient LsvdClient) *DiskLeaseController

NewDiskLeaseController creates a new disk lease controller

func NewDiskLeaseControllerWithClients

func NewDiskLeaseControllerWithClients(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, defaultClient, localReplicaClient, remoteOnlyClient LsvdClient) *DiskLeaseController

NewDiskLeaseControllerWithClients creates a new disk lease controller with separate clients for local and remote-only modes

func NewDiskLeaseControllerWithMountPath

func NewDiskLeaseControllerWithMountPath(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, lsvdClient LsvdClient, mountPath string) *DiskLeaseController

NewDiskLeaseControllerWithMountPath creates a new disk lease controller with custom mount path

func (*DiskLeaseController) CleanupOldReleasedLeases

func (d *DiskLeaseController) CleanupOldReleasedLeases(ctx context.Context) error

CleanupOldReleasedLeases deletes released leases that haven't been updated for over 1 hour

func (*DiskLeaseController) Create

Create handles creation of a new disk lease entity

func (*DiskLeaseController) Delete

func (d *DiskLeaseController) Delete(ctx context.Context, id entity.Id) error

Delete handles deletion of a disk lease entity

func (*DiskLeaseController) GetTestDisk

func (d *DiskLeaseController) GetTestDisk(diskId entity.Id) *storage_v1alpha.Disk

GetTestDisk is a test helper to retrieve disk information from test cache

func (*DiskLeaseController) Init

Init initializes the disk lease controller

func (*DiskLeaseController) SetTestDisk

func (d *DiskLeaseController) SetTestDisk(disk *storage_v1alpha.Disk)

SetTestDisk is a test helper to set disk information when EAC is not available

func (*DiskLeaseController) Update

Update handles updates to an existing disk lease entity

type DiskWatchController

type DiskWatchController struct {
	Log *slog.Logger
	EAC *entityserver_v1alpha.EntityAccessClient

	// Reference to the disk lease controller to enqueue lease reconciliations
	LeaseController *controller.ReconcileController
}

DiskWatchController watches for disk state changes and triggers reconciliation of dependent leases

func NewDiskWatchController

func NewDiskWatchController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, leaseController *controller.ReconcileController) *DiskWatchController

NewDiskWatchController creates a new disk watch controller

func (*DiskWatchController) Create

func (d *DiskWatchController) Create(ctx context.Context, disk *storage_v1alpha.Disk, meta *entity.Meta) error

Create handles creation of a disk entity (triggers lease reconciliation)

func (*DiskWatchController) Delete

func (d *DiskWatchController) Delete(ctx context.Context, id entity.Id) error

Delete handles deletion of a disk entity

func (*DiskWatchController) Init

Init initializes the disk watch controller

func (*DiskWatchController) Update

func (d *DiskWatchController) Update(ctx context.Context, disk *storage_v1alpha.Disk, meta *entity.Meta) error

Update handles updates to a disk entity (triggers lease reconciliation)

type LsvdClient

type LsvdClient interface {
	// CreateVolume creates a new LSVD volume (calls both CreateVolumeInSegmentAccess and InitializeDisk)
	// Returns the volume ID that was actually created.
	CreateVolume(ctx context.Context, sizeGb int64, filesystem string) (string, error)

	// CreateVolumeInSegmentAccess creates a volume only in SegmentAccess (no disk initialization).
	// Returns the volume ID that was created (server-generated for remote, locally-generated for local-only).
	CreateVolumeInSegmentAccess(ctx context.Context, diskName string, sizeGb int64, filesystem string) (string, error)

	// InitializeDisk initializes lsvd.NewDisk for an existing volume in SegmentAccess
	InitializeDisk(ctx context.Context, volumeId string, filesystem string) error

	// UnprovisionVolume unprovisions an LSVD volume (does not delete data)
	UnprovisionVolume(ctx context.Context, volumeId string) error

	// MountVolume mounts an LSVD volume to a mount path (requires InitializeDisk to be called first)
	MountVolume(ctx context.Context, volumeId string, mountPath string, readOnly bool) error

	// UnmountVolume unmounts an LSVD volume
	UnmountVolume(ctx context.Context, volumeId string) error

	// IsVolumeMounted checks if a volume is currently mounted
	IsVolumeMounted(ctx context.Context, volumeId string) (bool, error)

	// GetVolumeInfo returns information about a volume
	GetVolumeInfo(ctx context.Context, volumeId string) (*VolumeInfo, error)

	// ListVolumes lists all volumes
	ListVolumes(ctx context.Context) ([]string, error)

	// AcquireVolumeLease acquires a volume lease from the remote Disk API.
	// Returns the lease nonce if successful, empty string if not using remote storage.
	// nodeId and appId are included as metadata for the lease.
	AcquireVolumeLease(ctx context.Context, volumeId, nodeId, appId string) (string, error)

	// ReleaseVolumeLease releases a volume lease from the remote Disk API.
	ReleaseVolumeLease(ctx context.Context, volumeId string, nonce string) error
}

LsvdClient provides an interface for LSVD volume operations

func NewLsvdClient

func NewLsvdClient(log *slog.Logger, dataPath string, opts ...LsvdClientOption) LsvdClient

NewLsvdClient creates a new LSVD client

func NewLsvdClientWithReplica

func NewLsvdClientWithReplica(log *slog.Logger, dataPath string, authClient *cloudauth.AuthClient, cloudURL string) LsvdClient

NewLsvdClientWithReplica creates a new LSVD client with DiskAPI replication Deprecated: Use NewLsvdClient with WithReplica option instead

type LsvdClientOption

type LsvdClientOption func(*lsvdClientImpl)

LsvdClientOption is a functional option for configuring LsvdClient

func WithRemoteOnly

func WithRemoteOnly(authClient *cloudauth.AuthClient, cloudURL string) LsvdClientOption

WithRemoteOnly configures the client to use only remote storage (no local replica)

func WithReplica

func WithReplica(authClient *cloudauth.AuthClient, cloudURL string) LsvdClientOption

WithReplica enables replication to a remote DiskAPI endpoint

type VolumeInfo

type VolumeInfo struct {
	ID         string
	Name       string
	SizeBytes  int64
	Filesystem string
	MountPath  string
	UUID       string
	Status     VolumeStatus
}

VolumeInfo contains information about an LSVD volume

type VolumeStatus

type VolumeStatus string

VolumeStatus represents the state of a volume

const (
	// VolumeStatusNotFound indicates the volume doesn't exist
	VolumeStatusNotFound VolumeStatus = "not_found"
	// VolumeStatusOnDisk indicates the volume exists on disk but is not loaded in memory
	VolumeStatusOnDisk VolumeStatus = "on_disk"
	// VolumeStatusLoaded indicates the volume is loaded in memory but not mounted
	VolumeStatusLoaded VolumeStatus = "loaded"
	// VolumeStatusMounted indicates the volume is mounted and accessible
	VolumeStatusMounted VolumeStatus = "mounted"
)

Jump to

Keyboard shortcuts

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