utils

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package utils features auxiliary functions for the Anthos DB Operator compliant resources.

Index

Constants

View Source
const (
	PlatformGCP       = "GCP"
	PlatformBareMetal = "BareMetal"
	PlatformMinikube  = "Minikube"
	PlatformKind      = "Kind"
	EnginePostgres    = "Postgres"
	EngineOracle      = "Oracle"
)

Variables

View Source
var (
	ErrPodUnschedulable      = errors.New("Pod is unschedulable")
	ErrNoResources           = errors.New("Insufficient resources to create Pod")
	NoResourcesMessageRegexp = "Insufficient memory|Insufficient cpu|enough free storage"
)

Functions

func DiskSpaceTotal

func DiskSpaceTotal(inst commonv1alpha1.Instance) (int64, error)

DiskSpaceTotal is a helper function to calculate the total amount of allocated space across all disks requested for an instance.

func FindDiskSize

func FindDiskSize(diskSpec *commonv1alpha1.DiskSpec, configSpec *commonv1alpha1.ConfigSpec, defaultDiskSpecs map[string]commonv1alpha1.DiskSpec, defaultDiskSize resource.Quantity) resource.Quantity

func FindPods

func FindPods(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) ([]corev1.Pod, error)

func FindStorageClassName

func FindStorageClassName(diskSpec *commonv1alpha1.DiskSpec, configSpec *commonv1alpha1.ConfigSpec, defaultPlatform string, engineType string) (string, error)

func FindVolumeSnapshotClassName

func FindVolumeSnapshotClassName(volumneSnapshotClass string, configSpec *commonv1alpha1.ConfigSpec, defaultPlatform string, engineType string) (string, error)

func GetPodCondition

func GetPodCondition(pod corev1.Pod, condType corev1.PodConditionType) *corev1.PodCondition

func LoadBalancerAnnotations

func LoadBalancerAnnotations(options *commonv1alpha1.DBLoadBalancerOptions) map[string]string

LoadBalancerAnnotations returns cloud provider specific annotations that must be attached to a LoadBalancer k8s service during creation

func LoadBalancerIpAddress

func LoadBalancerIpAddress(options *commonv1alpha1.DBLoadBalancerOptions) string

LoadBalancerIpAddress returns an IP address address for the Load Balancer if specified. Otherwise, the empty string is returned.

func LoadBalancerURL

func LoadBalancerURL(svc *corev1.Service, port int) string

LoadBalancerURL returns a URL that can be used to connect to a Load Balancer.

func SnapshotDisks

func SnapshotDisks(ctx context.Context, diskSpecs []commonv1alpha1.DiskSpec, owner metav1.Object, c client.Client, scheme *runtime.Scheme,
	getPvcSnapshotName func(commonv1alpha1.DiskSpec) (string, string, string), applyOpts []client.PatchOption) error

SnapshotDisks takes a snapshot of each disk as provided in diskSpecs. Ownership of the snapshots are granted to owner object. getPvcSnapshotName is a function that, given a DiskSpec, returns the full PVC name, snapshot name, and volumeSnapshotClassName of that disk. Taking snapshots here is best-effort only: it will returns errors even if only 1 disk failed the snapshot, and upon retry it will try to take snapshot of all disks again.

func VerifyPodsStatus

func VerifyPodsStatus(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) error

Check if POD initialiazation is stuck because of insufficient resources It will return error if Pod creation is stuck and needs manual intervention.

Types

This section is empty.

Jump to

Keyboard shortcuts

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