storageos

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default api port.
	DefaultPort = 5705

	// DefaultScheme is used for api endpoint.
	DefaultScheme = "http"

	// TLSScheme scheme can be used if the api endpoint has TLS enabled.
	TLSScheme = "https"
)
View Source
const (
	// ReservedLabelPrefix is the string prefix used to identify StorageOS
	// reserved labels.  Most reserved labels will require specific API calls to
	// apply to the StorageOS object.
	ReservedLabelPrefix = "storageos.com/"

	// DataplaneReservedLabelPrefix is the reserved prefix shared by
	// all special labels which pertain to the dataplane. The CP need not
	// interpret these labels, but it must pass them to the dataplane in
	// any RPC calls it makes which pertain to the volume.
	DataplaneReservedLabelPrefix = "storageos.com/dataplane."

	// ReservedLabelComputeOnly is the node label used to indicate that a node
	// should not store data and should instead access it remotely.
	ReservedLabelComputeOnly = ReservedLabelPrefix + "computeonly"

	// ReservedLabelReplicas is the PVC label used to indicate the desired
	// number of volume replicas.
	ReservedLabelReplicas = ReservedLabelPrefix + "replicas"

	// ReservedLabelNoCache is the PVC label used to disable the per-volume
	// cache.  It can only be set when the volume is created.
	ReservedLabelNoCache = ReservedLabelPrefix + "nocache"

	// ReservedLabelNoCompress is the PVC label used to disable compression on a
	// volume. It can only be set when the volume is created.
	ReservedLabelNoCompress = ReservedLabelPrefix + "nocompress"

	// ReservedLabelFailureMode is the PVC label used to set the behaviour when
	// there are fewer copies of the data available than what was requested.
	ReservedLabelFailureMode = ReservedLabelPrefix + "failure-mode"

	// ReservedLabelEncryption is the PVC label used to indicate that the volume
	// should be encrypted.
	ReservedLabelEncryption = ReservedLabelPrefix + "encryption"

	// ReservedLabelTopologyAware is the PVC label used to indicate whether the
	// scheduler should make placement decisions based on the cluster's node
	// topology.
	ReservedLabelTopologyAware = ReservedLabelPrefix + "topology-aware"

	// ReservedLabelTopologyKey can be set on the PVC to indicate which node
	// label describes the topology used for volume placement decisions.
	ReservedLabelTopologyKey = ReservedLabelPrefix + "topology-key"

	// ReservedLabelFencing can be set on Pods to indicate that the Pod should
	// be deleted if it is running on a node that StorageOS believes no longer
	// has access to its storage.
	ReservedLabelFencing = ReservedLabelPrefix + "fenced"

	// ReservedLabelVolumeID is the label to set on created resources that refers
	// back to the StorageOS volume by its ID. This label is intended for
	// assisting with debugging and the api-manager should not rely on it being
	// set.
	ReservedLabelVolumeID = ReservedLabelPrefix + "volume-id"

	// ReservedLabelNFSMountEndpoint is the nfs attachment's mount endpoint, if any.
	ReservedLabelNFSMountEndpoint = ReservedLabelPrefix + "nfs/mount-endpoint"

	// ReservedLabelK8sPVCNamespace is set by the csi-provisioner at create
	// time.  It's treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVCNamespace = "csi.storage.k8s.io/pvc/namespace"

	// ReservedLabelK8sPVCName is set by the csi-provisioner at create time.
	// It's treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVCName = "csi.storage.k8s.io/pvc/name"

	// ReservedLabelK8sPVName is set by the csi-provisioner at create time. It's
	// treated as a reserved label by StorageOS and can't be modified.
	ReservedLabelK8sPVName = "csi.storage.k8s.io/pv/name"

	// ReservedLabelK8sStoragePoolID is set by the api-manager to dictate what storage pool the volume belongs in
	// It is immutable for volumes
	ReservedLabelStoragePoolID = "storageos.com/pool-id"
)
View Source
const (
	// NFSPort is the port exposed by the service.  Each service will have a
	// unique ip, so it can be fixed to the default NFS port.
	NFSPort int32 = 2049
	// NFSPortName is used as the name of the NFS port in the service definition.
	NFSPortName = "nfs"
	// NFSProtocol is the prtocol to be used for NFS.
	NFSProtocol = "TCP"
)
View Source
const (
	FailureModeSoft     = "soft"
	FailureModeHard     = "hard"
	FailureModeAlwaysOn = "alwayson"

	// PlacementStrategyDefault can be set to use the control plane's default
	// placement strategy.
	PlacementStrategyDefault = ""

	// PlacementStrategyTopologyAware sets the control plane's placement
	// scheduler to be topology-aware.
	PlacementStrategyTopologyAware = "topology-aware"
)

Variables

View Source
var (
	// ErrNotInitialized is returned if the API client was accessed before it
	// was initialised.
	ErrNotInitialized = errors.New("api client not initialized")
	// ErrNoAuthToken is returned when the API client did not get an error
	// during authentication but no valid auth token was returned.
	ErrNoAuthToken = errors.New("no token found in auth response")

	// HTTPTimeout is the time limit for requests made by the API Client. The
	// timeout includes connection time, any redirects, and reading the response
	// body. The timer remains running after Get, Head, Post, or Do return and
	// will interrupt reading of the Response.Body.
	HTTPTimeout = 10 * time.Second

	// AuthenticationTimeout is the time limit for authentication requests to
	// complete.  It should be longer than the HTTPTimeout.
	AuthenticationTimeout = 20 * time.Second

	// DefaultRequestTimeout is the default time limit for api requests to
	// complete.  It should be longer than the HTTPTimeout.
	DefaultRequestTimeout = 20 * time.Second
)
View Source
var (
	// ErrReservedLabelUnknown indicates that a label with the reserved prefix
	// was provided, but not recognized.
	ErrReservedLabelUnknown = errors.New("unrecognized reserved label")

	// ErrReservedLabelInvalid indicates that a label with the reserved prefix
	// was recognized, but not supported for the obejct type.
	ErrReservedLabelInvalid = errors.New("invalid reserved label for this object type")

	// ErrReservedLabelFixed can be used to indicate that a label can't be
	// modified once set during object creation.
	ErrReservedLabelFixed = errors.New("behaviour can't be changed after creation")
)
View Source
var (
	// ErrNamespaceNotFound is returned if a namespace was provided but it was
	// not found.
	ErrNamespaceNotFound = errors.New("namespace not found")

	// ErrNamespaceInUse is returned when an operation can't be completed because
	// StorageOS detects that the namespace is still in use.
	ErrNamespaceInUse = errors.New("namespace still in use")
)
View Source
var (
	// ErrNodeNotFound is returned if a node was provided but it was not found.
	ErrNodeNotFound = errors.New("node not found")

	// ErrNodeInUse is returned when an operation can't be completed because
	// StorageOS detects that the node is still in use.
	ErrNodeInUse = errors.New("node still in use")

	// ErrNodeHasLock is returned when the node lock has not yet expired.
	ErrNodeHasLock = errors.New("node lock has not yet expired")
)
View Source
var (
	// ErrBadFailureMode is returned if the failure-mode label value was
	// invalid.
	ErrBadFailureMode = errors.New("failed to parse failure-mode label, must be hard, soft, alwayson or an integer toleration")
)
View Source
var (
	// ErrPoolNotFound is returned if a pool was provided but it was not found.
	ErrPoolNotFound = errors.New("pool not found")
)
View Source
var (
	// ErrVolumeNotFound is returned if a volume was provided but it was not found.
	ErrVolumeNotFound = errors.New("volume not found")
)

Functions

func Authenticate

func Authenticate(client *stosapi.APIClient, username, password string) (context.Context, error)

Authenticate against the API and set the authentication token in the client to be used for subsequent API requests. The token must be refreshed periodically using AuthenticateRefresh().

func IsReservedLabel added in v1.1.0

func IsReservedLabel(key string) bool

IsReservedLabel returns true if the key is a StorageOS reserved label name. It does not validate whether the key is valid.

func ListErrors added in v1.1.0

func ListErrors(es []error) string

ListErrors is a basic formatter that outputs the number of errors that occurred along with a list of the errors.

func ParseFailureMode added in v1.1.0

func ParseFailureMode(s string) (stosapi.FailureModeIntent, uint64, error)

ParseFailureMode parses a string and returns either a failure mode intent or a threshold, if set. Only one of the intent or threshold should be set.

func ReadCredsFromMountedSecret

func ReadCredsFromMountedSecret(path string) (string, string, error)

ReadCredsFromMountedSecret reads the api username and password from a Kubernetes secret mounted at the given path. If the username or password in the secret changes, the data in the mounted file will also change.

Types

type Client

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

Client provides access to the StorageOS API.

func New

func New(username, password, endpoint string) (*Client, error)

New returns a pre-authenticated client for the StorageOS API. The authentication token must be refreshed periodically using AuthenticateRefresh().

func NewTestAPIClient added in v1.1.0

func NewTestAPIClient(api ControlPlane) *Client

NewTestAPIClient returns a client that uses the provided ControlPlane api client. Intended for tests that use a mocked StorageOS stosapiv2. This avoids having to publically expose the api on the Client struct.

func NewTracedClient

func NewTracedClient(username, password, endpoint string) (*Client, error)

NewTracedClient returns a pre-authenticated client for the StorageOS API that has tracing enabled. The authentication token must be refreshed periodically using AuthenticateRefresh().

func (*Client) AddToken added in v1.0.2

func (c *Client) AddToken(ctx context.Context) context.Context

AddToken adds the current authentication token to a given context.

func (*Client) CreatePool added in v1.2.12

func (c *Client) CreatePool(ctx context.Context, stosPool *stosv1.Pool) (string, error)

CreatePool creates a StorageOS pool.

func (*Client) DeleteNamespace added in v1.1.0

func (c *Client) DeleteNamespace(ctx context.Context, key client.ObjectKey) error

DeleteNamespace removes a namespace from the StorageOS cluster. Delete will fail if pre-requisites are not met (i.e. namespace has volumes).

func (*Client) DeleteNode added in v1.1.0

func (c *Client) DeleteNode(ctx context.Context, key client.ObjectKey) error

DeleteNode removes a node from the StorageOS cluster. Delete will fail if pre-requisites are not met:

		(1) The node appears offline
		(2) No node lock is held
     (3) No master deployments live on the node (i.e. node must be detected as no active volumes).

func (*Client) DeletePool added in v1.2.12

func (c *Client) DeletePool(ctx context.Context, key client.ObjectKey) error

DeletePool removes a pool from the StorageOS cluster.

func (*Client) EnsureComputeOnly added in v1.1.0

func (c *Client) EnsureComputeOnly(ctx context.Context, key client.ObjectKey, enabled bool) error

EnsureComputeOnly ensures that the compute-only behaviour has been applied to the StorageOS node.

func (*Client) EnsureFailureMode added in v1.1.0

func (c *Client) EnsureFailureMode(ctx context.Context, key client.ObjectKey, desired string) error

EnsureFailureMode ensures that the desired failure mode has been applied to the StorageOS volume.

func (*Client) EnsureNodeLabels added in v1.1.0

func (c *Client) EnsureNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureNodeLabels applies a set of labels to a StorageOS node.

Labels prefixed with the StorageOS reserved label indicator ("storageos.com/") will need to be processed separately as most have individual API endpoints to ensure that they are applied atomically.

Unreserved labels are copied as a blob and are not evaluated.

func (*Client) EnsureReplicas added in v1.1.0

func (c *Client) EnsureReplicas(ctx context.Context, key client.ObjectKey, desired uint64) error

EnsureReplicas ensures that the desired number of replicas has been applied to the StorageOS volume.

func (*Client) EnsureTopologyAware added in v1.2.0

func (c *Client) EnsureTopologyAware(ctx context.Context, key client.ObjectKey, desired bool, topologyKey string) error

EnsureTopologyAware ensures that the desired topology awareness has been applied to the StorageOS volume.

func (*Client) EnsureUnreservedNodeLabels added in v1.1.0

func (c *Client) EnsureUnreservedNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureUnreservedNodeLabels applies a set of labels to the StorageOS node if different. Existing labels will be overwritten. The set of labels must not include StorageOS reserved labels.

func (*Client) EnsureUnreservedVolumeLabels added in v1.1.0

func (c *Client) EnsureUnreservedVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureUnreservedVolumeLabels applies a set of labels to the StorageOS volume if different. Existing labels will be overwritten. Any reserved labels will be ignored.

func (*Client) EnsureVolumeLabels added in v1.1.0

func (c *Client) EnsureVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureVolumeLabels applies a set of labels to a StorageOS volume.

Labels prefixed with the StorageOS reserved label indicator ("storageos.com/") will need to be processed separately as most have individual API endpoints to ensure that they are applied atomically.

Unreserved labels are copied as a blob and are not evaluated.

func (*Client) GetLicence added in v1.2.15

func (c *Client) GetLicence(ctx context.Context) (LicenceObject, error)

Get Licence gets the StorageOS cluster licence.

func (*Client) GetPool added in v1.2.12

func (c *Client) GetPool(ctx context.Context, key client.ObjectKey) (*stosv1.Pool, error)

GetPool gets an existing pool in the StorageOS cluster by object key.

func (*Client) GetVolume added in v1.1.0

func (c *Client) GetVolume(ctx context.Context, key client.ObjectKey) (Object, error)

GetVolume returns the StorageOS volume object matching the key.

func (*Client) ListNamespaces added in v1.1.0

func (c *Client) ListNamespaces(ctx context.Context) ([]Object, error)

ListNamespaces returns a list of all StorageOS namespace objects.

func (*Client) ListNodes added in v1.1.0

func (c *Client) ListNodes(ctx context.Context) ([]client.Object, error)

ListNodes returns a list of all StorageOS node objects.

func (*Client) ListPools added in v1.2.12

func (c *Client) ListPools(ctx context.Context) (*stosv1.PoolList, error)

ListPools lists all pools in the StorageOS cluster.

func (*Client) ListVolumes added in v1.1.0

func (c *Client) ListVolumes(ctx context.Context) ([]Object, error)

ListVolumes returns a list of all StorageOS volume objects.

func (*Client) NodeObjects added in v1.1.0

func (c *Client) NodeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

NodeObjects returns a map of node objects, indexed on ObjectKey for efficient lookups.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, secretPath string, reset chan struct{}, interval time.Duration, resultCounter metrics.ResultMetric, log logr.Logger) error

Refresh the api token on a given interval, or reset is received on the reset channel. This function is blocking and is intended to be run in a goroutine. Errors are currently logged at info level since they will be retried and should be recoverable. Only a cancelled context will cause this to stop. Be aware that any errors returned will trigger a process shutdown.

func (*Client) SetExternalEndpoint

func (c *Client) SetExternalEndpoint(ctx context.Context, volID string, namespace string, endpoint string) error

SetExternalEndpoint sets the external endpoint on a SharedVolume. The endpoint should be <host|ip>:<port>.

func (*Client) UpdatePool added in v1.2.12

func (c *Client) UpdatePool(ctx context.Context, pool *stosv1.Pool) error

UpdatePool updates an existing pool in the StorageOS cluster.

func (*Client) VolumeObjects added in v1.1.0

func (c *Client) VolumeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

VolumeObjects returns a map of volume objects, indexed on object key for efficient lookups.

type ControlPlane added in v1.0.2

type ControlPlane interface {
	RefreshJwt(ctx context.Context) (stosapi.UserSession, *http.Response, error)
	AuthenticateUser(ctx context.Context, authUserData stosapi.AuthUserData) (stosapi.UserSession, *http.Response, error)
	ListNamespaces(ctx context.Context) ([]stosapi.Namespace, *http.Response, error)
	DeleteNamespace(ctx context.Context, id string, version string, localVarOptionals *stosapi.DeleteNamespaceOpts) (*http.Response, error)
	ListNodes(ctx context.Context) ([]stosapi.Node, *http.Response, error)
	UpdateNode(ctx context.Context, id string, updateNodeData stosapi.UpdateNodeData) (stosapi.Node, *http.Response, error)
	DeleteNode(ctx context.Context, id string, version string, localVarOptionals *stosapi.DeleteNodeOpts) (*http.Response, error)
	SetComputeOnly(ctx context.Context, id string, setComputeOnlyNodeData stosapi.SetComputeOnlyNodeData, localVarOptionals *stosapi.SetComputeOnlyOpts) (stosapi.Node, *http.Response, error)
	ListVolumes(ctx context.Context, namespaceID string) ([]stosapi.Volume, *http.Response, error)
	GetVolume(ctx context.Context, namespaceID string, id string) (stosapi.Volume, *http.Response, error)
	UpdateVolume(ctx context.Context, namespaceID string, id string, updateVolumeData stosapi.UpdateVolumeData, localVarOptionals *stosapi.UpdateVolumeOpts) (stosapi.Volume, *http.Response, error)
	SetReplicas(ctx context.Context, namespaceID string, id string, setReplicasRequest stosapi.SetReplicasRequest, localVarOptionals *stosapi.SetReplicasOpts) (stosapi.AcceptedMessage, *http.Response, error)
	SetFailureMode(ctx context.Context, namespaceID string, id string, setFailureModeRequest stosapi.SetFailureModeRequest, localVarOptionals *stosapi.SetFailureModeOpts) (stosapi.Volume, *http.Response, error)
	SetPlacementStrategy(ctx context.Context, namespaceID string, id string, setPlacementStrategyData stosapi.SetPlacementStrategyData, localVarOptionals *stosapi.SetPlacementStrategyOpts) (stosapi.AcceptedMessage, *http.Response, error)
	UpdateNFSVolumeMountEndpoint(ctx context.Context, namespaceID string, id string, nfsVolumeMountEndpoint stosapi.NfsVolumeMountEndpoint, localVarOptionals *stosapi.UpdateNFSVolumeMountEndpointOpts) (*http.Response, error)
	ListPools(ctx context.Context) ([]stosapi.Pool, *http.Response, error)
	GetPool(ctx context.Context, id string) (stosapi.Pool, *http.Response, error)
	UpdatePool(ctx context.Context, id string, updatePoolData stosapi.UpdatePoolData, updatePoolOpts *stosapi.UpdatePoolOpts) (stosapi.Pool, *http.Response, error)
	DeletePool(ctx context.Context, id string, version string, deleteOpts *stosapi.DeletePoolOpts) (*http.Response, error)
	CreatePool(ctx context.Context, pool stosapi.CreatePoolData) (stosapi.Pool, *http.Response, error)
	GetLicence(ctx context.Context) (stosapi.Licence, *http.Response, error)
}

ControlPlane is the subset of the StorageOS control plane ControlPlane that api-manager requires. New methods should be added here as needed, then the mocks regenerated.

type Licence added in v1.2.15

type Licence interface {
	GetLicence(ctx context.Context) (LicenceObject, error)
}

Licence provides access to StorageOS Licence.

type LicenceObject added in v1.2.15

type LicenceObject interface {
	GetClusterID() string
	GetExpiresAt() time.Time
	GetClusterCapacityBytes() uint64
	GetUsedBytes() uint64
	GetKind() string
	GetCustomerName() string
	GetFeatures() *[]string
	GetVersion() string
}

type MockClient

type MockClient struct {
	DeleteNamespaceCallCount map[client.ObjectKey]int
	DeleteNodeCallCount      map[client.ObjectKey]int
	ListNamespacesErr        error
	DeleteNamespaceErr       error
	GetNodeErr               error
	NodeObjectsErr           error
	ListNodesErr             error
	DeleteNodeErr            error
	EnsureNodeLabelsErr      error
	GetNodeLabelsErr         error
	ListVolumeErr            error
	GetVolumeErr             error
	VolumeObjectsErr         error
	EnsureVolumeLabelsErr    error
	SharedVolsErr            error
	SharedVolErr             error
	SetEndpointErr           error
	GetLicenceErr            error
	// contains filtered or unexported fields
}

MockClient provides a test interface to the StorageOS api.

func NewMockClient added in v1.1.0

func NewMockClient() *MockClient

NewMockClient returns an initialized MockClient.

func (*MockClient) AddCommunityLicence added in v1.2.15

func (c *MockClient) AddCommunityLicence() error

AddCommunityLicence adds a community licence to the StorageOS cluster.

func (*MockClient) AddEnterpriseLicence added in v1.2.15

func (c *MockClient) AddEnterpriseLicence(capacity string) error

AddEnterproseLicence adds an enterprise licence to the StorageOS cluster.

func (*MockClient) AddNamespace added in v1.1.0

func (c *MockClient) AddNamespace(key client.ObjectKey) error

AddNamespace adds a namespace to the StorageOS cluster.

func (*MockClient) AddNode added in v1.1.0

func (c *MockClient) AddNode(obj Object) error

AddNode adds a node to the StorageOS cluster.

func (*MockClient) AddVolume added in v1.1.0

func (c *MockClient) AddVolume(obj Object) error

AddVolume adds a volume to the StorageOS cluster.

func (*MockClient) DelVolume added in v1.2.1

func (c *MockClient) DelVolume(obj Object) error

DelVolume deletes a volume from the StorageOS cluster.

func (*MockClient) DeleteNamespace added in v1.1.0

func (c *MockClient) DeleteNamespace(ctx context.Context, key client.ObjectKey) error

DeleteNamespace removes a namespace from the StorageOS cluster.

func (*MockClient) DeleteNode added in v1.1.0

func (c *MockClient) DeleteNode(ctx context.Context, key client.ObjectKey) error

DeleteNode removes a node from the StorageOS cluster.

func (*MockClient) EnsureNodeLabels added in v1.1.0

func (c *MockClient) EnsureNodeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureNodeLabels applies a set of labels to the StorageOS node.

func (*MockClient) EnsureVolumeLabels added in v1.1.0

func (c *MockClient) EnsureVolumeLabels(ctx context.Context, key client.ObjectKey, labels map[string]string) error

EnsureVolumeLabels applies a set of labels to the StorageOS volume.

func (*MockClient) GetLicence added in v1.2.15

func (c *MockClient) GetLicence(ctx context.Context) (LicenceObject, error)

GetLicence retrieves the licence of the StorageOS cluster.

func (*MockClient) GetNodeLabels added in v1.1.0

func (c *MockClient) GetNodeLabels(key client.ObjectKey) (map[string]string, error)

GetNodeLabels retrieves the set of labels.

func (*MockClient) GetVolume added in v1.1.0

func (c *MockClient) GetVolume(ctx context.Context, key client.ObjectKey) (Object, error)

GetVolume retrieves a volume object.

func (*MockClient) ListNamespaces added in v1.1.0

func (c *MockClient) ListNamespaces(ctx context.Context) ([]Object, error)

ListNamespaces returns a list of StorageOS namespace objects.

func (*MockClient) ListNodes added in v1.1.0

func (c *MockClient) ListNodes(ctx context.Context) ([]client.Object, error)

ListNodes returns a list of StorageOS node objects.

func (*MockClient) ListVolumes added in v1.2.1

func (c *MockClient) ListVolumes(ctx context.Context) ([]Object, error)

func (*MockClient) NamespaceExists added in v1.1.0

func (c *MockClient) NamespaceExists(key client.ObjectKey) bool

NamespaceExists returns true if the namespace exists.

func (*MockClient) NodeExists added in v1.1.0

func (c *MockClient) NodeExists(key client.ObjectKey) bool

NodeExists returns true if the node exists.

func (*MockClient) NodeObjects added in v1.1.0

func (c *MockClient) NodeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

NodeObjects returns a map of nodes objects, indexed on object key.

func (*MockClient) RandomSharedVolume added in v1.2.1

func (c *MockClient) RandomSharedVolume() *SharedVolume

RandomSharedVolume returns a randomly generated shared volume. Always uses default namespace since it will always exist.

func (*MockClient) RandomStorageOSVolume added in v1.2.1

func (c *MockClient) RandomStorageOSVolume() *stosapi.Volume

RandomStorageOSVolume returns a randomly generated StorageOS volume. Always uses default namespace since it will always exist.

func (*MockClient) Reset

func (c *MockClient) Reset()

Reset the shared volume list.

func (*MockClient) SetExternalEndpoint

func (c *MockClient) SetExternalEndpoint(ctx context.Context, id string, namespace string, endpoint string) error

SetExternalEndpoint sets the external endpoint on a SharedVolume. The endpoint should be <host|ip>:<port>.

func (*MockClient) UpdateNodeHealth added in v1.1.0

func (c *MockClient) UpdateNodeHealth(key client.ObjectKey, healthy bool) bool

UpdateNodeHealth sets the node health.

func (*MockClient) UpdateVolumeHealth added in v1.1.0

func (c *MockClient) UpdateVolumeHealth(key client.ObjectKey, healthy bool) bool

UpdateVolumeHealth sets the volume health.

func (*MockClient) VolumeObjects added in v1.1.0

func (c *MockClient) VolumeObjects(ctx context.Context) (map[client.ObjectKey]Object, error)

VolumeObjects returns a map of volume objects, indexed on object key.

func (*MockClient) WithSetExternalEndpoint added in v1.2.1

func (c *MockClient) WithSetExternalEndpoint(callback func(string, string) error)

WithSetExternalEndpoint configures setExternalEndpoint callback.

type MockLicence added in v1.2.15

type MockLicence struct {
	ClusterID            string
	ExpiresAt            time.Time
	ClusterCapacityBytes uint64
	UsedBytes            uint64
	Kind                 string
	CustomerName         string
	Features             *[]string
	Version              string
}

MockLicence is used to replace a licence.

func (MockLicence) GetClusterCapacityBytes added in v1.2.15

func (l MockLicence) GetClusterCapacityBytes() uint64

func (MockLicence) GetClusterID added in v1.2.15

func (l MockLicence) GetClusterID() string

func (MockLicence) GetCustomerName added in v1.2.15

func (l MockLicence) GetCustomerName() string

func (MockLicence) GetExpiresAt added in v1.2.15

func (l MockLicence) GetExpiresAt() time.Time

func (MockLicence) GetFeatures added in v1.2.15

func (l MockLicence) GetFeatures() *[]string

func (MockLicence) GetKind added in v1.2.15

func (l MockLicence) GetKind() string

func (MockLicence) GetUsedBytes added in v1.2.15

func (l MockLicence) GetUsedBytes() uint64

func (MockLicence) GetVersion added in v1.2.15

func (l MockLicence) GetVersion() string

type MockObject added in v1.1.0

type MockObject struct {
	ID        string
	Name      string
	Namespace string
	Labels    map[string]string
	Healthy   bool
	Inner     interface{}
}

MockObject can be be used to replace an api object.

func (MockObject) GetID added in v1.1.0

func (m MockObject) GetID() string

GetID returns the object ID.

func (MockObject) GetInner added in v1.2.6

func (m MockObject) GetInner() interface{}

func (MockObject) GetLabels added in v1.1.0

func (m MockObject) GetLabels() map[string]string

GetLabels returns the object labels.

func (MockObject) GetName added in v1.1.0

func (m MockObject) GetName() string

GetName returns the object name.

func (MockObject) GetNamespace added in v1.1.0

func (m MockObject) GetNamespace() string

GetNamespace returns the object namespace.

func (MockObject) IsHealthy added in v1.1.0

func (m MockObject) IsHealthy() bool

IsHealthy returns true if the object is healthy.

type Object added in v1.1.0

type Object interface {
	GetInner() interface{}
	GetID() string
	GetName() string
	GetNamespace() string
	GetLabels() map[string]string
	IsHealthy() bool
}

Object is a StorageOS object with metadata.

type ObjectKey added in v1.1.0

type ObjectKey = types.NamespacedName

ObjectKey identifies a Kubernetes Object. https://github.com/kubernetes-sigs/controller-runtime/blob/74fd294a89c65c8efc17ab92e0d2014d36e357a8/pkg/client/interfaces.go

func ObjectKeyFromObject added in v1.1.0

func ObjectKeyFromObject(obj Object) ObjectKey

ObjectKeyFromObject returns the ObjectKey given a runtime.Object.

func ObjectKeys added in v1.1.0

func ObjectKeys(objects []Object) []ObjectKey

ObjectKeys converts objects to Kubernetes ObjectKeys.

type SharedVolume

type SharedVolume struct {
	*stosv1.Volume
}

SharedVolume represents a single StorageOS shared volume.

func NewSharedVolume

func NewSharedVolume(vol *stosv1.Volume) (*SharedVolume, error)

NewSharedVolume creates a new SharedVolume.

func (*SharedVolume) Endpoints

func (v *SharedVolume) Endpoints() *corev1.Endpoints

Endpoints returns the desired endpoints corresponding to the SharedVolume.

func (*SharedVolume) EndpointsIsEqual

func (v *SharedVolume) EndpointsIsEqual(e *corev1.Endpoints) bool

EndpointsIsEqual returns true if the endpoints provided matches the desired state of the SharedVolume.

func (*SharedVolume) EndpointsUpdate

func (v *SharedVolume) EndpointsUpdate(e *corev1.Endpoints) *corev1.Endpoints

EndpointsUpdate returns the provided endpoints, with updates to match the SharedVolume.

func (*SharedVolume) ExternalEndpoint

func (v *SharedVolume) ExternalEndpoint() string

ExternalEndpoint returns the name of the internal endpoint.

func (*SharedVolume) ID

func (v *SharedVolume) ID() string

ID returns the id of the volume.

func (*SharedVolume) InternalAddress

func (v *SharedVolume) InternalAddress() string

InternalAddress returns the address of the intenral SharedVolume listener.

func (*SharedVolume) InternalEndpoint

func (v *SharedVolume) InternalEndpoint() string

InternalEndpoint returns the name of the internal endpoint.

func (*SharedVolume) InternalPort

func (v *SharedVolume) InternalPort() int

InternalPort returns the port of the intenral SharedVolume listener.

func (*SharedVolume) IsEqual

func (v *SharedVolume) IsEqual(obj *SharedVolume) bool

IsEqual returns true if the given SharedVolume object is equivalent.

func (*SharedVolume) PVCName

func (v *SharedVolume) PVCName() string

PVCName returns the name of the PVC.

func (*SharedVolume) PVCNamespace added in v1.2.1

func (v *SharedVolume) PVCNamespace() string

PVCNamespace returns the namespace of the PVC.

func (*SharedVolume) PVName added in v1.2.1

func (v *SharedVolume) PVName() string

PVName returns the name of the PV.

func (*SharedVolume) Service

func (v *SharedVolume) Service(ownerRef metav1.OwnerReference) *corev1.Service

Service returns the desired service corresponding to the SharedVolume. ClusterIP can be provided if an existing ClusterIP should be re-used. The ownerRef must be set to the volume's PersistentVolumeClaim.

func (*SharedVolume) ServiceIsEqual

func (v *SharedVolume) ServiceIsEqual(svc *corev1.Service) bool

ServiceIsEqual returns true if the service provided matches the desired state of the SharedVolume.

func (*SharedVolume) ServiceName

func (v *SharedVolume) ServiceName() string

ServiceName returns the name of the service.

func (*SharedVolume) ServiceUpdate

func (v *SharedVolume) ServiceUpdate(svc *corev1.Service) *corev1.Service

ServiceUpdate returns the provided service, with updates to match the SharedVolume.

type SharedVolumeList

type SharedVolumeList []*SharedVolume

SharedVolumeList is a collection of SharedVolumes.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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