You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2017/03/24 21:48:02 UTC

[1/2] beam git commit: Allow customizing the GCE metadata service URL.

Repository: beam
Updated Branches:
  refs/heads/master 9b8e16fca -> c80ef1837


Allow customizing the GCE metadata service URL.

The goal here is to allow a user to customize where a job finds the metadata
service; it would also be possible to do this programmatically (eg expose a
variable), but making it an environment variable allows a caller to do this
without need to do so in-process.


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/7453766b
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/7453766b
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/7453766b

Branch: refs/heads/master
Commit: 7453766b0045fabcb8e6e683b30f7fa1a20b334c
Parents: 9b8e16f
Author: Craig Citro <cr...@google.com>
Authored: Fri Mar 24 13:38:50 2017 -0700
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Fri Mar 24 14:47:19 2017 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/internal/gcp/auth.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/7453766b/sdks/python/apache_beam/internal/gcp/auth.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/internal/gcp/auth.py b/sdks/python/apache_beam/internal/gcp/auth.py
index ccc67c6..8304658 100644
--- a/sdks/python/apache_beam/internal/gcp/auth.py
+++ b/sdks/python/apache_beam/internal/gcp/auth.py
@@ -86,9 +86,11 @@ class GCEMetadataCredentials(OAuth2Credentials):
       retry_filter=retry.retry_on_server_errors_and_timeout_filter)
   def _refresh(self, http_request):
     refresh_time = datetime.datetime.now()
-    req = urllib2.Request('http://metadata.google.internal/computeMetadata/v1/'
-                          'instance/service-accounts/default/token',
-                          headers={'Metadata-Flavor': 'Google'})
+    metadata_root = os.environ.get(
+        'GCE_METADATA_ROOT', 'metadata.google.internal')
+    token_url = ('http://{}/computeMetadata/v1/instance/service-accounts/'
+                 'default/token').format(metadata_root)
+    req = urllib2.Request(token_url, headers={'Metadata-Flavor': 'Google'})
     token_data = json.loads(urllib2.urlopen(req).read())
     self.access_token = token_data['access_token']
     self.token_expiry = (refresh_time +


[2/2] beam git commit: Closes #2319

Posted by ro...@apache.org.
Closes #2319


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/c80ef183
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/c80ef183
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/c80ef183

Branch: refs/heads/master
Commit: c80ef18376cb8c5b2cf8c1d9ac6000386d1eceb2
Parents: 9b8e16f 7453766
Author: Robert Bradshaw <ro...@gmail.com>
Authored: Fri Mar 24 14:47:20 2017 -0700
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Fri Mar 24 14:47:20 2017 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/internal/gcp/auth.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------