state

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectEncoder

type ObjectEncoder[T any] interface {
	// Encode will encode the object for storage, returning a byte slice that
	// can be understood by the decode method.
	Encode(T) ([]byte, error)
	// Decode will decode the object, returning the object.
	Decode([]byte) (T, error)
}

ObjectEncoder is used to encode an object for storage

func NewVersionedObjectEncoder

func NewVersionedObjectEncoder[
	InternalVersion any,
	StorageVersion any,
	IP ObjectPtr[InternalVersion],
	SP ObjectPtr[StorageVersion],
](scheme *runtime.Scheme) (ObjectEncoder[InternalVersion], error)

NewVersionedObjectEncoder implements an ObjectLoader that accepts an internal object type, but converts it to a versioned object before encoding.

This allows the schema to evolve and change while still being able to load older files.

type ObjectPtr

type ObjectPtr[T any] interface {
	*T
	runtime.Object
}

ObjectPtr is a type constraint. It is used to validate a pointer of a given type implements Object

type State

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

State contains the current state of the CSI implementation, it tracks the volumes currently being managed.

This is its own type so both the Controller and CSI GRPC server have access to the state in a thread safe way.

func InitializeState

func InitializeState(ctx context.Context, config *config.Config, metadataEncoder ObjectEncoder[metadata.Metadata]) (*State, error)

InitializeState will setup the persistent state required by the CSI implementation. It has two main jobs:

1. Ensure the tmpfs mount exists, creating if necessary 2. Loading config for existing volumes left over from a previous instance

func (*State) GetMetadataForBundle

func (s *State) GetMetadataForBundle(name string) []metadata.Metadata

GetMetadataForBundle returns the metadata for a given bundle name, each metadata item relates to a single volume that may require a re-sync.

func (*State) StopSync

func (s *State) StopSync(id string) error

StopSync removes a volume id from the state while keeping the file, this is used to make the controller stop syncing a volume while it is being cleaned up.

This explicitly does not delete the persisted metadata file.

func (*State) Track

func (s *State) Track(meta metadata.Metadata) error

Track adds a volume to the state, meaning the controller can resume managing it if restarted

Jump to

Keyboard shortcuts

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