GithubHelp home page GithubHelp logo

right_aws's Introduction

= RightScale Amazon Web Services Ruby Gems

Published by RightScale, Inc. under the MIT License.
For information about RightScale, see http://www.rightscale.com

== THE GEM IS NO LONGER MAINTAINED

We recommend you use https://github.com/rightscale/right_aws_api instead.

== DESCRIPTION:

The RightScale AWS gems have been designed to provide a robust, fast, and secure interface to Amazon EC2, EBS, S3, SQS, SDB, and CloudFront. 
These gems have been used in production by RightScale since late 2006 and are being maintained to track enhancements made by Amazon. 
The RightScale AWS gems comprise:

- RightAws::Ec2 -- interface to Amazon EC2 (Elastic Compute Cloud), VPC (Virtual Private Cloud) and the associated EBS (Elastic Block Store)
- RightAws::S3 and RightAws::S3Interface -- interface to Amazon S3 (Simple Storage Service)
- RightAws::Sqs and RightAws::SqsInterface -- interface to first-generation Amazon SQS (Simple Queue Service)
- RightAws::SqsGen2 and RightAws::SqsGen2Interface -- interface to second-generation Amazon SQS (Simple Queue Service)
- RightAws::SdbInterface and RightAws::ActiveSdb -- interface to Amazon SDB (SimpleDB)
- RightAws::AcfInterface -- interface to Amazon CloudFront, a content distribution service
- RightAws::AsInterface  -- interface to Amazon Auto Scaling
- RightAws::AcwInterface -- interface to Amazon Cloud Watch
- RightAws::ElbInterface -- interface to Amazon Elastic Load Balancer
- RightAws::RdsInterface -- interface to Amazon RDS instances

== FEATURES:

- Full programmmatic access to EC2, EBS, S3, SQS, SDB, CloudFront, AS, ACW, ELB and RDS.
- Complete error handling: all operations check for errors and report complete
  error information by raising an AwsError.
- Persistent HTTP connections with robust network-level retry layer using
  RightHttpConnection).  This includes socket timeouts and retries.
- Robust HTTP-level retry layer.  Certain (user-adjustable) HTTP errors returned
  by Amazon's services are classified as temporary errors.
  These errors are automaticallly retried using exponentially increasing intervals.
  The number of retries is user-configurable.
- Fast REXML-based parsing of responses (as fast as a pure Ruby solution allows).
- Uses libxml (if available) for faster response parsing. 
- Support for large S3 list operations.  Buckets and key subfolders containing
  many (> 1000) keys are listed in entirety.  Operations based on list (like
  bucket clear) work on arbitrary numbers of keys.
- Support for streaming GETs from S3, and streaming PUTs to S3 if the data source is a file.
- Support for single-threaded usage, multithreaded usage, as well as usage with multiple
  AWS accounts.
- Support for both first- and second-generation SQS (API versions 2007-05-01
  and 2008-01-01).  These versions of SQS are not compatible.
- Support for signature versions 0 and 1 on SQS, SDB, and EC2.
- Interoperability with any cloud running Eucalyptus (http://eucalyptus.cs.ucsb.edu)
- Test suite (requires AWS account to do "live" testing).

== THREADING:

All RightScale AWS interfaces offer two threading options:
1. Use a single persistent HTTP connection per process.
2. Use a persistent HTTP connection per Ruby thread.
 
Either way, it doesn't matter how many (for example) RightAws::S3 objects you create,
they all use the same per-program or per-thread
connection. The purpose of sharing the connection is to keep a single
persistent HTTP connection open to avoid paying connection
overhead on every request. However, if you have multiple concurrent
threads, you may want or need an HTTP connection per thread to enable
concurrent requests to AWS. The way this plays out in practice is:
1. If you have a non-multithreaded Ruby program, use the non-multithreaded setting.
2. If you have a multi-threaded Ruby program, use the multithreaded setting to enable
   concurrent requests to S3 (or SQS, or SDB, or EC2).
3. For running under Mongrel/Rails, use the non-multithreaded setting even though
   mongrel is multithreaded.  This is because only one Rails handler is invoked at
   time (i.e. it acts like a single-threaded program)

Note that due to limitations in the I/O of the Ruby interpreter you
may not get the degree of parallelism you may expect with the multi-threaded setting.

== GETTING STARTED:

* For EC2 read RightAws::Ec2 and consult the Amazon EC2 API documentation at
  http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=87
* For S3 read RightAws::S3 and consult the Amazon S3 API documentation at
  http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=48
* For first generation SQS read RightAws::Sqs and consult the Amazon SQS API documentation at
  http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=31
* For second generation SQS read RightAws::SqsGen2, RightAws::SqsGen2Interface, and consult the Amazon SQS API documentation at
  http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1214&categoryID=31 

  Amazon's Migration Guide for moving from first to second generation SQS is
  avalable at:
  http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1148
* For SDB read RightAws::SdbInterface, RightAws::ActiveSdb, and consult the Amazon SDB API documentation at
  http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=141
* For CloudFront (ACF) read RightAws::AcfInterface and consult the Amazon CloudFront API documentation at 
  http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=213

== KNOWN ISSUES:

- 7/08: A user has reported that uploads of large files on Windows may be broken on some
  Win platforms due to a buggy File.lstat.size.  Use the following monkey-patch at your own risk, 
  as it has been proven to break Rails 2.0 on Windows:

    require 'win32/file'
    class File
      def lstat
        self.stat
      end
    end


- Attempting to use the Gibberish plugin (used by the Beast forum app) 
  will break right_aws as well as lots of other code.  Gibberish
  changes the semantics of core Ruby (specifically, the String class) and thus presents a reliability
  problem for most Ruby programs.

- 2/11/08: If you use RightAws in conjunction with attachment_fu, the
  right_aws gem must be included (using the require statement) AFTER
  attachment_fu.  If right_aws is loaded before attachment_fu, you'll
  encounter errors similar to:

  s3.amazonaws.com temporarily unavailable: (wrong number of arguments (5 for 4))

  or

  'incompatible Net::HTTP monkey-patch'

  This is due to a conflict between the right_http_connection gem and another
  gem required by attachment_fu.

- 8/07: Amazon has changed the semantics of the SQS service.  A
  new queue may not be created within 60 seconds of the destruction of any
  older queue with the same name.  Certain methods of RightAws::Sqs and
  RightAws::SqsInterface will fail with the message:
  "AWS.SimpleQueueService.QueueDeletedRecently: You must wait 60 seconds after deleting a queue before you can create another with the same name."
  
== REQUIREMENTS:

RightAws requires REXML and the right_http_connection gem.
If libxml and its Ruby bindings (distributed in the libxml-ruby gem) are
present, RightAws can be configured to use them:
  RightAws::RightAWSParser.xml_lib = 'libxml'
Any error with the libxml installation will result in RightAws failing-safe to
REXML parsing.

== INSTALL:

sudo gem install right_aws

== LICENSE:

Copyright (c) 2007-2013 RightScale, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

right_aws's People

Contributors

aboisvert avatar ae9rb avatar careo avatar cleicar avatar dominicm avatar dvrensk avatar euge avatar findchris avatar jakedouglas avatar jashkenas avatar jschneiderhan avatar kevmoo avatar klochner avatar ktheory avatar martinos avatar mauricio avatar mirakui avatar pieter avatar rbroemeling avatar rgeyer avatar rnash-rs avatar rubysolo avatar seanxiesx avatar sergeyenin avatar sergyenko avatar soleun avatar trbryan avatar tve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

right_aws's Issues

Where is gem version 1.11.0?

On December 13th, RightAws::VERSION was bumped to 1.11.0. Are there any plans to release a gem of that version soon?

I'm building a gem that depends on right_aws and for the next version needs functionality that exists in 1.11. I'd rather depend on right_aws than on a copy.

regression in right_ec2_ebs.rb

This was regressed in 2.0 version of a year ago.
The earlier 1.x version had a method
describe_snapshots(list=[],owner=nil,restorable_by=nil,tags=[])
this was regressed by removal of the owner=nil,restorable_by=nil parameters. This meant a loss of functionality. Could not list snapshots by owner.

SignatureDoesNotMatch error due to wrong request signature being submitted

Sometimes when I try to access an S3 bucket, I get a SignatureDoesNotMatch error. I added some logging to the S3Interface#generate_rest_request method to see what was going on. Here is the log, edited for clarity:

I, [2010-06-01T08:40:12.897096 #18502]  INFO -- : Signed string: GET\n\n\nTue, 01 Jun 2010 15:40:12 GMT\n/com.talentspring.attachments/
I, [2010-06-01T08:40:12.897206 #18502]  INFO -- : Signature: StRFAW/7qxD8z2e5847fzTOu88w=
I, [2010-06-01T08:40:12.929960 #18502]  INFO -- : Closing HTTPS connection to s3.amazonaws.com:443
I, [2010-06-01T08:40:12.931784 #18502]  INFO -- : Opening new HTTPS connection to com.talentspring.attachments.s3.amazonaws.com:443
I, [2010-06-01T08:40:12.932062 #18502]  INFO -- : Signed string: GET\n\n\nTue, 01 Jun 2010 15:40:12 GMT\n/
I, [2010-06-01T08:40:12.932926 #18502]  INFO -- : Signature: cpeR9+WCyjbRs+6PUyqHXZl0O1w=
I, [2010-06-01T08:40:12.934483 #18502]  INFO -- : Opening new HTTPS connection to s3.amazonaws.com:443

GET /?prefix=ts%2FEvent%2F57359%2Fsnapshot HTTP/1.1
Host: s3.amazonaws.com
User-Agent: 
Accept: */*
Connection: close
Authorization: AWS 1ATYZYK25V9A292840R2:StRFAW/7qxD8z2e5847fzTOu88w=
Content-Type: 
Date: Tue, 01 Jun 2010 15:40:12 GMT

HTTP/1.X 403 Forbidden
X-Amz-Id-2: aNHZVshi4dgk8m9PIhin4yqRPUsLGUAXyv7fwj3iTkmNP/p6s5b5ob2kdHfmgVaO
Connection: close
Content-Type: application/xml
Server: AmazonS3
Date: Tue, 01 Jun 2010 15:40:12 GMT
X-Amz-Request-Id: 32D0CFE56BF4EA55
Transfer-Encoding: chunked

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
  <StringToSignBytes>47 45 54 0a 0a 0a 54 75 65 2c 20 30 31 20 4a 75 6e 20 32 30 31 30 20 31 35 3a 34 30 3a 31 32 20 47 4d 54 0a 2f</StringToSignBytes>
  <RequestId>32D0CFE56BF4EA55</RequestId>
  <HostId>aNHZVshi4dgk8m9PIhin4yqRPUsLGUAXyv7fwj3iTkmNP/p6s5b5ob2kdHfmgVaO</HostId>
  <SignatureProvided>StRFAW/7qxD8z2e5847fzTOu88w=</SignatureProvided>
  <StringToSign>GET\n\n\nTue, 01 Jun 2010 15:40:12 GMT\n/</StringToSign>
  <AWSAccessKeyId>1ATYZYK25V9A292840R2</AWSAccessKeyId>
</Error>

For some reason RightAWS is signing two different requests, and then submitting one of the requests with the signature for the other one. Any idea why this is happening? Is this a threading issue?

LibXML and redirection bug

...
[2009-04-28 19:56:06] [Ec2ImageReplicationWorker] : Request was: /Ubuntu8.04_i386_V4_3_5.manifest.xml
[2009-04-28 19:56:06] [Ec2ImageReplicationWorker] : Response was: 307 -- Temporary Redirect --
[2009-04-28 19:56:06] [Ec2ImageReplicationWorker] : Error (4): TypeError:wrong argument type nil (expected String). Next attempt in 3 seconds...
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : ##### RightAws::S3Interface redirect requested: 307 Temporary Redirect #####
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : ##### New location: https://kd-eu.s3-external-3.amazonaws.com/?prefix=Ubuntu8.04_i386_V4_3_5.manifest.xml #####
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : ##### Retry #1 is being performed due to a redirect. ####
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : Closing HTTPS connection to kd-eu.s3.amazonaws.com:443
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : Opening new HTTPS connection to kd-eu.s3-external-3.amazonaws.com:443
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : Closing HTTPS connection to kd-eu.s3-external-3.amazonaws.com:443
[2009-04-28 19:56:09] [Ec2ImageReplicationWorker] : Opening new HTTPS connection to kd-eu.s3.amazonaws.com:443
[2009-04-28 19:56:10] [Ec2ImageReplicationWorker] : #
/home/rails/right_gems/current/right_aws/lib/awsbase/right_awsbase.rb:791:in string='/home/rails/right_gems/current/right_aws/lib/awsbase/right_awsbase.rb:791:inparse'/home/rails/right_gems/current/right_aws/lib/awsbase/right_awsbase.rb:612:in check'/usr/lib/ruby/1.8/benchmark.rb:293:inmeasure'/home/rails/right_gems/current/right_gogrid/lib/benchmark_fix.rb:30:in add!'/home/rails/right_gems/current/right_aws/lib/awsbase/right_awsbase.rb:610:incheck'/home/rails/right_gems/current/right_aws/lib/awsbase/right_awsbase.rb:404:in request_info_impl'/home/rails/right_gems/current/right_aws/lib/s3/right_s3_interface.rb:180:inrequest_info'/home/rails/right_gems/current/right_aws/lib/s3/right_s3_interface.rb:613:in head'/home/rails/right_gems/current/right_aws/lib/s3/right_s3.rb:587:inhead'/home/rails/right_gems/current/right_aws/lib/s3/right_s3.rb:571:in refresh'./lib/workers/ec2_image_replication_worker.rb:100:indo_work'./lib/workers/ec2_image_replication_worker.rb:160:in retriable_s3_call'./lib/workers/ec2_image_replication_worker.rb:99:indo_work'/home/rails/rightscale/releases/20090422043040/lib/awsd_logger.rb:173:in each_with_index'./lib/workers/ec2_image_replication_worker.rb:73:ineach'./lib/workers/ec2_image_replication_worker.rb:73:in each_with_index'./lib/workers/ec2_image_replication_worker.rb:73:indo_work'./script/daemon/../../lib/daemon/workers_daemon.rb:200:in do_work'./script/daemon/../../lib/daemon/workers_daemon.rb:168:inloop'./script/daemon/../../lib/daemon/workers_daemon.rb:168:in do_work'./script/daemon/../../lib/daemon/workers_daemon.rb:57:inexecute'./script/daemon/../../lib/daemon/daemon.rb:410:in execute_worker'./script/daemon/../../lib/daemon/daemon.rb:346:instart_daemon'./script/daemon/../../lib/daemon/daemon.rb:344:in fork'./script/daemon/../../lib/daemon/daemon.rb:344:instart_daemon'./script/daemon/../../lib/daemon/daemon.rb:343:in times'./script/daemon/../../lib/daemon/daemon.rb:343:instart_daemon'./script/daemon/../../lib/daemon/daemon.rb:110:in daemonize'./script/daemon/action.rb:61/home/rails/rightscale/current/script/daemon/restart:27:inrequire'/home/rails/rightscale/current/script/daemon/restart:27.join('
')}
[2009-04-28 19:56:10] [Ec2ImageReplicationWorker] : Request was: /Ubuntu8.04_i386_V4_3_5.manifest.xml
[2009-04-28 19:56:10] [Ec2ImageReplicationWorker] : Response was: 307 -- Temporary Redirect --
[2009-04-28 19:56:10] [Ec2ImageReplicationWorker] : Exception: wrong argument type nil (expected String)

regression in right_ec2_rbs

in 2.0 it was
describe_snapshots(list=[],owner=nil,restorable_by=nil)
now in 2.1 it is:
describe_snapshots(*list_and_options)
Now i appreciate that you can use filters for the owner and restorable by but

  1. This will break existing code
  2. For eucalyptus that doesn't support filters yet so the functionality is lost.

Between versions you really need to keep the method signatures the same or extend them rather than breaking them....hope this is not too harsh...... but it would reduce folks cloning the code. Also releasing the ruby gem once a year is too slow. need to release at least every 6 months. 3 months would be even better.....

Neill

AcwInterface returns malformed token error

If I call:
acw = RightAws::AcwInterface.new(key_goes_here, secret_goes_here)
stats = acw.list_metrics

I get:

400 Bad Request
http://monitoring.amazonaws.com/doc/2009-05-15/">

Sender
DelegationFailure
Malformed token

002b8b87-48bc-11e0-bc36-0542cab5ae1c

This is also the case for AWS' javascript scratchpad (their demo doesn't work).
However, if you use the command line tool "mon-list-metrics", it gives you a token, which you can then use to get access to the metrics via right_aws & the javascript scratchpad.

According to https://forums.aws.amazon.com/thread.jspa?threadID=42887&tstart=0#167316, users of the Java API were noticing the issue too.
This is clearly an AWS bug, which they still haven't fixed, but a work around seems to be setting the user-agent string.

Unfortunately, this doesn't seem to be able to be set in AcwInterface? Any chance we can get this exposed, as the interface is currently unusable.

create_tags fails when creating multiple tags at the same time

Hi.

When trying to insert some tags at the same time using "create_tags" method it fails with
"The parameter 'Value' may only be specified once."

The http request seems to be malformed. It mixes keys and values :
Tag.1.Key.1=myKey1&
Tag.1.Key.2=myValue1&
Tag.1.Value.1=myKey2&
Tag.1.Value.2=myValue2&
Tag.2.Key.1=default&
Tag.2.Key.2=&
Tag.2.Value=

Code sample and full error output => https://gist.github.com/789496

It seems like a bug, but maybe I am missing something obvious here.

Any help is appreciated.

User data is base64-encoded in autoscaled instances

Please see the reproduce code here: https://gist.github.com/904753

When I create a launch configuration using right_aws, the user data is returned base64-encoded, both in the instance (http://169.254.169.254/latest/user-data) and api as shown in the gist.

Creating a launch configuration using amazon's command line tools and also specifying user data in aws console (both giving actual user data and base64-encoded user data) all work properly.

For now I ended up trying to base64-decode the user data in my initscript as a workaround if the proper retrieved user data does not look valid.

This is on the latest gem version (2.1.0).

Looking at the built request I cannot find an obvious problem.

add authorized link generation for cloudfront

It may be a feature we want to support, as at least one customer is trying to use it:

S3interface authorized-read get_link with cloudfront

Is there any way to do this? No matter how I configure the bucket and path names, it will not give me a valid, working, authorized-read link. I've tried:

s3 = RightAws::S3Interface.new(AWS_CREDS[:access_key], AWS_CREDS[:secret_access_key], :port => 80, :protocol => 'http', :server => '<cloudfront cname>')

s3.get_link(AWS_CREDS[:bucket],<path to resource less bucket name>)

I've tried aliasing the cloudfront distribution to <bucket name>.<domain name> and leaving the bucket name off of the cloudfront cname when I declare the server in S3Interface.new. Nothing works. I've looked at the code, and am not clear why this is failing.

It's delivering large video files that have to be authorized-read, so speed is important. It works fine so long as I stay with an S3 link.

NoMethodError: private method `clone' called for "\n":String when calling RightAws::S3Interface#copy

RightAws::S3Interface#copy now seems to be completely broken. We've repeated it consistently. I'll try again tomorrow and see if this is Amazon's problem, but something certainly changed.

Here's a stack trace:

NoMethodError: private method `clone' called for "\n":String
/usr/local/jruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:451:in `unnormalize'
/usr/local/jruby/lib/ruby/1.8/rexml/parsers/streamparser.rb:28:in `parse'
/usr/local/jruby/lib/ruby/1.8/rexml/document.rb:201:in `parse_stream'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/awsbase/right_awsbase.rb:901:in `parse'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/awsbase/right_awsbase.rb:445:in `request_info_impl'
/usr/local/jruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/awsbase/benchmark_fix.rb:30:in `add!'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/awsbase/right_awsbase.rb:445:in `request_info_impl'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/s3/right_s3_interface.rb:184:in `request_info'
/var/www/studio/shared/bundled_gems/jruby/1.8/gems/right_aws-2.0.0/lib/s3/right_s3_interface.rb:657:in `copy'

Consider adding HTTP response code stats to HttpConnection

Animoto submitted the following patch. We may want to add something similar (THE PATCH BELOW IS NOT NOT NOT APPROPRIATE FOR CUT & PASTE INTO OUR GEMS! REWRITE IT!)

ANIMOTO 2008-09-16

This monkey patch logs every HTTP transaction and records the

hostname/ip, and the count of how many times each error code

is returned.

$GLOBAL_HTTP_COUNT is a hash of hashes like this:

s3-p.animoto.com.s3.amazonaws.com 207.171.166.190:443:

"200": 6

"404": 2

queue.amazonaws.com 207.171.166.190:443:

"200": 33

s3-s.animoto.com.s3.amazonaws.com 207.171.166.191:443:

"200": 2

"500": 1

Somewhere in your main loop, you may want to log this info

and reset $GLOBAL_HTTP_COUNT.

$GLOBAL_HTTP_COUNT={}
END
module Net
class HTTP
def request_with_logging(req, body = nil, &block)
res = request_without_logging(req, body, &block)

IPSocket.peeraddr returns "the domain, port, name, and IP address of the peer."

["AF_INET", 443, "", "72.21.207.26"]

(domain_type, peer_port, peer_name, peer_ip) = @socket.io.peeraddr rescue []
peer = self.address
peer = "#{peer} #{peer_ip}:#{peer_port}" if peer_ip
Thread.exclusive do
$GLOBAL_HTTP_COUNT[ peer ]

= Hash.new(0)
$GLOBAL_HTTP_COUNT[ peer ][ res.code ] += 1
end
return res
end
alias_method :request_without_logging, :request
alias_method :request, :request_with_logging
end
end

camelize misbehaves with Rails 3

The currently published gem (2.0.0) tries to add ActiveSupport's camelize if ActiveSupport is not there, but it assumes Rails 2's version of ActiveSupport. See http://yehudakatz.com/tags/ruby-2-0/ for more explanation.

I'd be willing to offer a patch if I can find where the 2.0.0 commit left off. It'd be nice to have a 2.0.1 release with the patch so that the gem works with the current version of Rails.

Windows (7) - uninitialized constant RightAws::SqsGen2 (NameError)

!/usr/bin/env ruby

require 'rubygems'

require 'right_aws'

sqs = RightAws::SqsGen2.new('xxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxx')

=begin
On Windows with the right_aws-1.1.0 gem installed via: gem install right_aws

I get the following error message:

uninitialized constant RightAws::SqsGen2 (NameError)
=end

Is S3Interface supposed to be thread-safe?

I've been trying to use what I believe to be the thread safe mode of S3Interface. Earlier RDoc listed this as a :thread_safe => true option to the initializer, but that no longer appears to be supported.

I found the :connections parameter which defaults to :shared and appeared to use thread-specific connection pools, and assumed that meant S3Interface is supposed to be thread-safe.

However, I've been battling a very strange bug on JRuby in Rails thread-safe mode, and it appears to be caused by thread safety problems with S3Interface:

http://jira.codehaus.org/browse/JRUBY-5267

Switching to thread-specific S3Interfaces solved the problem. So first I'm curious if S3Interface is actually intended to be thread safe or not, and if it is, does it require some configuration I'm not doing?

Accidentally deleted entire bucket instead of one key.

I just accidentally deleted my entire S3 bucket. Reading the code I'd just pasted into irb, I find the command "bucket.delete key" which apparently actually went to the method RightAws::S3::Bucket.delete(force=false). Instead of a single key being deleted, my key was interpreted as a true boolean for the force parameter.

Dang.

Also, I tried to register for a RightScale.com forum account but it looks like I couldn't do that without giving you my AWS credentials. I thought that was over the top for just posting a "bug" report. The IRC channel #ruby-lang suggested I come here with the report.

Anyway, I think your API might use some work to make this kind of error less likely. It'd be nice to be able to post in the gem's forum without giving away my AWS keys too.

Why is :common_prefixes removed from bucket.keys_and_service?

Hi, I'd been looking for a way to discover the names of folders inside buckets when I eventually came across the :common_prefixes attribute and the following snippet of code in RightAWS::S3:

def keys_and_service(options={}, head=false)
  # ... some code ....
  thislist.each_key do |key|
    service_data[key] = thislist[key] unless (key == :contents || key == :common_prefixes)                                                   
  end
  [list, service_data]
end

Why on earth is the :common_prefixes being removed when it is so useful and has no additional cost in passing it through?

Cheers, sam

Eucalyptus not working with 2.1.0

After updating right_aws gem to version 2.1.0, our service stopped working (based on Eucalyptus).
After digging a while, I found that in prepare_instance_launch_params method defined in ec2/right_ec2_instances.rb is set ClientToken, which is not supported in Eucalyptus.
Here is the error:

 ##### RightAws::Ec2 returned an error: 400 Bad Request
 Failure: 400 Bad Request
 Failed to bind the following fields:
 ClientToken = 1301984140-617558-1ISow-nzbUH-Jnyvb-pblkZ

Solution can be to automatically disable this param if eucalyptus param is set to true.
I can prepare a patch for this.
What do you think?

Support for Cloud Formation and Elastic Beanstalk

It would be great if support for these could be added to right_aws. The Cloud Formation is a JSON format is so very simple from an API point of view. From Rightscale's point of view it is probably not in their interest to support the new PaaS features of Amazon but as this is an open source product they are going to be added sooner or later. Cloud Formation has tremendous potential as a common API that could be implemented across clouds.... right_aws Cloud Formation plus Chef could become a great cloud admin approach as they are both ruby and JSON formats...

Why CGI::escape instead of URI::escape

I have a key that has forward slashes, single quotes, apostrophes, spaces, and some valid UTF-8 characters, and CGI::escape mangles them all.

URI::escape handles this just fine...

Is there a reason why CGI::escape over URI::escape?

Possible signature/escaping bug in SDB modules

I have an app which is constantly sending requests to SDB but I'm
getting regular SignatureDoesNotMatch errors. A bit of Googling I
found this:
http://developer.amazonwebservices.com/connect/message.jspa?messageID=77430

I have a feeling there is something not quite right about the URL
encoding that's happening in the generate_request method of
right_sdb_interface.rb
I think occasionally the Signature has characters in it which are not
the encoded properly - beyond that I'm not sure.

There is a thread in your forum about the issues which hasn't had a
response: http://forums.rightscale.com/showthread.php?p=295

Have you guys got any ideas? This is the specific error I'm getting:

SignatureDoesNotMatch: The request signature we calculated does not
match the signature you provided. Check your AWS Secret Access Key and
signing method. Consult the service documentation for details.
/usr/lib/ruby/gems/1.8/gems/right_aws-1.9.0/lib/awsbase/right_awsbase.rb:280:in
request_info_impl' /usr/lib/ruby/gems/1.8/gems/right_aws-1.9.0/lib/sdb/right_sdb_interface.rb:116:in request_info'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.9.0/lib/sdb/right_sdb_interface.rb:314:in
put_attributes' /usr/lib/ruby/gems/1.8/gems/right_aws-1.9.0/lib/sdb/active_sdb.rb:657:insave'
/usr/lib/ruby/gems/1.8/gems/right_aws-1.9.0/lib/sdb/active_sdb.rb:475:in
`create'

Fix corruption of user data in RightEc2

I believe you have a 'bug' in your right_aws gem (either by design or  
by accident). It is in file right_ec2.rb around line 533 in method:

  launch_instances(image_id, lparams={})

  The line in question is:

lparams[:user_data].strip!

The problem is that when trying to pass user data that includes binary  
hex values, the strip! has the potential to corrupt the file. In my  
example, I tried passing a zip file that included 4 bytes of 0x00 (in  
hex) at the end, which the strip! then removed and corrupted the  
resulting file when trying to unzip it inside the ec2 image that was  
launched.

Like I mentioned, I don't know if this is by design or accident, but I  
had to comment this line out for the gem to work in my environment.

Hung Connections leading to RequestTimeTooSkewed

I am trying to use right_aws + right_http_connection to use one persistent connection per-process to reduce the overhead of dealing with S3.

I've got a module in lib/onehub.rb that keeps the connection and bucket objects.
https://gist.github.com/7ef90619fbd331479c6a

Then from my models I'll call something like Onehub.bucket.put to upload the file in background task, with the idea that this should be a persistent connection since these background workers are simply uploaders.

What I get quite frequently is 'hung' sockets. The socket doesn't get written to for > 15 minutes, but eventually this recovers (maybe related to a thread not getting scheduled?). The problem is that the request is signed and we've now left the 15 minute grace period that S3 will tolerate so I get the exception: RightAws::AwsError: RequestTimeTooSkewed: The difference between the request time and the current time is too large.

Here is a backtrace:
https://gist.github.com/26ddd66d2cc5de223c9c

Is there a better way to handle a per-process persistent connection? Is this some subtle threading issue where the thread that writes isn't being scheduled by the interpreter? I am not using this in a multi-threaded environment. Is this because S3 hangs up after 60 seconds but the library expects the connection to still be open?

We diagnosed the issue by instrumenting the PUT operations and dumping to a log file, but could never create a case that reliably reproduced it.

rds connection fails in Ruby 1.9.1

rds connection fails in Ruby 1.9.1

I, [2010-11-27T17:42:21.817452 #5744] INFO -- : New RightAws::RdsInterface usin
g shared connections mode
I, [2010-11-27T17:42:21.819452 #5744] INFO -- : Opening new HTTPS connection to
rds.amazonaws.com:443
W, [2010-11-27T17:42:24.250591 #5744] WARN -- : Rightscale::HttpConnection : re
quest failure count: 1, exception: #<OpenSSL::SSL::SSLError: SSL_connect returne
d=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed>

http://www.ruby-forum.com/topic/176626 suggest that
Add the following, just next to http.use_ssl:
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

Broken Pipe

We're getting broken pipe errors when uploading to S3.

Things to note:

  1. We have ephemeral EC2 workers that are doing the uploading.
  2. It does not seem to be an individual EC2 worker with the issue (happens on many of them).
  3. They're unpredictable. They happen seemingly at random. No consistency with time of day or events.
  4. The only pattern is that they seem to happen all around the same time, even though they're on separate workers.
  5. We have retries with increasing delays between them (up to several minutes) and this doesn't solve the issue.

Now, it could just be S3/EC2 flakiness or it could be an issue with connection management. I'm not sure and it's quite difficult to diagnose. Anyone have any tips for tracking this down?

Missing S3TrueParser class (uninitialized constant)

Text from Customer Ticket:

/opt/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/right_s3_interface.rb:248:in `put_logging': uninitialized constant RightAws::S3Interface::S3TrueParser (NameError?)
from
/opt/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/right_s3.rb:200:in `disable_logging'
from bin.rb:5

Diving into the code led me here:

    right_aws-1.10.0/lib/s3/right_s3_interface.rb:248

    def put_logging(params)  
      AwsUtils.mandatory_arguments([:bucket,:xmldoc], params)
      AwsUtils.allow_only([:bucket,:xmldoc, :headers], params)
      params[:headers] = {} unless params[:headers]
      req_hash = generate_rest_request('PUT', params[:headers].merge(:url=>"#{params[:bucket]}?logging", :data => params[:xmldoc]))
      request_info(req_hash, RightHttp2xxParser.new)
    rescue
      on_exception
    end

Welcome to the new home of right_aws!

We're happy to announce that we're moving active development on our gems here to GitHub!

So please, feel free to file any bugs or feature requests you have here.

right-aws fails on Heroku: awsbase/support.rb in constantize

2011-03-18T09:22:32-07:00 app[web.1]: /app/6d05e000-94be-4d75-b04d-30d64bbdf55/home/.bundle/gems/ruby/1.9.1/gems/right_
aws-2.0.0/lib/awsbase/support.rb:44:in constantize': "Admin/adminsHelper" is not a valid constant name! (NameError) 2011-03-18T09:22:32-07:00 app[web.1]: from /app/6d05e000-94be-4d75-b04d-730d64bbdf55/home/.bundle/gems/ruby/1.9.1/gems /actionpack-3.0.5/lib/abstract_controller/helpers.rb:149:inblock in modules_for_helpers'
2011-03-18T09:22:32-07:00 app[web.1]: from /app/6d05e000-94be-4d75-b04d-730d64bbdf55/home/.bundle/gems/ruby/1.9.1/gems
/actionpack-3.0.5/lib/abstract_controller/helpers.rb:144:in `map!'

...

AWSbase overrides Rails string inflections

In lib/awsbase/support.rb, constantize and camelize are added to String in the event that ActiveSupport::CoreExtensions has not (yet) been defined. It seems that in some cases these nonetheless can override the Rails versions of the methods.

Worse, the versions in support.rb are broken (or at least antiquated): they do not handle namespaces correctly, so the router is unable to route to any namespaced controllers when these are String's inflectors.

[PATCH] Fix incorrect parameters when creating an autoscaling group with elastic load balancers.

Currently right_aws doesn't correctly set the "LoadBalancerNames" parameter when creating an autoscaling group.

This causes the error:

RightAws::AwsError: MalformedInput: Top level element may not be treated as a list

My patch is pretty trivial; it adds ".members" to theLoadBalancerNames param:
http://github.com/ktheory/right_aws/commits/fix_autoscaling_load_balancer

To reproduce the bug, try to create an autoscaling group with an elastic load balancer.

# Set up credentials
access_key_id = ''
secret_access_key = ''
ssh_key_name = ''

# Create an ELB
elb = RightAws::ElbInterface.new(access_key_id, secret_access_key)
elb.create_load_balancer('test-lb', ['us-east-1c'], [{:protocol => 'HTTP', :load_balancer_port => 80, :instance_port => 80}])

# Create a launch config
# NB: ami-4234de2b = Ubuntu 10.04 64-bit ami
as =  RightAws::AsInterface.new(access_key_id, secret_access_key)

as.create_launch_configuration('test-config', 'ami-4234de2b', 'm1.large', {:security_groups => ['default'], :key_name => ssh_key_name})

# Create autoscaling group using launch config and ELB
as.create_auto_scaling_group('test-asg', 'test-config', ['us-east-1c'], {:min_size => 0, :max_size => 0, :load_balancer_names => ['test-lb']})

The last line raises the error. With my patch, there autoscaling group is correctly created with the right load balancer(s).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.