bouncer

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASG

type ASG struct {
	ASG        *at.AutoScalingGroup
	Instances  []*Instance
	DesiredASG *DesiredASG
}

ASG object holds a pointer to an ASG and its Instances

func NewASG

func NewASG(ctx context.Context, ac *aws.Clients, desASG *DesiredASG, force bool, startTime time.Time) (*ASG, error)

NewASG creates a new ASG object

type ASGSet

type ASGSet struct {
	ASGs []*ASG
}

ASGSet has a slice of ASG objects and some functions against them This object is recomputed every run of bouncer because it takes actual instance status into account

func (*ASGSet) GetActualBadCounts

func (a *ASGSet) GetActualBadCounts() []*ASG

GetActualBadCounts returns all ASGs whose desired counts don't match their actual counts

func (*ASGSet) GetBestOldInstance

func (a *ASGSet) GetBestOldInstance() *Instance

GetBestOldInstance returns the instance which is the best candidate to be bounced

func (*ASGSet) GetDivergedASGs

func (a *ASGSet) GetDivergedASGs() []*ASG

GetDivergedASGs returns all ASGs whose desired counts don't match what their desired counts should be

func (*ASGSet) GetHealthyNewInstances added in v0.16.0

func (a *ASGSet) GetHealthyNewInstances() []*Instance

GetHealthyNewInstances returns all instances which are on the latest launch configuration and are Healthy

func (*ASGSet) GetHealthyOldInstances added in v0.16.0

func (a *ASGSet) GetHealthyOldInstances() []*Instance

GetHealthyOldInstances returns all instances which are old and are Healthy

func (*ASGSet) GetImmutableInstances

func (a *ASGSet) GetImmutableInstances() []*Instance

GetImmutableInstances returns instances which are in autoscaling events that we can't manipulate by completing lifecycle actions

func (*ASGSet) GetNewInstances

func (a *ASGSet) GetNewInstances() []*Instance

GetNewInstances returns all instances which are on an outdated launch configuration

func (*ASGSet) GetOldInstances

func (a *ASGSet) GetOldInstances() []*Instance

GetOldInstances returns all instances which are on an outdated launch configuration

func (*ASGSet) GetTerminatingInstances

func (a *ASGSet) GetTerminatingInstances() []*Instance

GetTerminatingInstances returns all instances which are in the process of terminating

func (*ASGSet) GetUnHealthyOldInstances added in v0.16.0

func (a *ASGSet) GetUnHealthyOldInstances() []*Instance

GetUnHealthyOldInstances returns all instances which are old and are UnHealthy

func (*ASGSet) GetUnhealthyNewInstances

func (a *ASGSet) GetUnhealthyNewInstances() []*Instance

GetUnhealthyNewInstances returns all instances which are on the latest launch configuration but are unhealthy

func (*ASGSet) IsCountMismatch

func (a *ASGSet) IsCountMismatch() bool

IsCountMismatch prints all instances whose desired_capacity doesn't match running instances and returns true/false whether it found any

func (*ASGSet) IsImmutableAutoscalingEvent

func (a *ASGSet) IsImmutableAutoscalingEvent() bool

IsImmutableAutoscalingEvent prints all instances who are in a state we can't affect and returns true/false whether it found any

func (*ASGSet) IsNewInstance

func (a *ASGSet) IsNewInstance() bool

IsNewInstance prints all new instances and returns true/false whether it found any

func (*ASGSet) IsNewUnhealthy

func (a *ASGSet) IsNewUnhealthy() bool

IsNewUnhealthy prints all instances who are running latest LC but not yet healthy and returns true/false whether it found any

func (*ASGSet) IsOldInstance

func (a *ASGSet) IsOldInstance() bool

IsOldInstance prints all old instances and returns true/false whether it found any

func (*ASGSet) IsTerminating

func (a *ASGSet) IsTerminating() bool

IsTerminating prints all instances in the process of terminating and returns true/false whether it found any

func (*ASGSet) IsTransient added in v0.10.0

func (a *ASGSet) IsTransient() bool

IsTransient returns true if there are any ASGs in the set that have any instances in flight, or are waiting for their capacity to fill the desired

type BaseRunner

type BaseRunner struct {
	Opts *RunnerOpts
	// contains filtered or unexported fields
}

BaseRunner is the base struct for any runner

func NewBaseRunner

func NewBaseRunner(ctx context.Context, opts *RunnerOpts) (*BaseRunner, error)

NewBaseRunner instantiates a BaseRunner

func (*BaseRunner) KillInstance

func (r *BaseRunner) KillInstance(ctx context.Context, inst *Instance, decrement *bool) error

KillInstance calls TerminateInstanceInAutoscalingGroup, or, if the instance is stuck in a lifecycle hook, issues an ABANDON to it, killing it more forcefully

func (*BaseRunner) NewASGSet

func (r *BaseRunner) NewASGSet(ctx context.Context) (*ASGSet, error)

NewASGSet returns an ASGSet pointer

func (*BaseRunner) NewContext added in v0.14.0

func (r *BaseRunner) NewContext() (context.Context, context.CancelFunc)

NewContext generates a context with the ItemTimeout from the parent context given

func (*BaseRunner) SetDesiredCapacity

func (r *BaseRunner) SetDesiredCapacity(ctx context.Context, asg *ASG, desiredCapacity *int32) error

SetDesiredCapacity Updates desired capacity of ASG This function should only be used to increase desired cap, not decrease, since AWS will _always_ remove instances based on AZ before any other criteria http://docs.aws.amazon.com/autoscaling/latest/userguide/as-instance-termination.html

func (*BaseRunner) Sleep

func (r *BaseRunner) Sleep(ctx context.Context)

Sleep makes us sleep for the constant time - call this when waiting for an AWS change

type DesiredASG

type DesiredASG struct {
	AsgName         string
	DesiredCapacity int32
	// PreTerminateCmd is the external process that needs to be run before terminating an instance in this ASG
	PreTerminateCmd *string
}

DesiredASG contains pieces of the ASG as they _should_ be, but at any given time, since we twiddle the desired capacity, may not _actually_ be.

func ExtractDesiredASG added in v0.16.0

func ExtractDesiredASG(asgItem string, defaultDesired *int32, preTerminateCmd *string) (*DesiredASG, error)

ExtractDesiredASG takes in a separator-separated string of asgname and desired capacity, and returns a DesiredASG pointer

type Instance

type Instance struct {
	EC2Instance      *et.Instance
	ASGInstance      *at.Instance
	AutoscalingGroup *at.AutoScalingGroup
	IsOld            bool
	IsHealthy        bool
	PreTerminateCmd  *string
}

Instance tracks the AWS representations of an EC2 instance as well as the metadata we care about it

func NewInstance

func NewInstance(ctx context.Context, ac *aws.Clients, asg *at.AutoScalingGroup, asgInst at.Instance, force bool, startTime time.Time, preTerminateCmd *string) (*Instance, error)

NewInstance returns a new bouncer.Instance object

type RunnerOpts

type RunnerOpts struct {
	Noop            bool
	Force           bool
	Fast            bool
	BatchSize       *int32
	AsgString       string
	CommandString   string
	DefaultCapacity *int32
	TerminateHook   string
	PendingHook     string
	ItemTimeout     time.Duration
}

RunnerOpts is user-supplied options to any flavor of runner

Jump to

Keyboard shortcuts

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