Skip to content

Commit df6b375

Browse files
authored
AWS: perform disable src-dst check only if node has necessary IAM. Also introduce delay (#319)
between ec2 api calls, so that requests are not rejected due to API throttling Fixes: #313
1 parent 31402a5 commit df6b375

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/controllers/network_routes_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/aws/aws-sdk-go/aws"
18+
"github.com/aws/aws-sdk-go/aws/awserr"
1819
"github.com/aws/aws-sdk-go/aws/ec2metadata"
1920
"github.com/aws/aws-sdk-go/aws/session"
2021
"github.com/aws/aws-sdk-go/service/ec2"
@@ -904,10 +905,18 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
904905
},
905906
)
906907
if err != nil {
907-
glog.Errorf("Failed to disable source destination check due to: " + err.Error())
908+
awserr := err.(awserr.Error)
909+
if awserr.Code() == "UnauthorizedOperation" {
910+
glog.Errorf("Node does not have necessary IAM creds to modify instance attribute. So skipping disabling src-dst check.")
911+
return
912+
}
913+
glog.Errorf("Failed to disable source destination check due to: %v", err.Error())
908914
} else {
909915
glog.Infof("Disabled source destination check for the instance: " + instanceID)
910916
}
917+
918+
// to prevent EC2 rejecting API call due to API throttling give a delay between the calls
919+
time.Sleep(100 * time.Millisecond)
911920
}
912921
}
913922

0 commit comments

Comments
 (0)