Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-up error message a bit #55

Merged
merged 3 commits into from Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions bouncer/asgset.go
Expand Up @@ -19,6 +19,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/pkg/errors"

"github.com/palantir/bouncer/aws"
Expand Down Expand Up @@ -54,7 +55,7 @@ func (a *ASGSet) GetImmutableInstances() []*Instance {
var instances []*Instance
for _, asg := range a.ASGs {
for _, inst := range asg.Instances {
if *inst.ASGInstance.LifecycleState == "Terminating" || *inst.ASGInstance.LifecycleState == "Pending" || *inst.ASGInstance.LifecycleState == "Terminating:Proceed" {
if *inst.ASGInstance.LifecycleState == autoscaling.LifecycleStateTerminating || *inst.ASGInstance.LifecycleState == autoscaling.LifecycleStatePending || *inst.ASGInstance.LifecycleState == autoscaling.LifecycleStateTerminatingProceed {
instances = append(instances, inst)
}
}
Expand Down Expand Up @@ -243,11 +244,21 @@ func (a *ASGSet) IsNewUnhealthy() bool {

newUnhealthy := a.GetUnhealthyNewInstances()
for _, inst := range newUnhealthy {
state := *inst.ASGInstance.LifecycleState
var msg string

switch state {
case autoscaling.LifecycleStateTerminating, autoscaling.LifecycleStateTerminatingProceed, autoscaling.LifecycleStateTerminatingWait:
msg = "Waiting for unhealthy new instance to get out of the way"
default:
msg = "Waiting for new instance to become healthy"
}

log.WithFields(log.Fields{
"ASG": *inst.AutoscalingGroup.AutoScalingGroupName,
"InstanceID": *inst.ASGInstance.InstanceId,
"State": *inst.ASGInstance.LifecycleState,
}).Info("Waiting for new instance to become healthy")
"State": state,
}).Info(msg)
isNewUnhealthy = true
}

Expand Down
10 changes: 3 additions & 7 deletions bouncer/runner.go
Expand Up @@ -21,6 +21,7 @@ import (
"time"

log "github.com/Sirupsen/logrus"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/pkg/errors"

"github.com/palantir/bouncer/aws"
Expand Down Expand Up @@ -56,11 +57,6 @@ const (

asgSeparator = ","
desiredCapSeparator = ":"

// The state instance is in while waiting for autoscaling:EC2_INSTANCE_LAUNCHING transition hook
pendingHookState = "Pending:Wait"
// The state instance is in while waiting for autoscaling:EC2_INSTANCE_TERMINATING transition hook
terminateHookState = "Terminating:Wait"
)

func retry(attempts int, sleep time.Duration, callback func() error) (err error) {
Expand Down Expand Up @@ -165,11 +161,11 @@ func (r *BaseRunner) KillInstance(inst *Instance) error {
}).Info("Picked instance to die next")
var hook string

if *inst.ASGInstance.LifecycleState == pendingHookState {
if *inst.ASGInstance.LifecycleState == autoscaling.LifecycleStatePendingWait {
hook = r.opts.PendingHook
}

if *inst.ASGInstance.LifecycleState == terminateHookState {
if *inst.ASGInstance.LifecycleState == autoscaling.LifecycleStateTerminatingWait {
hook = r.opts.TerminateHook
}

Expand Down