Skip to content

Commit

Permalink
Merge pull request #10 from kizkoh/output-retry-message
Browse files Browse the repository at this point in the history
Output AWS API retry count message
  • Loading branch information
taku-k authored Feb 13, 2018
2 parents cc8a943 + 8369242 commit 2b4f0e7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"context"
"errors"
"fmt"
"log"
"os"
"strings"
Expand Down Expand Up @@ -36,6 +37,9 @@ func (c *Ec2Client) getRouteTables(ctx context.Context, retry int) ([]*ec2.Route
req.HTTPRequest = req.HTTPRequest.WithContext(ctx)
var err error
for i := 0; i < retry; i++ {
if i > 0 {
fmt.Printf("Retry (%v/%v): describe route tables API", i, retry)
}
err = req.Send()
if err == nil {
break
Expand Down Expand Up @@ -79,6 +83,9 @@ func (c *Ec2Client) getRouteTableByKey(ctx context.Context, retry int, key strin
req.HTTPRequest = req.HTTPRequest.WithContext(ctx)
var err error
for i := 0; i < retry; i++ {
if i > 0 {
fmt.Printf("Retry (%v/%v): describe route tables API", i, retry)
}
err := req.Send()
if err == nil {
break
Expand All @@ -104,6 +111,9 @@ func (c *Ec2Client) replaceRoute(ctx context.Context, retry int, routeTableId, d
req.HTTPRequest = req.HTTPRequest.WithContext(ctx)
var err error
for i := 0; i < retry; i++ {
if i > 0 {
fmt.Printf("Retry (%v/%v): replace route API", i, retry)
}
err := req.Send()
if err == nil {
break
Expand Down Expand Up @@ -159,6 +169,9 @@ func (c *Ec2Client) getInstanceByKey(ctx context.Context, retry int, key string)
req, resp := c.ec2Svc.DescribeInstancesRequest(input)
req.HTTPRequest = req.HTTPRequest.WithContext(ctx)
for i := 0; i < retry; i++ {
if i > 0 {
fmt.Printf("Retry (%v/%v): describe instances API", i, retry)
}
err := req.Send()
if err == nil {
break
Expand Down Expand Up @@ -212,6 +225,9 @@ func (c *Ec2Client) getENINameById(ctx context.Context, retry int, ENIId string)
req.HTTPRequest = req.HTTPRequest.WithContext(ctx)
var err error
for i := 0; i < retry; i++ {
if i > 0 {
fmt.Printf("Retry (%v/%v): describe network interfaces API", i, retry)
}
err := req.Send()
if err == nil {
break
Expand Down

0 comments on commit 2b4f0e7

Please sign in to comment.