grempe/amazon-ec2 — Issue #65: cloudwatch errors are not recognised by aws_error?
Author: benclifford
Created: 2012-02-08 12:49:22+00:00
State: open

This is against amazon-ec2-0.9.17 - I haven't tried with the latest git code, but from looking at the source, I think this will still be a problem.

I noticed that the error format that I'm getting from cloudwatch appears to be different than the format that AWS.rb aws_error? expects. Here's the error report that I was getting from cloudwatch.

This error was giving me the below stack track, presumably because the XML format is different to that expected, rather than passing on the error text. I hacked my version of the amazon-ec2 code to dump the whole XML document when it gets an HTTPBadRequest, which is where the below comes from.

HTTP bad request. response.body is: (AWS::Error)

Sender
InvalidParameterCombination
You have requested up to 4,005 datapoints, which exceeds the limit of 1,440. You may reduce the datapoints requested by increasing Period, or decreasing the time range.

a01a9251-5251-11e1-9d02-d1039a5448f0

from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:300:in `make_request'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:274:in `make_request'
from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:324:in `response_generator'
from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS/Cloudwatch/monitoring.rb:86:in `get_metric_statistics'
from ruby-mrtg-cloudwatch/ruby-mrtg-cloudwatch3:41:in `probe'
from ruby-mrtg-cloudwatch/ruby-mrtg-cloudwatch3:85

The previous error I was getting before I hacked in that dump is this, which was unenlightening.

/home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:348:in `aws_error?': undefined method `elements' for nil:NilClass (NoMethodError)
from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:300:in `make_request'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
from /home/mrtg/.gem/ruby/1.8/gems/amazon-ec2-0.9.17/lib/AWS.rb:274:in `make_request'