utils

package
v0.0.0-...-4a1a1e7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ControllerKindSS = apps.SchemeGroupVersion.WithKind("StatefulSet")
)

Functions

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodConditionFromList

func GetPodConditionFromList(conditions []v1.PodCondition, conditionType v1.PodConditionType) (int, *v1.PodCondition)

GetPodConditionFromList extracts the provided condition from the given list of condition and returns the index of the condition and the condition. Returns -1 and nil if the condition is not present.

func GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

GetPodReadyCondition extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func GetZdbForPod

func GetZdbForPod(c client.Client, logger logr.Logger, pod *v1.Pod) (*opsv1.ZoneDisruptionBudget, error)

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

IsPodReadyConditionTrue returns true if a pod is ready; false otherwise.

func IsRunningAndReady

func IsRunningAndReady(pod *v1.Pod) bool

func IsTerminating

func IsTerminating(pod *v1.Pod) bool

Types

type AlarmStateProvider

type AlarmStateProvider interface {
	AlarmState(ctx context.Context, alarmName string) (types.StateValue, error)
}

type CloudWatchAPI

type CloudWatchAPI interface {
	DescribeAlarms(ctx context.Context, params *cloudwatch.DescribeAlarmsInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.DescribeAlarmsOutput, error)
}

type CloudWatchAlarmStateProvider

type CloudWatchAlarmStateProvider struct {
	Client CloudWatchAPI
}

func (*CloudWatchAlarmStateProvider) AlarmState

func (p *CloudWatchAlarmStateProvider) AlarmState(ctx context.Context, alarmName string) (types.StateValue, error)

type ControllerAndScale

type ControllerAndScale struct {
	types.UID
	Scale int32
}

ControllerAndScale is used to return (controller, scale) pairs from the controller finder functions.

type Pair

type Pair struct {
	Key   string
	Value int32
}

type PairList

type PairList []Pair

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

func (p PairList) Less(i, j int) bool

func (PairList) Swap

func (p PairList) Swap(i, j int)

type PodControllerFinder

type PodControllerFinder func(client client.Client, controllerRef *metav1.OwnerReference, namespace string) (*ControllerAndScale, error)

PodControllerFinder is a function type that maps a pod to a list of controllers and their scale.

func Finders

func Finders() []PodControllerFinder

Only StatefulSets are supported for now!! TODO Implement finders of other controler types (e.g Deployment, ReplicaSet)

Jump to

Keyboard shortcuts

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