client

package
v1.29.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// KiB is 1024 bytes
	KiB = 1 << (10 * iota)
	// MiB is 1024KB
	MiB
	// GiB is 1024 MB
	GiB
	// TiB is 1024 GB
	TiB
)
View Source
const (

	// OCIVolumeID is the name of the oci volume id.
	OCIVolumeID = "ociVolumeID"
	// OCIVolumeBackupID is the name of the oci volume backup id annotation.
	OCIVolumeBackupID = "volume.beta.kubernetes.io/oci-volume-source"
	// FSType is the name of the file storage type parameter for storage classes.
	FSType = "fsType"
)
View Source
const (
	HTTP400RelatedResourceNotAuthorizedOrNotFoundCode = "RelatedResourceNotAuthorizedOrNotFound"
	HTTP401NotAuthenticatedCode                       = "NotAuthenticated"
	HTTP404NotAuthorizedOrNotFoundCode                = "NotAuthorizedOrNotFound"
	HTTP409IncorrectStateCode                         = "IncorrectState"
	HTTP409NotAuthorizedOrResourceAlreadyExistsCode   = "NotAuthorizedOrResourceAlreadyExists"
	HTTP429TooManyRequestsCode                        = "TooManyRequests"
	HTTP500InternalServerErrorCode                    = "InternalServerError"
)

HTTP Error Types

View Source
const (
	ListWorkRequestLimit = 100
)
View Source
const (
	NetworkLoadBalancerEntityType = "NetworkLoadBalancer"
)

Variables

This section is empty.

Functions

func IsInstanceInStoppedState

func IsInstanceInStoppedState(instance *core.Instance) bool

IsInstanceInStoppedState returns true if the instance is in a stopped or stopping state, false otherwise.

func IsInstanceInTerminalState

func IsInstanceInTerminalState(instance *core.Instance) bool

IsInstanceInTerminalState returns true if the instance is in a terminal state, false otherwise.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error indicates that a resource could not be found.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable returns true if the given error is retriable.

func IsSystemTagNotFoundOrNotAuthorisedError added in v1.26.4

func IsSystemTagNotFoundOrNotAuthorisedError(logger *zap.SugaredLogger, err error) bool

func MapProviderIDToResourceID added in v1.26.3

func MapProviderIDToResourceID(providerID string) string

MapProviderIDToResourceID parses the provider id and returns the instance ocid.

func NewRetryPolicyWithMaxAttempts

func NewRetryPolicyWithMaxAttempts(retryAttempts uint) *common.RetryPolicy

NewRetryPolicyWithMaxAttempts returns a RetryPolicy with the specified max retryAttempts

func RateLimitError

func RateLimitError(isWrite bool, opName string) error

RateLimitError produces an Errorf for rate limiting.

Types

type BlockStorageInterface

type BlockStorageInterface interface {
	AwaitVolumeAvailableORTimeout(ctx context.Context, id string) (*core.Volume, error)
	AwaitVolumeCloneAvailableOrTimeout(ctx context.Context, id string) (*core.Volume, error)
	CreateVolume(ctx context.Context, details core.CreateVolumeDetails) (*core.Volume, error)
	DeleteVolume(ctx context.Context, id string) error
	GetVolume(ctx context.Context, id string) (*core.Volume, error)
	GetVolumesByName(ctx context.Context, volumeName, compartmentID string) ([]core.Volume, error)
	UpdateVolume(ctx context.Context, volumeId string, details core.UpdateVolumeDetails) (*core.Volume, error)

	AwaitVolumeBackupAvailableOrTimeout(ctx context.Context, id string) (*core.VolumeBackup, error)
	CreateVolumeBackup(ctx context.Context, details core.CreateVolumeBackupDetails) (*core.VolumeBackup, error)
	DeleteVolumeBackup(ctx context.Context, id string) error
	GetVolumeBackup(ctx context.Context, id string) (*core.VolumeBackup, error)
	GetVolumeBackupsByName(ctx context.Context, snapshotName, compartmentID string) ([]core.VolumeBackup, error)
}

BlockStorageInterface defines the interface to OCI block storage utilised by the volume provisioner.

type ComputeInterface

type ComputeInterface interface {
	// GetInstance gets information about the specified instance.
	GetInstance(ctx context.Context, id string) (*core.Instance, error)
	ListInstancesByCompartmentAndAD(ctx context.Context, compartmentId, availabilityDomain string) (response []core.Instance, err error)

	// GetInstanceByNodeName gets the OCI instance corresponding to the given
	// Kubernetes node name.
	GetInstanceByNodeName(ctx context.Context, compartmentID, vcnID, nodeName string) (*core.Instance, error)

	GetPrimaryVNICForInstance(ctx context.Context, compartmentID, instanceID string) (*core.Vnic, error)

	VolumeAttachmentInterface
}

ComputeInterface defines the subset of the OCI compute API utilised by the CCM.

type FileStorageInterface

type FileStorageInterface interface {
	AwaitMountTargetActive(ctx context.Context, logger *zap.SugaredLogger, id string) (*fss.MountTarget, error)

	GetFileSystem(ctx context.Context, id string) (*fss.FileSystem, error)
	GetFileSystemSummaryByDisplayName(ctx context.Context, compartmentID, ad, displayName string) (bool, []fss.FileSystemSummary, error)
	AwaitFileSystemActive(ctx context.Context, logger *zap.SugaredLogger, id string) (*fss.FileSystem, error)
	CreateFileSystem(ctx context.Context, details fss.CreateFileSystemDetails) (*fss.FileSystem, error)
	DeleteFileSystem(ctx context.Context, id string) error

	CreateExport(ctx context.Context, details fss.CreateExportDetails) (*fss.Export, error)
	FindExport(ctx context.Context, fsID, path, exportSetID string) (*fss.ExportSummary, error)
	AwaitExportActive(ctx context.Context, logger *zap.SugaredLogger, id string) (*fss.Export, error)
	DeleteExport(ctx context.Context, id string) error

	GetMountTarget(ctx context.Context, id string) (*fss.MountTarget, error)
	CreateMountTarget(ctx context.Context, details fss.CreateMountTargetDetails) (*fss.MountTarget, error)
	DeleteMountTarget(ctx context.Context, id string) error
	GetMountTargetSummaryByDisplayName(ctx context.Context, compartmentID, ad, mountTargetName string) (bool, []fss.MountTargetSummary, error)
}

FileStorageInterface defines the interface to OCI File Storage Service consumed by the volume provisioner and fss-controller.

type GenericBackend added in v1.19.12

type GenericBackend struct {
	Port      *int
	Name      *string
	IpAddress *string
	TargetId  *string
	Weight    *int
}

type GenericBackendSetDetails added in v1.19.12

type GenericBackendSetDetails struct {
	Name                            *string
	HealthChecker                   *GenericHealthChecker
	Policy                          *string
	Backends                        []GenericBackend
	SessionPersistenceConfiguration *GenericSessionPersistenceConfiguration
	// Only needed for LB
	SslConfiguration *GenericSslConfigurationDetails
	// Only needed for NLB
	IsPreserveSource *bool
}

type GenericCertificate added in v1.19.12

type GenericCertificate struct {
	CertificateName   *string
	Passphrase        *string
	PrivateKey        *string
	PublicCertificate *string
	CaCertificate     *string
}

type GenericConnectionConfiguration added in v1.19.12

type GenericConnectionConfiguration struct {
	IdleTimeout                    *int64
	BackendTcpProxyProtocolVersion *int
	BackendTcpProxyProtocolOptions []string
}

type GenericCreateLoadBalancerDetails added in v1.19.12

type GenericCreateLoadBalancerDetails struct {
	CompartmentId               *string
	DisplayName                 *string
	ShapeName                   *string
	SubnetIds                   []string
	ShapeDetails                *GenericShapeDetails
	IsPrivate                   *bool
	IsPreserveSourceDestination *bool
	ReservedIps                 []GenericReservedIp
	Listeners                   map[string]GenericListener
	BackendSets                 map[string]GenericBackendSetDetails
	NetworkSecurityGroupIds     []string
	FreeformTags                map[string]string
	DefinedTags                 map[string]map[string]interface{}

	// Only needed for LB
	Certificates map[string]GenericCertificate
}

type GenericHealthChecker added in v1.19.12

type GenericHealthChecker struct {
	Protocol          string
	IsForcePlainText  *bool
	Port              *int
	UrlPath           *string
	Retries           *int
	TimeoutInMillis   *int
	IntervalInMillis  *int
	ResponseBodyRegex *string
	// Only needed for NLB
	ReturnCode *int
}

type GenericIpAddress added in v1.19.12

type GenericIpAddress struct {
	IpAddress  *string
	IsPublic   *bool
	ReservedIp *GenericReservedIp
}

type GenericListener added in v1.19.12

type GenericListener struct {
	Name                    *string
	DefaultBackendSetName   *string
	Port                    *int
	Protocol                *string
	HostnameNames           []string
	PathRouteSetName        *string
	SslConfiguration        *GenericSslConfigurationDetails
	ConnectionConfiguration *GenericConnectionConfiguration
	RoutingPolicyName       *string
	RuleSetNames            []string
}

type GenericLoadBalancer added in v1.19.12

type GenericLoadBalancer struct {
	Id                      *string
	CompartmentId           *string
	DisplayName             *string
	LifecycleState          *string
	ShapeName               *string
	IpAddresses             []GenericIpAddress
	ShapeDetails            *GenericShapeDetails
	IsPrivate               *bool
	SubnetIds               []string
	NetworkSecurityGroupIds []string
	Listeners               map[string]GenericListener
	Certificates            map[string]GenericCertificate
	BackendSets             map[string]GenericBackendSetDetails

	FreeformTags map[string]string
	DefinedTags  map[string]map[string]interface{}
	SystemTags   map[string]map[string]interface{}
}

type GenericLoadBalancerInterface added in v1.19.12

type GenericLoadBalancerInterface interface {
	CreateLoadBalancer(ctx context.Context, details *GenericCreateLoadBalancerDetails, serviceUid *string) (string, error)

	GetLoadBalancer(ctx context.Context, id string) (*GenericLoadBalancer, error)
	GetLoadBalancerByName(ctx context.Context, compartmentID, name string) (*GenericLoadBalancer, error)
	DeleteLoadBalancer(ctx context.Context, id string) (string, error)

	GetCertificateByName(ctx context.Context, lbID, name string) (*GenericCertificate, error)
	CreateCertificate(ctx context.Context, lbID string, cert *GenericCertificate) (string, error)

	CreateBackendSet(ctx context.Context, lbID, name string, details *GenericBackendSetDetails) (string, error)
	UpdateBackendSet(ctx context.Context, lbID, name string, details *GenericBackendSetDetails) (string, error)
	DeleteBackendSet(ctx context.Context, lbID, name string) (string, error)

	UpdateListener(ctx context.Context, lbID, name string, details *GenericListener) (string, error)
	CreateListener(ctx context.Context, lbID, name string, details *GenericListener) (string, error)
	DeleteListener(ctx context.Context, lbID, name string) (string, error)

	UpdateLoadBalancerShape(context.Context, string, *GenericUpdateLoadBalancerShapeDetails) (string, error)
	UpdateNetworkSecurityGroups(context.Context, string, []string) (string, error)

	AwaitWorkRequest(ctx context.Context, id string) (*GenericWorkRequest, error)
	ListWorkRequests(ctx context.Context, compartmentId, lbId string) ([]*GenericWorkRequest, error)
	UpdateLoadBalancer(ctx context.Context, lbID string, details *GenericUpdateLoadBalancerDetails) (string, error)
}

type GenericReservedIp added in v1.19.12

type GenericReservedIp struct {
	Id *string
}

type GenericSessionPersistenceConfiguration added in v1.19.12

type GenericSessionPersistenceConfiguration struct {
	CookieName      *string
	DisableFallback *bool
}

type GenericShapeDetails added in v1.19.12

type GenericShapeDetails struct {
	MinimumBandwidthInMbps *int
	MaximumBandwidthInMbps *int
}

type GenericSslConfigurationDetails added in v1.19.12

type GenericSslConfigurationDetails struct {
	VerifyDepth                    *int
	VerifyPeerCertificate          *bool
	TrustedCertificateAuthorityIds []string
	CertificateIds                 []string
	CertificateName                *string
	ServerOrderPreference          string
	CipherSuiteName                *string
	Protocols                      []string
}

type GenericUpdateLoadBalancerDetails added in v1.26.4

type GenericUpdateLoadBalancerDetails struct {
	FreeformTags map[string]string
	DefinedTags  map[string]map[string]interface{}
}

type GenericUpdateLoadBalancerShapeDetails added in v1.19.12

type GenericUpdateLoadBalancerShapeDetails struct {
	ShapeName    *string
	ShapeDetails *GenericShapeDetails
}

type GenericUpdateNetworkSecurityGroupsDetails added in v1.19.12

type GenericUpdateNetworkSecurityGroupsDetails struct {
	NetworkSecurityGroupIds []string
}

type GenericWorkRequest added in v1.19.12

type GenericWorkRequest struct {
	Id             *string
	LoadBalancerId *string
	Type           *string
	LifecycleState *string
	Message        *string
	CompartmentId  *string
	OperationType  string
	Status         string
}

type IdentityInterface

type IdentityInterface interface {
	GetAvailabilityDomainByName(ctx context.Context, compartmentID, name string) (*identity.AvailabilityDomain, error)
	ListAvailabilityDomains(ctx context.Context, compartmentID string) ([]identity.AvailabilityDomain, error)
}

IdentityInterface defines the interface to the OCI identity service consumed by the volume provisioner.

type Interface

type Interface interface {
	Compute() ComputeInterface
	LoadBalancer(*zap.SugaredLogger, string, string, *authv1.TokenRequest) GenericLoadBalancerInterface
	Networking() NetworkingInterface
	BlockStorage() BlockStorageInterface
	FSS() FileStorageInterface
	Identity() IdentityInterface
}

Interface of consumed OCI API functionality.

func GetClient

func GetClient(logger *zap.SugaredLogger, cfg *config.Config) (Interface, error)

GetClient returns the client for given Configuration

func New

func New(logger *zap.SugaredLogger, cp common.ConfigurationProvider, opRateLimiter *RateLimiter) (Interface, error)

New constructs an OCI API client.

type NetworkingInterface

type NetworkingInterface interface {
	GetSubnet(ctx context.Context, id string) (*core.Subnet, error)
	GetSubnetFromCacheByIP(ip string) (*core.Subnet, error)
	IsRegionalSubnet(ctx context.Context, id string) (bool, error)

	GetVcn(ctx context.Context, id string) (*core.Vcn, error)

	GetSecurityList(ctx context.Context, id string) (core.GetSecurityListResponse, error)
	UpdateSecurityList(ctx context.Context, id string, etag string, ingressRules []core.IngressSecurityRule, egressRules []core.EgressSecurityRule) (core.UpdateSecurityListResponse, error)

	GetPrivateIp(ctx context.Context, id string) (*core.PrivateIp, error)

	GetPublicIpByIpAddress(ctx context.Context, id string) (*core.PublicIp, error)

	CreateNetworkSecurityGroup(ctx context.Context, compartmentId, vcnId, displayName, serviceUid string) (*core.NetworkSecurityGroup, error)
	GetNetworkSecurityGroup(ctx context.Context, id string) (*core.NetworkSecurityGroup, *string, error)
	ListNetworkSecurityGroups(ctx context.Context, displayName, compartmentId, vcnId string) ([]core.NetworkSecurityGroup, error)
	UpdateNetworkSecurityGroup(ctx context.Context, id, etag string, freeformTags map[string]string) (*core.NetworkSecurityGroup, error)
	DeleteNetworkSecurityGroup(ctx context.Context, id, etag string) (*string, error)

	AddNetworkSecurityGroupSecurityRules(ctx context.Context, id string, details core.AddNetworkSecurityGroupSecurityRulesDetails) (*core.AddNetworkSecurityGroupSecurityRulesResponse, error)
	RemoveNetworkSecurityGroupSecurityRules(ctx context.Context, id string, details core.RemoveNetworkSecurityGroupSecurityRulesDetails) (*core.RemoveNetworkSecurityGroupSecurityRulesResponse, error)
	ListNetworkSecurityGroupSecurityRules(ctx context.Context, id string, direction core.ListNetworkSecurityGroupSecurityRulesDirectionEnum) ([]core.SecurityRule, error)
	UpdateNetworkSecurityGroupSecurityRules(ctx context.Context, id string, details core.UpdateNetworkSecurityGroupSecurityRulesDetails) (*core.UpdateNetworkSecurityGroupSecurityRulesResponse, error)
}

NetworkingInterface defines the subset of the OCI compute API utilised by the CCM.

type RateLimiter

type RateLimiter struct {
	Reader flowcontrol.RateLimiter
	Writer flowcontrol.RateLimiter
}

RateLimiter reader and writer.

func NewRateLimiter

func NewRateLimiter(logger *zap.SugaredLogger, config *providercfg.RateLimiterConfig) RateLimiter

NewRateLimiter builds and returns a struct containing read and write rate limiters. Defaults are used where no (0) value is provided.

type VolumeAttachmentInterface

type VolumeAttachmentInterface interface {
	// FindVolumeAttachment searches for a volume attachment in either the state
	// ATTACHING or ATTACHED and returns the first volume attachment found.
	FindVolumeAttachment(ctx context.Context, compartmentID, volumeID string) (core.VolumeAttachment, error)

	// AttachVolume attaches a block storage volume to the specified instance.
	// See https://docs.us-phoenix-1.oraclecloud.com/api/#/en/iaas/20160918/VolumeAttachment/AttachVolume
	AttachVolume(ctx context.Context, instanceID, volumeID string) (core.VolumeAttachment, error)

	AttachParavirtualizedVolume(ctx context.Context, instanceID, volumeID string, isPvEncryptionInTransitEnabled bool) (core.VolumeAttachment, error)

	// WaitForVolumeAttached polls waiting for a OCI block volume to be in the
	// ATTACHED state.
	WaitForVolumeAttached(ctx context.Context, attachmentID string) (core.VolumeAttachment, error)

	// DetachVolume detaches a storage volume from the specified instance.
	// See: https://docs.us-phoenix-1.oraclecloud.com/api/#/en/iaas/20160918/Volume/DetachVolume
	DetachVolume(ctx context.Context, id string) error

	// WaitForVolumeDetached polls waiting for a OCI block volume to be in the
	// DETACHED state.
	WaitForVolumeDetached(ctx context.Context, attachmentID string) error

	FindActiveVolumeAttachment(ctx context.Context, compartmentID, volumeID string) (core.VolumeAttachment, error)
}

VolumeAttachmentInterface defines the interface to the OCI volume attachement API.

Jump to

Keyboard shortcuts

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