Skip to content

Commit f094c08

Browse files
authored
SQS Monitor should handle all kinds of InvalidInstanceID errors (#1035)
Fixes: #1034
1 parent 2a9f0e1 commit f094c08

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/monitor/sqsevent/sqs-monitor.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,28 @@ func (m SQSMonitor) getNodeInfo(instanceID string) (*NodeInfo, error) {
358358
},
359359
})
360360
if err != nil {
361+
// handle all kinds of InvalidInstanceID error events
362+
// - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html
363+
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID" {
364+
msg := fmt.Sprintf("Invalid instance id %s provided", instanceID)
365+
log.Warn().Msg(msg)
366+
return nil, skip{fmt.Errorf(msg)}
367+
}
361368
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotFound" {
362369
msg := fmt.Sprintf("No instance found with instance-id %s", instanceID)
363370
log.Warn().Msg(msg)
364371
return nil, skip{fmt.Errorf(msg)}
365372
}
373+
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.Malformed" {
374+
msg := fmt.Sprintf("Malformed instance-id %s", instanceID)
375+
log.Warn().Msg(msg)
376+
return nil, skip{fmt.Errorf(msg)}
377+
}
378+
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotLinkable" {
379+
msg := fmt.Sprintf("Instance-id %s not linkable", instanceID)
380+
log.Warn().Msg(msg)
381+
return nil, skip{fmt.Errorf(msg)}
382+
}
366383
return nil, err
367384
}
368385
if len(result.Reservations) == 0 || len(result.Reservations[0].Instances) == 0 {

0 commit comments

Comments
 (0)