← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~philroche/cloud-init/trunk into lp:cloud-init

 

Philip Roche has proposed merging lp:~philroche/cloud-init/trunk into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~philroche/cloud-init/trunk/+merge/297442

Removes trailing dot in metadata.google.internal GCE metadata lookup.

This MP includes test updates to reflect code changes.

A bug was reported (lp:1581200) where if there is no DNS server configured
or it is not running then the metadata lookup on GCE will fail as it contains a
trailing dot 'metadata.google.internal.'. As there is no DNS configured or
running it will use the /etc/hosts file but the hosts file does not contain
an entry with the trailing dot.

One solution is to add an entry to the /etc/hosts file with the trailing dot
but according to the manpage, /etc/hosts entries must end with an alphanumeric
character and cannot end with a dot.

The trailing dot was added to avoid MIM by dns search but we should probably
assume the instance being started has no DNS and as such when querying
metadata should use a URL that will resolve using /etc/hosts.
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~philroche/cloud-init/trunk into lp:cloud-init.
=== modified file 'cloudinit/sources/DataSourceGCE.py'
--- cloudinit/sources/DataSourceGCE.py	2016-06-14 19:08:24 +0000
+++ cloudinit/sources/DataSourceGCE.py	2016-06-15 09:28:01 +0000
@@ -25,7 +25,7 @@
 LOG = logging.getLogger(__name__)
 
 BUILTIN_DS_CONFIG = {
-    'metadata_url': 'http://metadata.google.internal./computeMetadata/v1/'
+    'metadata_url': 'http://metadata.google.internal/computeMetadata/v1/'
 }
 REQUIRED_FIELDS = ('instance-id', 'availability-zone', 'local-hostname')
 

=== modified file 'tests/unittests/test_datasource/test_gce.py'
--- tests/unittests/test_datasource/test_gce.py	2016-05-12 20:43:11 +0000
+++ tests/unittests/test_datasource/test_gce.py	2016-06-15 09:28:01 +0000
@@ -52,7 +52,7 @@
 
 HEADERS = {'X-Google-Metadata-Request': 'True'}
 MD_URL_RE = re.compile(
-    r'http://metadata.google.internal./computeMetadata/v1/.*')
+    r'http://metadata.google.internal/computeMetadata/v1/.*')
 
 
 def _set_mock_metadata(gce_meta=None):