array

package
v2.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package array provides structs and methods for configuring connection to PowerStore array.

Index

Constants

This section is empty.

Variables

View Source
var (
	// IPToArray - Store Array IPs
	IPToArray map[string]string
)

Functions

func GetLeastUsedActiveNAS added in v2.14.0

func GetLeastUsedActiveNAS(ctx context.Context, arr *PowerStoreArray, nasServers []string) (string, error)

GetLeastUsedActiveNAS finds the active NAS with the least FS count

func GetNASInCooldown added in v2.14.0

func GetNASInCooldown(arr *PowerStoreArray, nasServers []string) []string

GetNASInCooldown returns a list of NAS servers that are in cooldown

func GetVolumeUUIDPrefix added in v2.14.0

func GetVolumeUUIDPrefix(volumeID string) (prefix string)

GetVolumeUUIDPrefix extracts the prefix, if any exists, from a volume ID with a UUID format. The prefix is assumed to be all characters preceding the volume UUID including separators/delimiters, e.g. '-'. If no prefix is found, or the volume ID is not of the UUID format, the function returns an empty string.

func IsLessUsed added in v2.14.0

func IsLessUsed(nas, current *gopowerstore.NAS) bool

Types

type Consumer

type Consumer interface {
	Arrays() map[string]*PowerStoreArray
	SetArrays(map[string]*PowerStoreArray)
	DefaultArray() *PowerStoreArray
	SetDefaultArray(*PowerStoreArray)
	UpdateArrays(string, fs.Interface) error
}

Consumer provides methods for safe management of arrays

type Locker

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

Locker provides implementation for safe management of arrays

func (*Locker) Arrays

func (s *Locker) Arrays() map[string]*PowerStoreArray

Arrays is a getter for list of arrays

func (*Locker) DefaultArray

func (s *Locker) DefaultArray() *PowerStoreArray

DefaultArray is a getter for default array

func (*Locker) GetOneArray

func (s *Locker) GetOneArray(globalID string) (*PowerStoreArray, error)

GetOneArray is a getter for an arrays based on globalID

func (*Locker) SetArrays

func (s *Locker) SetArrays(arrays map[string]*PowerStoreArray)

SetArrays adds an array

func (*Locker) SetDefaultArray

func (s *Locker) SetDefaultArray(array *PowerStoreArray)

SetDefaultArray sets default array

func (*Locker) UpdateArrays

func (s *Locker) UpdateArrays(configPath string, fs fs.Interface) error

UpdateArrays updates array info

type NASCooldown added in v2.14.0

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

func NewNASCooldown added in v2.14.0

func NewNASCooldown(cooldownPeriod time.Duration, threshold int) *NASCooldown

NewNASCooldown returns a new instance of NASCooldown.

func (*NASCooldown) FallbackRetry added in v2.14.0

func (n *NASCooldown) FallbackRetry(nasList []string) string

Fallback logic - Retry all NAS servers, prioritizing least failed ones

func (*NASCooldown) GetCooldownPeriod added in v2.14.0

func (n *NASCooldown) GetCooldownPeriod() time.Duration

GetCooldownPeriod is a getter for cooldownPeriod

func (*NASCooldown) GetStatusMap added in v2.14.0

func (n *NASCooldown) GetStatusMap() map[string]*NASStatus

GetStatusMap is a getter for statusMap

func (*NASCooldown) GetThreshold added in v2.14.0

func (n *NASCooldown) GetThreshold() int

GetThreshold is a getter for threshold

func (*NASCooldown) IsInCooldown added in v2.14.0

func (n *NASCooldown) IsInCooldown(nas string) bool

Check if NAS is in cooldown

func (*NASCooldown) MarkFailure added in v2.14.0

func (n *NASCooldown) MarkFailure(nas string)

Mark NAS as failed; only enter cooldown if threshold exceeded

func (*NASCooldown) ResetFailure added in v2.14.0

func (n *NASCooldown) ResetFailure(nas string)

Reset failure count on successful FS creation

type NASCooldownTracker added in v2.14.0

type NASCooldownTracker interface {
	MarkFailure(nas string)
	IsInCooldown(nas string) bool
	ResetFailure(nas string)
	FallbackRetry(nasList []string) string
}

type NASStatus added in v2.14.0

type NASStatus struct {
	Failures      int
	CooldownUntil time.Time
}

type PowerStoreArray

type PowerStoreArray struct {
	Endpoint      string                    `yaml:"endpoint"`
	GlobalID      string                    `yaml:"globalID"`
	Username      string                    `yaml:"username"`
	Password      string                    `yaml:"password"`
	NasName       string                    `yaml:"nasName"`
	BlockProtocol identifiers.TransportType `yaml:"blockProtocol"`
	Insecure      bool                      `yaml:"skipCertificateValidation"`
	IsDefault     bool                      `yaml:"isDefault"`
	NfsAcls       string                    `yaml:"nfsAcls"`
	MetroTopology string                    `yaml:"metroTopology"`
	Labels        map[string]string         `yaml:"labels"`

	Client             gopowerstore.Client
	IP                 string
	NASCooldownTracker NASCooldownTracker
}

PowerStoreArray is a struct that stores all PowerStore connection information. It stores gopowerstore client that can be directly used to invoke PowerStore API calls. This structure is supposed to be parsed from config and mainly is created by GetPowerStoreArrays function.

func GetPowerStoreArrays

func GetPowerStoreArrays(fs fs.Interface, filePath string) (map[string]*PowerStoreArray, map[string]string, *PowerStoreArray, error)

GetPowerStoreArrays parses config.yaml file, initializes gopowerstore Clients and composes map of arrays for ease of access. It will return array that can be used as default as a second return parameter. If config does not have any array as a default then the first will be returned as a default.

func (*PowerStoreArray) GetClient

func (psa *PowerStoreArray) GetClient() gopowerstore.Client

GetClient is a getter that returns gopowerstore Client interface

func (*PowerStoreArray) GetGlobalID

func (psa *PowerStoreArray) GetGlobalID() string

GetGlobalID is a getter that returns GlobalID address of the array

func (*PowerStoreArray) GetIP

func (psa *PowerStoreArray) GetIP() string

GetIP is a getter that returns IP address of the array

func (*PowerStoreArray) GetNasName

func (psa *PowerStoreArray) GetNasName() string

GetNasName is a getter that returns name of configured NAS

type VolumeHandle added in v2.14.0

type VolumeHandle struct {
	// The UUID of a volume provisioned by a PowerStore system that is locally managed by this driver.
	LocalUUID string
	// The Global ID of the PowerStore system that is locally managed by this driver. The Global ID
	// can be found in the PowerStore UI under Settings > Properties
	LocalArrayGlobalID string
	// The UUID of a volume provisioned by a PowerStore system that is paired for replication with the
	// PowerStore system managed by this driver. Currently only used for Metro replicated volume handles.
	RemoteUUID string
	// The Global ID of the PowerStore system that is paired for replication with the PowerStore system
	// managed by this driver. Currently only used for Metro replicated volume handles.
	// The Global ID can be found in the PowerStore UI under Settings > Properties
	RemoteArrayGlobalID string
	// One of "scsi" or "nfs"
	Protocol string
}

VolumeHandle represents the components of a unique csi-powerstore volume identifier and any remote volumes associated with the volume via data replication.

func ParseVolumeID

func ParseVolumeID(ctx context.Context, volumeHandleRaw string,
	defaultArray *PowerStoreArray,
	vc *csi.VolumeCapability,
) (volumeHandle VolumeHandle, err error)

ParseVolumeID parses a volume id from the CO (Kubernetes) and tries to extract local and remote PowerStore volume UUID, Global ID, and protocol.

Example:

ParseVolumeID("1cd254s/192.168.0.1/scsi") assuming 192.168.0.1 is the IP array PSabc0123def will return
	VolumeHandle{
		LocalUUID: "1cd254s",
		LocalArrayGlobalID: "PSabc0123def",
		RemoteUUID: "",
		RemoteArrayGlobalID: "",
		Protocol: "scsi",
	}, nil

Example:

ParseVolumeID("9f840c56-96e6-4de9-b5a3-27e7c20eaa77/PSabcdef0123/scsi:9f840c56-96e6-4de9-b5a3-27e7c20eaa77/PS0123abcdef") returns
	VolumeHandle{
		LocalUUID: "9f840c56-96e6-4de9-b5a3-27e7c20eaa77",
		LocalArrayGlobalID: "PSabcdef0123",
		RemoteUUID: "9f840c56-96e6-4de9-b5a3-27e7c20eaa77",
		RemoteArrayGlobalID: "PS0123abcdef",
		Protocol: "scsi",
	}, nil

This function is backwards compatible and will try to understand volume protocol even if there is no such information in volume id. It will do that by querying default powerstore array passed as one of the arguments

Jump to

Keyboard shortcuts

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