podutils

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnhealthy

func IsUnhealthy(_ context.Context, pod *v1.Pod) bool

IsUnhealthy checks if a pod has not been ready since at least 10 minutes/ This heuristic also detects infrastructure issues like not enough room to schedule pod. As false positives are less problematic than false negatives in our case, this is not a problem. if false positives were to be a frequent issue we could build a more specific heuristic by looking at the container statuses

func ListNames

func ListNames[T metav1.Object](objs []T) []string

ListNames takes any object list and returns a list of the object names. This can be used for logging or testing purposes.

func MustHaveControllerRevisionLabel

func MustHaveControllerRevisionLabel(ctx context.Context, pod *v1.Pod) bool

MustHaveControllerRevisionLabel checks if the pod is labeled with a controller revision hash and produces an error log if it is not.

func PodListToListOfPods

func PodListToListOfPods(list *v1.PodList) (pods []*v1.Pod)

PodListToListOfPods converts a v1.PodList coming from a pod LIST operation into a slice of pods.

Types

type FilterFunc

type FilterFunc func(ctx context.Context, pod *v1.Pod) bool

FilterFunc takes a pod and checks if it matches a specific criteria For example: "is the pod healthy?", "does the pod have this label?" It returns true if the pod meets the criteria

func BelongsControllerRevisionFilter

func BelongsControllerRevisionFilter(controllerRevision string) FilterFunc

BelongsControllerRevisionFilter returns a FilterFunc checking if the pod belong to a specific controller revision.

func Not

func Not(filterFunc FilterFunc) FilterFunc

Not takes a FilterFunc and builds the opposite FilterFunc.

type Filters

type Filters []FilterFunc

Filters is a list of FilterFunc.

func (Filters) Apply

func (f Filters) Apply(ctx context.Context, pods []*v1.Pod) []*v1.Pod

Apply filters a pod list with all Filters and return a list of the pods that matched against all Filters.

Jump to

Keyboard shortcuts

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