Skip to content

Commit

Permalink
SQS Monitor should handle all kinds of InvalidInstanceID errors (#1035)
Browse files Browse the repository at this point in the history
Fixes: #1034
  • Loading branch information
guessi authored Jul 31, 2024
1 parent 2a9f0e1 commit f094c08
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/monitor/sqsevent/sqs-monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,28 @@ func (m SQSMonitor) getNodeInfo(instanceID string) (*NodeInfo, error) {
},
})
if err != nil {
// handle all kinds of InvalidInstanceID error events
// - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID" {
msg := fmt.Sprintf("Invalid instance id %s provided", instanceID)
log.Warn().Msg(msg)
return nil, skip{fmt.Errorf(msg)}
}
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotFound" {
msg := fmt.Sprintf("No instance found with instance-id %s", instanceID)
log.Warn().Msg(msg)
return nil, skip{fmt.Errorf(msg)}
}
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.Malformed" {
msg := fmt.Sprintf("Malformed instance-id %s", instanceID)
log.Warn().Msg(msg)
return nil, skip{fmt.Errorf(msg)}
}
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotLinkable" {
msg := fmt.Sprintf("Instance-id %s not linkable", instanceID)
log.Warn().Msg(msg)
return nil, skip{fmt.Errorf(msg)}
}
return nil, err
}
if len(result.Reservations) == 0 || len(result.Reservations[0].Instances) == 0 {
Expand Down

0 comments on commit f094c08

Please sign in to comment.