provider

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Package provider ...

Index

Constants

View Source
const (
	VpcVolumeAttachment = "vpcVolumeAttachment"
	StatusAttached      = "attached"
	StatusAttaching     = "attaching"
	StatusDetaching     = "detaching"
)

VpcVolumeAttachment ...

View Source
const (
	// VPCClassic ...
	VPCClassic = "gc"
	// VPCNextGen ...
	VPCNextGen = "g2"
	// PrivatePrefix ...
	PrivatePrefix = "private-"
	// BasePrivateURL ...
	BasePrivateURL = "https://" + PrivatePrefix
	// HTTPSLength ...
	HTTPSLength = 8
	// NEXTGenProvider ...
	NEXTGenProvider = 2
)
View Source
const (
	// VPC storage provider
	VPC = provider.VolumeProvider("VPC")
	// VolumeType ...
	VolumeType = provider.VolumeType("vpc-block")
	// SnapshotMask ...
	SnapshotMask = "" /* 337-byte string literal not displayed */
)
View Source
const (
	ConstantRetryGap        = 10 // seconds
	ConstMaxVPCRetryAttempt = 46
	ConstMinVPCRetryGap     = 3 //seconds
	SnapshotIDNotFound      = "snapshot_id_not_found"
	SnapshotNotFound        = "snapshots_not_found"
)

ConstantRetryGap ...

View Source
const (
	GiB = 1024 * 1024 * 1024
)

GiB ...

Variables

View Source
var (
	// DeleteVolumeReason ...
	DeleteVolumeReason = "deleted by ibm-volume-lib on behalf of user request"
)

Functions

func FromProviderToLibSnapshot

func FromProviderToLibSnapshot(vpcSnapshot *models.Snapshot, logger *zap.Logger) (libSnapshot *provider.Snapshot)

FromProviderToLibSnapshot converting vpc provider snapshot type to generic lib snapshot type

func FromProviderToLibVolume

func FromProviderToLibVolume(vpcVolume *models.Volume, logger *zap.Logger) (libVolume *provider.Volume)

FromProviderToLibVolume converting vpc provider volume type to generic lib volume type

func GetEtcPath

func GetEtcPath() string

GetEtcPath returns the path to the etc directory

func GiBToBytes

func GiBToBytes(volumeSizeGiB int64) int64

GiBToBytes converts GiB to Bytes

func IsValidVolumeIDFormat

func IsValidVolumeIDFormat(volID string) bool

IsValidVolumeIDFormat validating(gc has 5 parts and NG has 6 parts)

func NewProvider

func NewProvider(conf *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient, logger *zap.Logger) (local.Provider, error)

NewProvider initialises an instance of an IaaS provider.

func SetRetryParameters

func SetRetryParameters(maxAttempts int, maxGap int)

SetRetryParameters sets the retry logic parameters

func SkipRetryForIKS

func SkipRetryForIKS(err error) bool

SkipRetryForIKS skip retry as per listed error codes

func ToInt

func ToInt(valueInInt string) int

ToInt ...

func ToInt64

func ToInt64(valueInInt string) int64

ToInt64 ...

func WaitForSnapshotDeletion

func WaitForSnapshotDeletion(vpcs *VPCSession, snapshotID string) (err error)

WaitForSnapshotDeletion checks the snapshot for valid status

func WaitForValidVolumeState

func WaitForValidVolumeState(vpcs *VPCSession, volumeObj *models.Volume) (err error)

WaitForValidVolumeState checks the volume for valid status

func WaitForVolumeDeletion

func WaitForVolumeDeletion(vpcs *VPCSession, volumeID string) (err error)

WaitForVolumeDeletion checks the volume for valid status

Types

type Error

type Error struct {
	// Fault ...
	Fault Fault
}

Error implements the error interface for a Fault. Most easily constructed using util.NewError() or util.NewErrorWithProperties()

func (Error) Code

func (err Error) Code() reasoncode.ReasonCode

Code satisfies the legacy provider.Error interface

func (Error) Error

func (err Error) Error() string

Error satisfies the error contract

func (Error) Properties

func (err Error) Properties() map[string]string

Properties satisfies the legacy provider.Error interface

func (Error) Wrapped

func (err Error) Wrapped() []string

Wrapped mirrors the legacy provider.Error interface

type Fault

type Fault struct {
	// Message is the fault message (required)
	Message string `json:"msg"`

	// ReasonCode is fault reason code (required)  //TODO: will have better reasoncode mechanism
	ReasonCode reasoncode.ReasonCode `json:"code"`

	// WrappedErrors contains wrapped error messages (if applicable)
	Wrapped []string `json:"wrapped,omitempty"`

	// Properties contains diagnostic properties (if applicable)
	Properties map[string]string `json:"properties,omitempty"`
}

Fault encodes a fault condition. Does not implement the error interface so that cannot be accidentally misassigned to error variables when returned in a function response.

type FaultResponse

type FaultResponse struct {
	Fault *Fault `json:"fault,omitempty"`
}

FaultResponse is an optional Fault

type FlexyRetry

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

FlexyRetry ...

func NewFlexyRetry

func NewFlexyRetry(maxRtyAtmpt int, maxrRtyGap int) FlexyRetry

NewFlexyRetry ...

func NewFlexyRetryDefault

func NewFlexyRetryDefault() FlexyRetry

NewFlexyRetryDefault ...

func (*FlexyRetry) FlexyRetry

func (fRetry *FlexyRetry) FlexyRetry(logger *zap.Logger, funcToRetry func() (error, bool)) error

FlexyRetry ...

func (*FlexyRetry) FlexyRetryWithConstGap

func (fRetry *FlexyRetry) FlexyRetryWithConstGap(logger *zap.Logger, funcToRetry func() (error, bool)) error

FlexyRetryWithConstGap ...

func (*FlexyRetry) FlexyRetryWithCustomGap

func (fRetry *FlexyRetry) FlexyRetryWithCustomGap(logger *zap.Logger, funcToRetry func() (error, bool)) error

FlexyRetryWithCustomGap ...

Flow 1.) First attempt is immediately after attach was done. 2.) MinVPCRetryGapAttempts will be done with interval MinVPCRetryGap 3.) 2*MinVPCRetryGapAttempts will be done with interval of MinVPCRetryGap*2 ( it will default to 10 sec if it more than 10) 4.) Remaining attempts will be done with interval of 10 secs

type VPCBlockProvider

type VPCBlockProvider struct {
	Config *vpcconfig.VPCBlockConfig

	ContextCF local.ContextCredentialsFactory

	ClientProvider riaas.RegionalAPIClientProvider

	APIConfig riaas.Config
	// contains filtered or unexported fields
}

VPCBlockProvider implements provider.Provider

func (*VPCBlockProvider) ContextCredentialsFactory

func (vpcp *VPCBlockProvider) ContextCredentialsFactory(zone *string) (local.ContextCredentialsFactory, error)

ContextCredentialsFactory ...

func (*VPCBlockProvider) OpenSession

func (vpcp *VPCBlockProvider) OpenSession(ctx context.Context, contextCredentials provider.ContextCredentials, ctxLogger *zap.Logger) (provider.Session, error)

OpenSession opens a session on the provider

type VPCSession

type VPCSession struct {
	provider.DefaultVolumeProvider
	VPCAccountID          string
	Config                *vpcconfig.VPCBlockConfig
	ContextCredentials    provider.ContextCredentials
	VolumeType            provider.VolumeType
	Provider              provider.VolumeProvider
	Apiclient             riaas.RegionalAPI
	APIClientVolAttachMgr instances.VolumeAttachManager
	APIVersion            string
	Logger                *zap.Logger
	APIRetry              FlexyRetry
	SessionError          error
}

VPCSession implements lib.Session

func (*VPCSession) AttachVolume

func (vpcs *VPCSession) AttachVolume(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

AttachVolume attach volume based on given volume attachment request

func (*VPCSession) AuthorizeVolume

func (vpcs *VPCSession) AuthorizeVolume(volumeAuthorization provider.VolumeAuthorization) error

AuthorizeVolume allows aceess to volume based on given authorization

func (*VPCSession) Close

func (*VPCSession) Close()

Close at present does nothing

func (*VPCSession) CreateSnapshot

func (vpcs *VPCSession) CreateSnapshot(sourceVolumeID string, snapshotParameters provider.SnapshotParameters) (*provider.Snapshot, error)

CreateSnapshot creates snapshot

func (*VPCSession) CreateVolume

func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeResponse *provider.Volume, err error)

CreateVolume Get the volume by using ID

func (*VPCSession) CreateVolumeFromSnapshot

func (vpcs *VPCSession) CreateVolumeFromSnapshot(snapshot provider.Snapshot, tags map[string]string) (*provider.Volume, error)

CreateVolumeFromSnapshot creates the volume by using ID

func (*VPCSession) DeleteSnapshot

func (vpcs *VPCSession) DeleteSnapshot(snapshot *provider.Snapshot) error

DeleteSnapshot delete snapshot

func (*VPCSession) DeleteVolume

func (vpcs *VPCSession) DeleteVolume(volume *provider.Volume) (err error)

DeleteVolume deletes the volume

func (*VPCSession) DetachVolume

func (vpcs *VPCSession) DetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*http.Response, error)

DetachVolume detach volume based on given volume attachment request

func (*VPCSession) ExpandVolume

func (vpcs *VPCSession) ExpandVolume(expandVolumeRequest provider.ExpandVolumeRequest) (size int64, err error)

ExpandVolume Get the volume by using ID

func (*VPCSession) GetProviderDisplayName

func (vpcs *VPCSession) GetProviderDisplayName() provider.VolumeProvider

GetProviderDisplayName returns the name of the VPC provider

func (*VPCSession) GetSnapshot

func (vpcs *VPCSession) GetSnapshot(snapshotID string) (*provider.Snapshot, error)

GetSnapshot get snapshot

func (*VPCSession) GetSnapshotByName

func (vpcs *VPCSession) GetSnapshotByName(name string) (respSnap *provider.Snapshot, err error)

GetSnapshotByName ...

func (*VPCSession) GetVolume

func (vpcs *VPCSession) GetVolume(id string) (respVolume *provider.Volume, err error)

GetVolume gets the volume by using ID

func (*VPCSession) GetVolumeAttachment

func (vpcs *VPCSession) GetVolumeAttachment(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

GetVolumeAttachment get the volume attachment based on the request

func (*VPCSession) GetVolumeByName

func (vpcs *VPCSession) GetVolumeByName(name string) (respVolume *provider.Volume, err error)

GetVolumeByName ...

func (*VPCSession) GetVolumeByRequestID

func (vpcs *VPCSession) GetVolumeByRequestID(requestID string) (*provider.Volume, error)

GetVolumeByRequestID get volume by volume ID

func (*VPCSession) ListSnapshots

func (vpcs *VPCSession) ListSnapshots(limit int, start string, filters map[string]string) (*provider.SnapshotList, error)

ListSnapshots list all snapshots

func (*VPCSession) ListVolumes

func (vpcs *VPCSession) ListVolumes(limit int, start string, tags map[string]string) (*provider.VolumeList, error)

ListVolumes list all volumes

func (*VPCSession) ProviderName

func (vpcs *VPCSession) ProviderName() provider.VolumeProvider

ProviderName ...

func (*VPCSession) Type

func (vpcs *VPCSession) Type() provider.VolumeType

Type ...

func (*VPCSession) UpdateVolume

func (vpc *VPCSession) UpdateVolume(volumeTemplate provider.Volume) error

UpdateVolume POSTs to /volumes

func (*VPCSession) WaitForAttachVolume

func (vpcs *VPCSession) WaitForAttachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)

WaitForAttachVolume waits for volume to be attached to node. e.g waits till status becomes attached

func (*VPCSession) WaitForDetachVolume

func (vpcs *VPCSession) WaitForDetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) error

WaitForDetachVolume waits for volume to be detached from node. e.g waits till no volume attachment is found

Jump to

Keyboard shortcuts

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