common

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumBytesInGiB       = 1024 * 1024 * 1024
	NumGiBInTiB         = 1024
	BlockSizeSSD        = 4096
	MinSSDSizeGiB       = 1
	MaxSSDSizeGiB       = NumGiBInTiB * 10
	SSDSizeIncrementGiB = 1
	MinFSSizeGiB        = NumGiBInTiB
	MaxFSSizeGiB        = NumGiBInTiB * 1000
	FSSizeIncrementGiB  = NumGiBInTiB
)

Numeric constants.

View Source
const (
	TopologyLocationKey            = "location"
	TopologySupportsSharedDisksKey = "supports-shared-disks"

	VolumeContextDiskSerialNumberKey = "csi.crusoe.ai/serial-number"
	VolumeContextDiskNameKey         = "csi.crusoe.ai/disk-name"
)

Map keys.

View Source
const (
	SSDPluginName    = "ssd.csi.crusoe.ai"
	SSDPluginVersion = "0.1.0"

	FSPluginName    = "fs.csi.crusoe.ai"
	FSPluginVersion = "0.1.0"
)

Plugin metadata.

View Source
const (
	// OperationTimeout is the maximum time the Crusoe CSI driver will wait for an asynchronous operation to complete.
	OperationTimeout = 5 * time.Minute

	// MaxVolumesPerNode refers to the maximum number of disks that can be attached to a VM
	// ref: https://docs.crusoecloud.com/storage/disks/overview#persistent-disks
	MaxVolumesPerNode = 15

	// MaxDiskNameLength refers to the maximum permissible length of a Crusoe disk name
	// ref: https://docs.crusoecloud.com/storage/disks/overview#persistent-disks
	MaxDiskNameLength = 63
)

Runtime options.

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrTimeout        = errors.New("timeout")
)
View Source
var (
	ErrUnableToGetOpRes         = errors.New("failed to get result of operation")
	ErrUnexpectedOperationState = errors.New("unexpected operation state")
	ErrNoSizeRequested          = errors.New("no disk size requested")
)
View Source
var PluginCapabilityVolumeExpansionOffline = csi.PluginCapability{
	Type: &csi.PluginCapability_VolumeExpansion_{
		VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
			Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
		},
	},
}
View Source
var PluginCapabilityVolumeExpansionOnline = csi.PluginCapability{
	Type: &csi.PluginCapability_VolumeExpansion_{
		VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
			Type: csi.PluginCapability_VolumeExpansion_ONLINE,
		},
	},
}

Functions

func AwaitOperation

func AwaitOperation(ctx context.Context, op *crusoeapi.Operation, projectID string,
	getOp func(ctx context.Context, projectID string, operationID string) (crusoeapi.Operation, *http.Response, error),
) (
	*crusoeapi.Operation, error,
)

AwaitOperation polls an async API operation until it resolves into a success or failure state.

func CancellableSleep

func CancellableSleep(ctx context.Context, duration time.Duration) error

func GetAsyncOperationResult

func GetAsyncOperationResult[T any](ctx context.Context, op *crusoeapi.Operation, projectID string,
	getOp func(ctx context.Context, projectID string, operationID string) (crusoeapi.Operation, *http.Response, error),
) (*T, *crusoeapi.Operation, error)

func GetTopologyKey

func GetTopologyKey(pluginName, key string) string

func OpResultToError

func OpResultToError(res interface{}) (expectedErr, unexpectedErr error)

func RequestSizeToBytes

func RequestSizeToBytes(capacityRange *csi.CapacityRange) (int64, error)

func RequestSizeToGiB

func RequestSizeToGiB(capacityRange *csi.CapacityRange) (int, error)

func TrimPVCPrefix

func TrimPVCPrefix(pvcName string) string

func UnpackSwaggerErr

func UnpackSwaggerErr(original error) error

UnpackSwaggerErr takes a swagger error and safely attempts to extract the additional information which is present in the response. The error is returned unchanged if it cannot be unpacked.

Types

type DiskType

type DiskType string
const (
	// DiskTypeSSD and DiskTypeFS names correspond to the Crusoe API enum values.
	DiskTypeSSD DiskType = "persistent-ssd"
	DiskTypeFS  DiskType = "shared-volume"
)

Enums.

type OpResultErr

type OpResultErr struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type OpStatus

type OpStatus string
const (
	PollInterval          = 1 * time.Second
	OpSucceeded  OpStatus = "SUCCEEDED"
	OpInProgress OpStatus = "IN_PROGRESS"
	OpFailed     OpStatus = "FAILED"
)

Jump to

Keyboard shortcuts

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