Help us shape the future of Go! Take the 2026 Go Developer Survey

disk

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const OrphanSweepGracePeriod = 2 * time.Minute

OrphanSweepGracePeriod is how old a BOUND/PENDING lease must be before the recurring orphan sweep will reclaim it. It's defense-in-depth: the sweep already only targets leases whose owning sandbox is DEAD or missing, but a young lease may belong to a sandbox that is still booting (its entity not yet settled) or one that just died and whose own in-band ReleaseDiskLeases is still in flight. Skipping young leases lets those in-band paths win the race. The boot-time sweep (Init) bypasses this with a zero grace, since it only ever sees leftovers from a prior, crashed process where nothing is mid-boot.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskController

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

	// NodeId is the ID of this node, used for creating volume entities
	NodeId compute.NodeId
	// contains filtered or unexported fields
}

DiskController manages disk entities and their lifecycle. It uses disk_volume entities to coordinate volume operations via loop devices.

func NewDiskController

func NewDiskController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, nodeId compute.NodeId, diskMode string, isCoordinator bool) *DiskController

NewDiskController creates a disk controller that uses disk_volume entities. The diskMode parameter comes from server config (MIREN_DISK_MODE); pass "" for auto-detection. isCoordinator must be true on the primary node and false on distributed runners.

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, obj *storage_v1alpha.Disk) error

Delete handles deletion of a disk entity

func (*DiskController) ForceUniversalMode added in v0.6.0

func (d *DiskController) ForceUniversalMode()

ForceUniversalMode forces the controller to use disk_volume entities with loop devices. This is used by integration tests.

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

	// NodeId is the ID of this node, used for creating disk_mount entities
	NodeId compute.NodeId
	// contains filtered or unexported fields
}

DiskLeaseController manages disk lease entities and exclusive access. It uses disk_mount entities to coordinate mount operations via loop devices.

func NewDiskLeaseController

func NewDiskLeaseController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient, nodeId compute.NodeId, diskMode string) *DiskLeaseController

NewDiskLeaseController creates a disk lease controller that uses disk_mount entities. The diskMode parameter comes from server config (MIREN_DISK_MODE); pass "" for auto-detection.

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

Delete handles deletion of a disk lease entity

func (*DiskLeaseController) ForceUniversalMode added in v0.6.0

func (d *DiskLeaseController) ForceUniversalMode()

ForceUniversalMode forces the controller to use disk_mount entities with loop devices. This is used by integration tests.

func (*DiskLeaseController) Init

Init initializes the disk lease controller

func (*DiskLeaseController) ReconcileOrphanLeases added in v0.11.0

func (d *DiskLeaseController) ReconcileOrphanLeases(ctx context.Context, minLeaseAge time.Duration) error

ReconcileOrphanLeases releases leases whose owning sandbox no longer exists or is already DEAD. On a clean shutdown the sandbox controller releases leases via StopSandbox → ReleaseDiskLeases, but a sandbox can also die without that path running: a SIGKILL, or a boot that fails after binding the lease (the boot-failure defer marks the sandbox DEAD). A BOUND lease left pointing at a dead sandbox then blocks every future sandbox that wants the same disk. This sweep runs both at boot (Init) and periodically, turning a latent deadlock into a transient, self- healing one bounded by the sweep interval.

minLeaseAge skips leases younger than the given age. The recurring sweep passes OrphanSweepGracePeriod so it never reclaims a lease that may still belong to a booting sandbox or a death whose in-band release is mid-flight; the boot-time sweep passes 0. See OrphanSweepGracePeriod for the rationale.

func (*DiskLeaseController) Update

Update handles updates to an existing disk lease entity

type DiskMountWatchController added in v0.6.0

type DiskMountWatchController struct {
	Log    *slog.Logger
	NodeId compute.NodeId

	LeaseController *controller.ReconcileController
}

DiskMountWatchController watches for disk_mount state changes and triggers re-reconciliation of the parent disk_lease entity. This bridges the gap where the disk lease controller creates a disk_mount and needs to know when the mount controller finishes mounting it.

func NewDiskMountWatchController added in v0.6.0

func NewDiskMountWatchController(log *slog.Logger, leaseController *controller.ReconcileController, nodeId compute.NodeId) *DiskMountWatchController

NewDiskMountWatchController creates a new disk mount watch controller.

func (*DiskMountWatchController) Create added in v0.6.0

func (*DiskMountWatchController) Delete added in v0.6.0

func (*DiskMountWatchController) Init added in v0.6.0

func (*DiskMountWatchController) Update added in v0.6.0

type DiskVolumeWatchController added in v0.6.0

type DiskVolumeWatchController struct {
	Log    *slog.Logger
	NodeId compute.NodeId

	DiskController *controller.ReconcileController
}

DiskVolumeWatchController watches for disk_volume state changes and triggers re-reconciliation of the parent disk entity. This bridges the gap where the disk controller creates a disk_volume and needs to know when the volume controller finishes provisioning it.

func NewDiskVolumeWatchController added in v0.6.0

func NewDiskVolumeWatchController(log *slog.Logger, diskController *controller.ReconcileController, nodeId compute.NodeId) *DiskVolumeWatchController

NewDiskVolumeWatchController creates a new disk volume watch controller.

func (*DiskVolumeWatchController) Create added in v0.6.0

func (*DiskVolumeWatchController) Delete added in v0.6.0

func (*DiskVolumeWatchController) Init added in v0.6.0

func (*DiskVolumeWatchController) Update added in v0.6.0

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

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)

Jump to

Keyboard shortcuts

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