utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlowStartInitialBatchSize = 1
)

Variables

This section is empty.

Functions

func AddFinalizer

func AddFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) error

func AggregateErrors

func AggregateErrors(errs []error) error

func BeforeReady

func BeforeReady(po *corev1.Pod) bool

func ContainsFinalizer

func ContainsFinalizer(obj client.Object, finalizer string) bool

func FormatTime

func FormatTime(originTime metav1.Time) metav1.Time

func FormatTimeNow

func FormatTimeNow() metav1.Time

func GetLabelAnnoPatchBytes

func GetLabelAnnoPatchBytes(oldLabels, newLabels, oldAnno, newAnno map[string]string) []byte

func GetPodCondition

func GetPodCondition(status *corev1.PodStatus, conditionType corev1.PodConditionType) (int, *corev1.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 []corev1.PodCondition, conditionType corev1.PodConditionType) (int, *corev1.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 corev1.PodStatus) *corev1.PodCondition

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

func GetPodScheduledCondition

func GetPodScheduledCondition(status corev1.PodStatus) *corev1.PodCondition

func GetProtectionFinalizers

func GetProtectionFinalizers(pod *corev1.Pod) []string

func IsExpectedFinalizerSatisfied

func IsExpectedFinalizerSatisfied(pod *corev1.Pod) (bool, map[string]string, error)

func IsPodPhaseTerminal

func IsPodPhaseTerminal(phase corev1.PodPhase) bool

IsPodPhaseTerminal returns true if the pod's phase is terminal.

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

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

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status corev1.PodStatus) bool

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

func IsPodScheduled

func IsPodScheduled(pod *corev1.Pod) bool

func IsPodScheduledConditionTrue

func IsPodScheduledConditionTrue(status corev1.PodStatus) bool

func IsPodServiceAvailable

func IsPodServiceAvailable(pod *corev1.Pod) bool

func IsPodTerminal

func IsPodTerminal(pod *corev1.Pod) bool

IsPodTerminal returns true if a pod is terminal, all containers are stopped and cannot ever regress.

func PodAvailableConditions

func PodAvailableConditions(pod *corev1.Pod) (*v1alpha1.PodAvailableConditions, error)

func RemoveFinalizer

func RemoveFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) error

func Selected

func Selected(selector *metav1.LabelSelector, lb map[string]string) bool

func SlowStartBatch

func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error) (int, error)

SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.

It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.

If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.

It returns the number of successful calls to the function.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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