Преглед изворни кода

HUE-6515 [aws] Do not use a default region if not configured, fallback to standard S3 endpoint

Jenny Kim пре 8 година
родитељ
комит
2157c971d7

+ 2 - 2
desktop/conf.dist/hue.ini

@@ -1376,8 +1376,8 @@
       # EC2 InstanceProfile to retrieve AWS credentials.
       # EC2 InstanceProfile to retrieve AWS credentials.
       ## allow_environment_credentials=yes
       ## allow_environment_credentials=yes
 
 
-      # AWS region to use
-      ## region=us-east-1
+      # AWS region to use, if no region is specified, will attempt to connect to standard s3.amazonaws.com endpoint
+      ## region=
 
 
       # Endpoint overrides
       # Endpoint overrides
       ## host=
       ## host=

+ 2 - 2
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1378,8 +1378,8 @@
       # EC2 InstanceProfile to retrieve AWS credentials.
       # EC2 InstanceProfile to retrieve AWS credentials.
       ## allow_environment_credentials=yes
       ## allow_environment_credentials=yes
 
 
-      # AWS region to use
-      ## region=us-east-1
+      # AWS region to use, if no region is specified, will attempt to connect to standard s3.amazonaws.com endpoint
+      ## region=
 
 
       # Endpoint overrides
       # Endpoint overrides
       ## host=
       ## host=

+ 1 - 0
desktop/libs/aws/src/aws/client.py

@@ -110,6 +110,7 @@ class Client(object):
       elif self._region:
       elif self._region:
         connection = boto.s3.connect_to_region(self._region, **kwargs)
         connection = boto.s3.connect_to_region(self._region, **kwargs)
       else:
       else:
+        kwargs.update({'host': 's3.amazonaws.com'})
         connection = boto.s3.connection.S3Connection(**kwargs)
         connection = boto.s3.connection.S3Connection(**kwargs)
     except Exception, e:
     except Exception, e:
       LOG.exception(e)
       LOG.exception(e)

+ 3 - 2
desktop/libs/aws/src/aws/conf.py

@@ -17,6 +17,7 @@ from __future__ import absolute_import
 
 
 import boto.utils
 import boto.utils
 from boto.regioninfo import get_regions
 from boto.regioninfo import get_regions
+from boto.s3.connection import Location
 
 
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import ugettext_lazy as _
 
 
@@ -45,7 +46,7 @@ def get_default_secret_key():
 
 
 
 
 def get_default_region():
 def get_default_region():
-  return AWS_ACCOUNTS['default'].REGION.get() if 'default' in AWS_ACCOUNTS else 'us-east-1'
+  return AWS_ACCOUNTS['default'].REGION.get() if 'default' in AWS_ACCOUNTS else Location.DEFAULT
 
 
 
 
 AWS_ACCOUNTS = UnspecifiedConfigSection(
 AWS_ACCOUNTS = UnspecifiedConfigSection(
@@ -92,7 +93,7 @@ AWS_ACCOUNTS = UnspecifiedConfigSection(
       ),
       ),
       REGION=Config(
       REGION=Config(
         key='region',
         key='region',
-        default='us-east-1',
+        default=None,
         type=str
         type=str
       ),
       ),
       HOST=Config(
       HOST=Config(

+ 4 - 1
desktop/libs/aws/src/aws/s3/s3fs.py

@@ -100,7 +100,10 @@ class S3FileSystem(object):
         raise S3FileSystemException(_('User is not authorized to access bucket named "%s". '
         raise S3FileSystemException(_('User is not authorized to access bucket named "%s". '
           'If you are attempting to create a bucket, this bucket name is already reserved.') % name)
           'If you are attempting to create a bucket, this bucket name is already reserved.') % name)
       elif e.status == 404:
       elif e.status == 404:
-        bucket = self._s3_connection.create_bucket(name, location=self._get_location())
+        kwargs = {}
+        if self._get_location():
+          kwargs['location'] = self._get_location()
+        bucket = self._s3_connection.create_bucket(name, **kwargs)
         self._bucket_cache[name] = bucket
         self._bucket_cache[name] = bucket
       elif e.status == 400:
       elif e.status == 400:
         raise S3FileSystemException(_('Failed to create bucket named "%s": %s') % (name, e.reason))
         raise S3FileSystemException(_('Failed to create bucket named "%s": %s') % (name, e.reason))