Преглед на файлове

fix case wehere we have no data

Chris Mague преди 7 години
родител
ревизия
74288f9244
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      lib/neoinfra/cloudwatch.rb

+ 5 - 0
lib/neoinfra/cloudwatch.rb

@@ -14,6 +14,7 @@ module NeoInfra
         region: region
       }
       cwstats = Fog::AWS::CloudWatch.new(conf)
+      begin
       cwstats.get_metric_statistics('Statistics' => ['Maximum'],
                                     'StartTime'  => DateTime.now - 7,
                                     'EndTime'    => DateTime.now,
@@ -24,6 +25,10 @@ module NeoInfra
                                       { 'Name' => 'BucketName', 'Value' => bucket },
                                       { 'Name' => 'StorageType', 'Value' => 'StandardStorage' }
                                     ]).data[:body]['GetMetricStatisticsResult']['Datapoints'].last['Maximum']
+      rescue
+        puts "Unable to get stats for #{bucket} returning -1"
+        return -1
+      end
     end
   end
 end