collectors

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(l Lists) (Instances, Pods)

Combine merges all data sources and returns all in one structs for Pods and Instances.

func HasASGData

func HasASGData(i *Instance) bool

func HasEC2Data

func HasEC2Data(i *Instance) bool

func HasLifecycleMessage deprecated

func HasLifecycleMessage(i *Instance) bool

Deprecated: Should use filters instead.

func HasNodeData added in v2.1.0

func HasNodeData(i *Instance) bool

func HasSpotData

func HasSpotData(i *Instance) bool

func InstancesByEC2State

func InstancesByEC2State(i1, i2 *Instance) bool

func InstancesByID

func InstancesByID(i1, i2 *Instance) bool

InstancesByID defines the order based on the Instance ID.

func InstancesByLaunchTime

func InstancesByLaunchTime(i1, i2 *Instance) bool

InstancesByLaunchTime defines the order based on the instance start time.

func InstancesByTriggeredAt

func InstancesByTriggeredAt(i1, i2 *Instance) bool

InstancesByTriggeredAt defines the order based on the time of the ASG Shudown Lifecycle.

func LifecycleCompleted

func LifecycleCompleted(i *Instance) bool

func LifecycleDeleted

func LifecycleDeleted(i *Instance) bool

func PendingLifecycleCompletion deprecated

func PendingLifecycleCompletion(i *Instance) bool

Deprecated: Should use filters instead.

func PodCanDecrement

func PodCanDecrement(p *Pod) bool

func PodImmuneToEviction

func PodImmuneToEviction(p *Pod) bool

func PodNotImmuneToEviction added in v2.3.0

func PodNotImmuneToEviction(p *Pod) bool

func PodsByImmuneToEviction

func PodsByImmuneToEviction(p1, p2 *Pod) bool

func PodsByNeedsEviction

func PodsByNeedsEviction(p1, p2 *Pod) bool

Types

type Collectors

type Collectors struct {
	ASG  asg.Client
	EC2  ec2.Client
	Spot spot.Client
	Node node.Client
	Pod  pod.Client
}

func (Collectors) List

func (c Collectors) List(ctx context.Context) Lists

type Instance

type Instance struct {
	InstanceID string `logfield:"instance-id"`

	ASG  asg.Instance  `logfield:",squash"`
	EC2  ec2.Instance  `logfield:",squash"`
	Spot spot.Instance `logfield:",squash"`
	Node node.Node     `logfield:",squash"`

	Pods Pods `logfield:"-"`
}

Instance is the combined data from different sources.

func (*Instance) HasASGData

func (i *Instance) HasASGData() bool

func (*Instance) HasEC2Data

func (i *Instance) HasEC2Data() bool

func (*Instance) HasEC2State

func (i *Instance) HasEC2State(states ...string) bool

func (*Instance) HasLifecycleMessage deprecated

func (i *Instance) HasLifecycleMessage() bool

Deprecated: Should use filters instead.

func (*Instance) HasNodeData added in v2.1.0

func (i *Instance) HasNodeData() bool

func (*Instance) NodeName

func (i *Instance) NodeName() string

NodeName returns the NodeName which it tries to get from Kubernetes or EC2 data. Returns an empty string, if the NodeName could not been determinated.

func (*Instance) PendingLifecycleCompletion deprecated

func (i *Instance) PendingLifecycleCompletion() bool

Deprecated: Should use filters instead.

func (Instance) PodStats

func (instance Instance) PodStats() InstancePodStats

func (*Instance) WantsShutdown deprecated

func (i *Instance) WantsShutdown() bool

Deprecated: Should use filters instead.

type InstancePodStats

type InstancePodStats struct {
	Total            int
	ImmuneToEviction int
	CannotDecrement  int
	CanDecrement     int
}

type InstanceSelector

type InstanceSelector func(i *Instance) bool

Selector is a function type that defines if an instance should be selected.

func HasEC2State

func HasEC2State(states ...string) InstanceSelector

func HasSpotStatusCode

func HasSpotStatusCode(codes ...string) InstanceSelector

func HasTaint

func HasTaint(key string) InstanceSelector

func InstanceQuery

func InstanceQuery() InstanceSelector

InstanceQuery returns a dummy selector that selects all instances. It is used to make chaining selectors prettier while making sure the type is correct.

Without:

InstanceSelector(HasEC2Data).
    Select(HasASGData).
    Filter(LifecycleDeleted)

With:

InstanceQuery().
    Select(HasEC2Data).
    Select(HasASGData).
    Filter(LifecycleDeleted)

func LifecycleTriggeredOlderThan

func LifecycleTriggeredOlderThan(age time.Duration) InstanceSelector

func (InstanceSelector) Any

func (InstanceSelector) Filter

func (InstanceSelector) FilterByAllPods

func (is InstanceSelector) FilterByAllPods(ps PodSelector) InstanceSelector

func (InstanceSelector) Select

type Instances

type Instances []Instance

Instances is a collection of Instance types with some additional functions.

func (Instances) Get

func (instances Instances) Get(instanceID string) *Instance

func (Instances) Select

func (instances Instances) Select(selector InstanceSelector) Instances

Select returns a subset of the instances based on the selector. The subset only contains instances, that match the selector.

func (Instances) Sort

func (instances Instances) Sort(by InstancesBy) Instances

Sort returns a sorted list of instances based on the given sorter.

func (Instances) SortReverse

func (instances Instances) SortReverse(by InstancesBy) Instances

SortReverse returns a sorted list of instances based on the given sorter. The output is reversed.

type InstancesBy

type InstancesBy func(i1, i2 *Instance) bool

InstancesBy is a function type that defines the order and is used by Sort and SortReverse.

type Lists

type Lists struct {
	ASG   []asg.Instance
	EC2   []ec2.Instance
	Spot  []spot.Instance
	Nodes []node.Node
	Pods  []pod.Pod
}

type Pod

type Pod struct {
	Instance `logfield:",squash"`
	pod.Pod  `logfield:",squash"`
}

func (*Pod) NeedsEviction deprecated

func (p *Pod) NeedsEviction() bool

Deprecated: Should use filters instead.

type PodSelector

type PodSelector func(p *Pod) bool

Selector is a function type that defines if an instance should be selected and is used by Select and Filter.

func PodOnInstance added in v2.3.0

func PodOnInstance(instanceID string) PodSelector

func PodQuery

func PodQuery() PodSelector

PodQuery returns a dummy selector that selects all pods. It is used to make chaining selectors prettier while making sure the type is correct. See InstanceQuery for an example.

func (PodSelector) Filter

func (ps1 PodSelector) Filter(ps2 PodSelector) PodSelector

func (PodSelector) Select

func (ps1 PodSelector) Select(ps2 PodSelector) PodSelector

func (PodSelector) SelectByInstance

func (ps PodSelector) SelectByInstance(is InstanceSelector) PodSelector

type Pods

type Pods []Pod

func (Pods) Names

func (pods Pods) Names() []string

func (Pods) Select

func (pods Pods) Select(selector PodSelector) Pods

func (Pods) Sort

func (pods Pods) Sort(by PodsBy) Pods

Sort returns a sorted list of pods based on the given sorter.

type PodsBy

type PodsBy func(p1, p2 *Pod) bool

By is a function type that defines the order and is used by Sort and SortReverse.

Directories

Path Synopsis
aws
asg
Package asg provides an interface to ASG Lifecycle Hooks, that are delivered via SQS.
Package asg provides an interface to ASG Lifecycle Hooks, that are delivered via SQS.
ec2
Package ec2 provides an interface to EC2 instances, that are polled from the API.
Package ec2 provides an interface to EC2 instances, that are polled from the API.
spot
Package spot provides an interface to Spot requests, that are polled from the API.
Package spot provides an interface to Spot requests, that are polled from the API.
kube
pod

Jump to

Keyboard shortcuts

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