cloud

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultVolumeSize represents the default size used
	// this is the minimum FSx for Lustre FS size
	DefaultVolumeSize = 1200

	// PollCheckInterval specifies the interval to check if filesystem is ready;
	// needs to be shorter than the provisioner timeout
	PollCheckInterval = 30 * time.Second
	// PollCheckTimeout specifies the time limit for polling DescribeFileSystems
	// for a completed create/update operation. FSx for Lustre filesystem
	// creation time is around 5 minutes, and update time varies depending on
	// target file system values
	PollCheckTimeout = 10 * time.Minute
)
View Source
const (
	// VolumeNameTagKey is the key value that refers to the volume's name.
	VolumeNameTagKey = "CSIVolumeName"
)

Tags

Variables

View Source
var (
	// ErrMultiDisks is an error that is returned when multiple
	// disks are found with the same volume name.
	ErrMultiFileSystems = errors.New("Multiple filesystems with same ID")

	// ErrFsExistsDiffSize is an error that is returned if a filesystem
	// exists with a given ID, but a different capacity is requested.
	ErrFsExistsDiffSize = errors.New("There is already a disk with same ID and different size")

	// ErrNotFound is returned when a resource is not found.
	ErrNotFound = errors.New("Resource was not found")
)
View Source
var DefaultEC2MetadataClient = func() (EC2Metadata, error) {
	sess := session.Must(session.NewSession(&aws.Config{}))
	svc := ec2metadata.New(sess)
	return svc, nil
}
View Source
var DefaultKubernetesAPIClient = func() (kubernetes.Interface, error) {

	config, err := rest.InClusterConfig()
	if err != nil {
		return nil, err
	}

	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		return nil, err
	}
	return clientset, nil
}

Functions

This section is empty.

Types

type Cloud

type Cloud interface {
	CreateFileSystem(ctx context.Context, volumeName string, fileSystemOptions *FileSystemOptions) (fs *FileSystem, err error)
	ResizeFileSystem(ctx context.Context, fileSystemId string, newSizeGiB int64) (int64, error)
	DeleteFileSystem(ctx context.Context, fileSystemId string) (err error)
	DescribeFileSystem(ctx context.Context, fileSystemId string) (fs *FileSystem, err error)
	WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error
	WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error
}

func NewCloud

func NewCloud(region string) (Cloud, error)

NewCloud returns a new instance of AWS cloud It panics if session is invalid

type EC2Metadata

type EC2Metadata interface {
	Available() bool
	// ec2 instance metadata endpoints: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
	GetMetadata(string) (string, error)
	GetInstanceIdentityDocument() (ec2metadata.EC2InstanceIdentityDocument, error)
}

type EC2MetadataClient added in v0.10.0

type EC2MetadataClient func() (EC2Metadata, error)

type FSx

type FSx interface {
	CreateFileSystemWithContext(aws.Context, *fsx.CreateFileSystemInput, ...request.Option) (*fsx.CreateFileSystemOutput, error)
	UpdateFileSystemWithContext(aws.Context, *fsx.UpdateFileSystemInput, ...request.Option) (*fsx.UpdateFileSystemOutput, error)
	DeleteFileSystemWithContext(aws.Context, *fsx.DeleteFileSystemInput, ...request.Option) (*fsx.DeleteFileSystemOutput, error)
	DescribeFileSystemsWithContext(aws.Context, *fsx.DescribeFileSystemsInput, ...request.Option) (*fsx.DescribeFileSystemsOutput, error)
}

FSx abstracts FSx client to facilitate its mocking. See https://docs.aws.amazon.com/sdk-for-go/api/service/fsx/ for details

type FakeCloudProvider

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

func NewFakeCloudProvider

func NewFakeCloudProvider() *FakeCloudProvider

func (*FakeCloudProvider) CreateFileSystem

func (c *FakeCloudProvider) CreateFileSystem(ctx context.Context, volumeName string, fileSystemOptions *FileSystemOptions) (fs *FileSystem, err error)

func (*FakeCloudProvider) DeleteFileSystem

func (c *FakeCloudProvider) DeleteFileSystem(ctx context.Context, volumeID string) (err error)

func (*FakeCloudProvider) DescribeFileSystem

func (c *FakeCloudProvider) DescribeFileSystem(ctx context.Context, volumeID string) (fs *FileSystem, err error)

func (*FakeCloudProvider) GetMetadata

func (c *FakeCloudProvider) GetMetadata() MetadataService

func (*FakeCloudProvider) ResizeFileSystem

func (c *FakeCloudProvider) ResizeFileSystem(ctx context.Context, volumeName string, newSizeGiB int64) (int64, error)

func (*FakeCloudProvider) WaitForFileSystemAvailable

func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error

func (*FakeCloudProvider) WaitForFileSystemResize

func (c *FakeCloudProvider) WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error

type FileSystem

type FileSystem struct {
	FileSystemId             string
	CapacityGiB              int64
	DnsName                  string
	MountName                string
	StorageType              string
	DeploymentType           string
	PerUnitStorageThroughput int64
}

FileSystem represents a FSx for Lustre filesystem

type FileSystemOptions

type FileSystemOptions struct {
	CapacityGiB                   int64
	SubnetId                      string
	SecurityGroupIds              []string
	AutoImportPolicy              string
	S3ImportPath                  string
	S3ExportPath                  string
	DeploymentType                string
	KmsKeyId                      string
	PerUnitStorageThroughput      int64
	StorageType                   string
	DriveCacheType                string
	DailyAutomaticBackupStartTime string
	AutomaticBackupRetentionDays  int64
	CopyTagsToBackups             bool
	DataCompressionType           string
	WeeklyMaintenanceStartTime    string
	FileSystemTypeVersion         string
	ExtraTags                     []string
}

FileSystemOptions represents the options to create FSx for Lustre filesystem

type KubernetesAPIClient added in v0.10.0

type KubernetesAPIClient func() (kubernetes.Interface, error)

type Metadata added in v0.10.0

type Metadata struct {
	InstanceID       string
	InstanceType     string
	Region           string
	AvailabilityZone string
}

func EC2MetadataInstanceInfo added in v0.10.0

func EC2MetadataInstanceInfo(svc EC2Metadata, regionFromSession string) (*Metadata, error)

func KubernetesAPIInstanceInfo added in v0.10.0

func KubernetesAPIInstanceInfo(clientset kubernetes.Interface) (*Metadata, error)

func (*Metadata) GetAvailabilityZone added in v0.10.0

func (m *Metadata) GetAvailabilityZone() string

GetAvailabilityZone returns the Availability Zone which the instance is in.

func (*Metadata) GetInstanceID added in v0.10.0

func (m *Metadata) GetInstanceID() string

GetInstanceID returns the instance identification.

func (*Metadata) GetInstanceType added in v0.10.0

func (m *Metadata) GetInstanceType() string

GetInstanceType returns the instance type.

func (*Metadata) GetRegion added in v0.10.0

func (m *Metadata) GetRegion() string

GetRegion returns the Region Zone which the instance is in.

type MetadataService

type MetadataService interface {
	GetInstanceID() string
	GetInstanceType() string
	GetRegion() string
	GetAvailabilityZone() string
}

MetadataService represents AWS metadata service.

func NewMetadataService

func NewMetadataService(ec2MetadataClient EC2MetadataClient, k8sAPIClient KubernetesAPIClient, region string) (MetadataService, error)

NewMetadataService returns a new MetadataServiceImplementation.

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