From df583f83ac9d4869e0b3df5a904d13890d2f0986 Mon Sep 17 00:00:00 2001 From: Phil Roche Date: Mon, 13 Jun 2016 09:52:52 +0100 Subject: Removes trailing dot in metadata.google.internal GCE metadata lookup. 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. LP: #1581200 --- cloudinit/sources/DataSourceGCE.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cloudinit/sources/DataSourceGCE.py') diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py index 9234d1f8..c660a350 100644 --- a/cloudinit/sources/DataSourceGCE.py +++ b/cloudinit/sources/DataSourceGCE.py @@ -25,7 +25,7 @@ from cloudinit import util 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') -- cgit v1.2.3 From 780f88f4dd8ddd36c54e217ea5af3b18b7339758 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 14 Jun 2016 15:08:24 -0400 Subject: [Revert] Remove trailing dot from GCE metadata URL This change broke tox tests. --- ChangeLog | 1 - cloudinit/sources/DataSourceGCE.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'cloudinit/sources/DataSourceGCE.py') diff --git a/ChangeLog b/ChangeLog index 66539792..e2869522 100644 --- a/ChangeLog +++ b/ChangeLog @@ -122,7 +122,6 @@ - ConfigDrive: improved support for networking information from a network_data.json or older interfaces formated network_config. - Change missing Cheetah log warning to debug [Andrew Jorgensen] - - Remove trailing dot from GCE metadata URL (LP: #1581200) [Phil Roche] 0.7.6: - open 0.7.6 diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py index c660a350..9234d1f8 100644 --- a/cloudinit/sources/DataSourceGCE.py +++ b/cloudinit/sources/DataSourceGCE.py @@ -25,7 +25,7 @@ from cloudinit import util 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') -- cgit v1.2.3 From 946b0f5542ffb43149f60b5dd50b2fb450d23713 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 15 Jun 2016 10:31:44 +0100 Subject: Re-apply "Remove trailing dot from GCE metadata URL (LP: #1581200) [Phil Roche]" This commit includes the content of that commit, plus a fix for the tests (provided by Phil). --- ChangeLog | 1 + cloudinit/sources/DataSourceGCE.py | 2 +- tests/unittests/test_datasource/test_gce.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'cloudinit/sources/DataSourceGCE.py') diff --git a/ChangeLog b/ChangeLog index e2869522..66539792 100644 --- a/ChangeLog +++ b/ChangeLog @@ -122,6 +122,7 @@ - ConfigDrive: improved support for networking information from a network_data.json or older interfaces formated network_config. - Change missing Cheetah log warning to debug [Andrew Jorgensen] + - Remove trailing dot from GCE metadata URL (LP: #1581200) [Phil Roche] 0.7.6: - open 0.7.6 diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py index 9234d1f8..c660a350 100644 --- a/cloudinit/sources/DataSourceGCE.py +++ b/cloudinit/sources/DataSourceGCE.py @@ -25,7 +25,7 @@ from cloudinit import util 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') diff --git a/tests/unittests/test_datasource/test_gce.py b/tests/unittests/test_datasource/test_gce.py index 1f7eb99e..6e62a4d2 100644 --- a/tests/unittests/test_datasource/test_gce.py +++ b/tests/unittests/test_datasource/test_gce.py @@ -52,7 +52,7 @@ GCE_META_ENCODING = { 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): -- cgit v1.2.3