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
- Variables
- func FromProviderToLibSnapshot(vpcSnapshot *models.Snapshot, logger *zap.Logger) (libSnapshot *provider.Snapshot)
- func FromProviderToLibVolume(vpcVolume *models.Volume, logger *zap.Logger) (libVolume *provider.Volume)
- func GetEtcPath() string
- func GiBToBytes(volumeSizeGiB int64) int64
- func IsValidVolumeIDFormat(volID string) bool
- func NewProvider(conf *vpcconfig.VPCBlockConfig, k8sClient *k8s_utils.KubernetesClient, ...) (local.Provider, error)
- func SetRetryParameters(maxAttempts int, maxGap int)
- func SkipRetryForIKS(err error) bool
- func ToInt(valueInInt string) int
- func ToInt64(valueInInt string) int64
- func WaitForSnapshotDeletion(vpcs *VPCSession, snapshotID string) (err error)
- func WaitForValidVolumeState(vpcs *VPCSession, volumeObj *models.Volume) (err error)
- func WaitForVolumeDeletion(vpcs *VPCSession, volumeID string) (err error)
- type Error
- type Fault
- type FaultResponse
- type FlexyRetry
- func (fRetry *FlexyRetry) FlexyRetry(logger *zap.Logger, funcToRetry func() (error, bool)) error
- func (fRetry *FlexyRetry) FlexyRetryWithConstGap(logger *zap.Logger, funcToRetry func() (error, bool)) error
- func (fRetry *FlexyRetry) FlexyRetryWithCustomGap(logger *zap.Logger, funcToRetry func() (error, bool)) error
- type VPCBlockProvider
- type VPCSession
- func (vpcs *VPCSession) AttachVolume(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)
- func (vpcs *VPCSession) AuthorizeVolume(volumeAuthorization provider.VolumeAuthorization) error
- func (*VPCSession) Close()
- func (vpcs *VPCSession) CreateSnapshot(sourceVolumeID string, snapshotParameters provider.SnapshotParameters) (*provider.Snapshot, error)
- func (vpcs *VPCSession) CreateVolume(volumeRequest provider.Volume) (volumeResponse *provider.Volume, err error)
- func (vpcs *VPCSession) CreateVolumeFromSnapshot(snapshot provider.Snapshot, tags map[string]string) (*provider.Volume, error)
- func (vpcs *VPCSession) DeleteSnapshot(snapshot *provider.Snapshot) error
- func (vpcs *VPCSession) DeleteVolume(volume *provider.Volume) (err error)
- func (vpcs *VPCSession) DetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*http.Response, error)
- func (vpcs *VPCSession) ExpandVolume(expandVolumeRequest provider.ExpandVolumeRequest) (size int64, err error)
- func (vpcs *VPCSession) GetProviderDisplayName() provider.VolumeProvider
- func (vpcs *VPCSession) GetSnapshot(snapshotID string) (*provider.Snapshot, error)
- func (vpcs *VPCSession) GetSnapshotByName(name string) (respSnap *provider.Snapshot, err error)
- func (vpcs *VPCSession) GetVolume(id string) (respVolume *provider.Volume, err error)
- func (vpcs *VPCSession) GetVolumeAttachment(volumeAttachmentRequest provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)
- func (vpcs *VPCSession) GetVolumeByName(name string) (respVolume *provider.Volume, err error)
- func (vpcs *VPCSession) GetVolumeByRequestID(requestID string) (*provider.Volume, error)
- func (vpcs *VPCSession) ListSnapshots(limit int, start string, filters map[string]string) (*provider.SnapshotList, error)
- func (vpcs *VPCSession) ListVolumes(limit int, start string, tags map[string]string) (*provider.VolumeList, error)
- func (vpcs *VPCSession) ProviderName() provider.VolumeProvider
- func (vpcs *VPCSession) Type() provider.VolumeType
- func (vpc *VPCSession) UpdateVolume(volumeTemplate provider.Volume) error
- func (vpcs *VPCSession) WaitForAttachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) (*provider.VolumeAttachmentResponse, error)
- func (vpcs *VPCSession) WaitForDetachVolume(volumeAttachmentTemplate provider.VolumeAttachmentRequest) error
Constants ¶
const ( VpcVolumeAttachment = "vpcVolumeAttachment" StatusAttached = "attached" StatusAttaching = "attaching" StatusDetaching = "detaching" )
VpcVolumeAttachment ...
const ( // VPCClassic ... VPCClassic = "gc" // VPCNextGen ... VPCNextGen = "g2" // PrivatePrefix ... PrivatePrefix = "private-" // BasePrivateURL ... BasePrivateURL = "https://" + PrivatePrefix // HTTPSLength ... HTTPSLength = 8 // NEXTGenProvider ... NEXTGenProvider = 2 )
const ( // VPC storage provider VPC = provider.VolumeProvider("VPC") // VolumeType ... VolumeType = provider.VolumeType("vpc-block") // SnapshotMask ... SnapshotMask = "" /* 337-byte string literal not displayed */ )
const ( ConstantRetryGap = 10 // seconds ConstMaxVPCRetryAttempt = 46 ConstMinVPCRetryGap = 3 //seconds SnapshotIDNotFound = "snapshot_id_not_found" SnapshotNotFound = "snapshots_not_found" )
ConstantRetryGap ...
const (
GiB = 1024 * 1024 * 1024
)
GiB ...
Variables ¶
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 IsValidVolumeIDFormat ¶
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 ¶
SetRetryParameters sets the retry logic parameters
func SkipRetryForIKS ¶
SkipRetryForIKS skip retry as per listed error codes
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) Properties ¶
Properties satisfies 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 (*FlexyRetry) FlexyRetry ¶
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) 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) 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
Source Files ¶
- attach_volume.go
- authorize_volume.go
- create_snapshot.go
- create_volume.go
- create_volume_from_snapshot.go
- delete_snapshot.go
- delete_volume.go
- detach_volume.go
- error.go
- expand_volume.go
- get_snapshot.go
- get_volume.go
- get_volume_attachment.go
- get_volume_with_request_id.go
- list_snapshots.go
- list_volumes.go
- provider.go
- session.go
- token_generator.go
- update_volume.go
- util.go
- wait_for_attach_volume.go
- wait_for_detach_volume.go
- wait_for_valid_volume_state.go