Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pkg/monitor/sqsevent/asg-lifecycle-event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 3 additions & 2 deletions pkg/monitor/sqsevent/sqs-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/monitor/sqsevent/sqs-monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func TestMonitor_EC2NoInstances(t *testing.T) {
}

err = sqsMonitor.Monitor()
h.Nok(t, err)
h.Ok(t, err)

select {
case <-drainChan:
Expand Down