Skip to content

Commit 0315694

Browse files
committed
return non zero code for throttling exceptions even if no new resources are found
1 parent 412e4d0 commit 0315694

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

cmd/nuke.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ func (n *Nuke) Run() error {
6363
return err
6464
}
6565

66+
if n.items.Count(ItemStateFailed) > 0 && n.items.Count(ItemStateNew) == 0 {
67+
for _, item := range n.items {
68+
if item.State != ItemStateFailed {
69+
continue
70+
}
71+
logrus.Error(fmt.Sprintf("%s. %s.", item.Type, item.Reason))
72+
}
73+
return fmt.Errorf("failed")
74+
}
75+
6676
if n.items.Count(ItemStateNew) == 0 {
6777
fmt.Println("No resource to delete.")
6878
return nil
@@ -249,9 +259,9 @@ func (n *Nuke) HandleQueue() {
249259
n.HandleRemove(item)
250260
item.Print()
251261
case ItemStateFailed:
252-
// item.Resource will be nil if an exception was thrown while retrieving the resourceType's
253-
// items (I.E resourceTypes lister()), however we still pass down the reason and state so we
254-
// aren't ignoring these exceptions.
262+
// item.Resource will be nil if an exception was thrown while retrieving cloudControl
263+
// resourceType's items (I.E resourceTypes lister()), however we still pass down the
264+
// reason and state so we aren't ignoring these exceptions.
255265
if item.Resource != nil {
256266
n.HandleRemove(item)
257267
n.HandleWait(item, listCache)

cmd/scan.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ func (s *scanner) list(region *Region, resourceType string) {
7373
return
7474
}
7575

76-
// check for this error "ThrottlingException: Rate exceeded"
77-
// TODO: if there is a throttling exception call lister(sess) again 3 times with exponential backoff.
78-
// or maybe try recursion and call s.list(region, resourceType)
7976
awsErr, ok := err.(awserr.Error)
8077
if ok && awsErr.Code() == "ThrottlingException" {
8178
s.items <- &Item{
@@ -85,6 +82,8 @@ func (s *scanner) list(region *Region, resourceType string) {
8582
Reason: err.Error(),
8683
Type: resourceType,
8784
}
85+
dump := util.Indent(fmt.Sprintf("%v", err), " ")
86+
log.Errorf("Listing %s failed:\n%s", resourceType, dump)
8887
return
8988
}
9089

0 commit comments

Comments
 (0)