storage

package
v1.16.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

README

Storage

Purpose

pkg/handler/storage handles v2 file storage.

It is one of the strongest examples of why the saga pattern exists in this repository. Storage create and update are not just “write one CRD” operations. They coordinate:

  • request validation
  • storage-class lookup
  • attachment/network validation
  • quota allocation changes
  • storage-object mutation

So this package is where stateful lifecycle, attachment semantics, and quota accounting meet.

Distinctive Behaviour

  • create and update both use sagas with explicit compensation for quota allocation changes
  • attachments are validated against Network v2 resources in the caller's project
  • storage-class and region compatibility are validated before mutation
  • attachment IP ranges are derived from transitional provider-specific network storage-range information
  • attachment status reporting is currently based partly on desired state rather than fully observed actual state

Invariants And Guard Rails

  • Storage is a v2 resource and follows the flatter direct-lookup model.
  • Region access is enforced via region.CheckAccess during request validation, preventing callers from creating storage in regions they cannot see.
  • Quota allocation changes are part of the storage lifecycle contract, not an optional side effect.
  • Attachments must reference visible, provisioned networks in the same project.
  • Update preserves the existing allocation annotation while mutating the storage resource.

Caveats

  • This package still depends on transitional provider-specific network status (Status.Openstack.StorageRange) because a cleaner generic source of that information does not yet exist.
  • Attachment status is intentionally conservative and not fully actual-state derived yet.
  • The package relies heavily on saga compensation because there is no transaction boundary for storage-plus-allocation changes.

TODO

  • Remove the dependency on transitional provider-specific network status once a generic storage-range source exists.
  • Tighten attachment status so it reflects observed state rather than mostly desired state where practical.

Cross-Package Context

Documentation

Index

Constants

View Source
const (
	// DefaultParallelism is the default number of IP addresses assigned to storage.
	// This maintains legacy default behaviour for storage classes that do not specify a value.
	DefaultParallelism = 4
)

Variables

View Source
var ErrAllocation = fmt.Errorf("allocation error")

Functions

This section is empty.

Types

type Client

type Client struct {
	common.ClientArgs
}

Client provides a restful API for storage.

func New

func New(clientArgs common.ClientArgs) *Client

New creates a new client.

func (*Client) CreateV2

func (c *Client) CreateV2(ctx context.Context, request *openapi.StorageV2Create) (*openapi.StorageV2Read, error)

CreateV2 satisifies an http PUT action by creating a unique storage object. It does this leveraging the saga system which acts as a tape to enable rollbacks in case of errors.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, storageID string) error

Delete satisfies the http DELETE action by removing the client. It does not leverage the saga system because we can rely on finalizers to handle this for us.

func (*Client) Get

func (c *Client) Get(ctx context.Context, storageID string) (*openapi.StorageV2Read, error)

Get returns a storage object for a specific storageID.

func (*Client) GetRaw

func (c *Client) GetRaw(ctx context.Context, storageID string) (*regionv1.FileStorage, error)

func (*Client) GetStorageClass

func (c *Client) GetStorageClass(ctx context.Context, storageClassID string) (*openapi.StorageClassV2Read, error)

func (*Client) ListV2

ListV2 satisfies an http get to return all storage items within a project.

func (*Client) Update

func (c *Client) Update(ctx context.Context, storageID string, request *openapi.StorageV2Update) (*openapi.StorageV2Read, error)

Update satisifies an http POST action by updating the storage object attached to the storage ID. it leverages the update saga system, which acts as a tape to enable rollbacks in case of errors.

type NetworkGetter added in v1.14.0

type NetworkGetter interface {
	GetV2(ctx context.Context, id string) (*openapi.NetworkV2Read, error)
}

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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