diff --git a/pkg/monitor/sqsevent/asg-lifecycle-event.go b/pkg/monitor/sqsevent/asg-lifecycle-event.go index 87746161..f4a88598 100644 --- a/pkg/monitor/sqsevent/asg-lifecycle-event.go +++ b/pkg/monitor/sqsevent/asg-lifecycle-event.go @@ -109,13 +109,5 @@ func (m SQSMonitor) asgTerminationToInterruptionEvent(event EventBridgeEvent, me return nil } - if nodeName == "" { - log.Info().Msg("Node name is empty, assuming instance was already terminated, deleting queue message") - errs := m.deleteMessages([]*sqs.Message{message}) - if errs != nil { - log.Warn().Errs("errors", errs).Msg("There was an error deleting the messages") - } - } - return interruptionEvent, nil } diff --git a/pkg/monitor/sqsevent/sqs-monitor.go b/pkg/monitor/sqsevent/sqs-monitor.go index cbb4a472..470553cd 100644 --- a/pkg/monitor/sqsevent/sqs-monitor.go +++ b/pkg/monitor/sqsevent/sqs-monitor.go @@ -192,14 +192,15 @@ func (m SQSMonitor) retrieveNodeName(instanceID string) (string, error) { return "", err } if len(result.Reservations) == 0 || len(result.Reservations[0].Instances) == 0 { - return "", fmt.Errorf("No instance found with instance-id %s", instanceID) + log.Info().Msgf("No instance found with instance-id %s", instanceID) + return "", ErrNodeStateNotRunning } instance := result.Reservations[0].Instances[0] nodeName := *instance.PrivateDnsName log.Debug().Msgf("Got nodename from private ip %s", nodeName) instanceJSON, _ := json.MarshalIndent(*instance, " ", " ") - log.Debug().Msgf("Got nodename from ec2 describe call: %s", instanceJSON) + log.Debug().Msgf("Got instance data from ec2 describe call: %s", instanceJSON) if nodeName == "" { state := "unknown" diff --git a/pkg/monitor/sqsevent/sqs-monitor_test.go b/pkg/monitor/sqsevent/sqs-monitor_test.go index 3cd60aa2..7b439383 100644 --- a/pkg/monitor/sqsevent/sqs-monitor_test.go +++ b/pkg/monitor/sqsevent/sqs-monitor_test.go @@ -474,7 +474,7 @@ func TestMonitor_EC2NoInstances(t *testing.T) { } err = sqsMonitor.Monitor() - h.Nok(t, err) + h.Ok(t, err) select { case <-drainChan: