From 9ee07c96c2b0d64485d111aed0af03fa394e9c4d Mon Sep 17 00:00:00 2001 From: James Slagle Date: Wed, 14 Sep 2016 16:02:00 +0000 Subject: [PATCH] Revert "Treat ec2 collector data as immutable" All CI jobs are timing out currently during NetworkDeployment because 99-refresh-completed is not signaling to Heat due to instance-id being detected as null by os-apply-config. I suspect this patch is causing the issue. This reverts commit 8717436db99a84588532e792f8c9ea909f3e3628. Change-Id: Id0d122d7e855cd828a0742dabc5f7089fb6a913c Closes-Bug: 1623754 --- os_collect_config/collect.py | 4 ---- os_collect_config/ec2.py | 6 ------ os_collect_config/exc.py | 8 -------- os_collect_config/tests/test_collect.py | 8 -------- os_collect_config/tests/test_ec2.py | 15 --------------- 5 files changed, 41 deletions(-) diff --git a/os_collect_config/collect.py b/os_collect_config/collect.py index de19a7a..f519dfb 100644 --- a/os_collect_config/collect.py +++ b/os_collect_config/collect.py @@ -170,10 +170,6 @@ def collect_all(collectors, store=False, collector_kwargs_map=None): except exc.SourceNotConfigured: logger.debug('Source [%s] Not configured.' % collector) continue - except exc.SourceAlreadyCollected: - logger.debug('Source [%s] Already collected and cached.' - % collector) - continue if store: for output_key, output_content in content: diff --git a/os_collect_config/ec2.py b/os_collect_config/ec2.py index 03a0ce6..d652922 100644 --- a/os_collect_config/ec2.py +++ b/os_collect_config/ec2.py @@ -13,12 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - from oslo_config import cfg from oslo_log import log -from os_collect_config import cache from os_collect_config import common from os_collect_config import exc @@ -63,8 +60,5 @@ class Collector(object): return content def collect(self): - cache_path = cache.get_path('ec2') - if os.path.exists(cache_path): - raise exc.Ec2MetadataAlreadyCollected() root_url = '%s/' % (CONF.ec2.metadata_url) return [('ec2', self._fetch_metadata(root_url, CONF.ec2.timeout))] diff --git a/os_collect_config/exc.py b/os_collect_config/exc.py index 37ab039..73a9687 100644 --- a/os_collect_config/exc.py +++ b/os_collect_config/exc.py @@ -22,18 +22,10 @@ class SourceNotConfigured(RuntimeError): """The requested data source is not configured.""" -class SourceAlreadyCollected(RuntimeError): - """The requested data source is immutable and already cached.""" - - class Ec2MetadataNotAvailable(SourceNotAvailable): """The EC2 metadata service is not available.""" -class Ec2MetadataAlreadyCollected(SourceAlreadyCollected): - """The EC2 metadata has already been fetched and cached.""" - - class CfnMetadataNotAvailable(SourceNotAvailable): """The cfn metadata service is not available.""" diff --git a/os_collect_config/tests/test_collect.py b/os_collect_config/tests/test_collect.py index 05f8f32..5f4ef3f 100644 --- a/os_collect_config/tests/test_collect.py +++ b/os_collect_config/tests/test_collect.py @@ -447,10 +447,6 @@ class TestCollectAll(testtools.TestCase): cache.commit(changed) (changed_keys, paths2) = self._call_collect_all(store=True) self.assertEqual(set(), changed_keys) - - # check the second collect skips ec2, it has already been cached. - ec2_path = os.path.join(self.cache_dir.path, 'ec2.json') - paths.remove(ec2_path) self.assertEqual(paths, paths2) def test_collect_all_no_change_softwareconfig(self): @@ -481,10 +477,6 @@ class TestCollectAll(testtools.TestCase): (changed_keys, paths2) = self._call_collect_all( store=True, collector_kwargs_map=soft_config_map) self.assertEqual(set(), changed_keys) - - # check the second collect skips ec2, it has already been cached. - ec2_path = os.path.join(self.cache_dir.path, 'ec2.json') - paths.remove(ec2_path) self.assertEqual(paths, paths2) def test_collect_all_nostore(self): diff --git a/os_collect_config/tests/test_ec2.py b/os_collect_config/tests/test_ec2.py index e2a0e04..7b27d96 100644 --- a/os_collect_config/tests/test_ec2.py +++ b/os_collect_config/tests/test_ec2.py @@ -13,12 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json -import os import uuid import fixtures -from oslo_config import cfg import requests import six.moves.urllib.parse as urlparse import testtools @@ -117,15 +114,3 @@ class TestEc2(testtools.TestCase): collect_ec2 = ec2.Collector(requests_impl=FakeFailRequests) self.assertRaises(exc.Ec2MetadataNotAvailable, collect_ec2.collect) self.assertIn('Forbidden', self.log.output) - - def test_collect_ec2_collected(self): - collect.setup_conf() - cache_dir = self.useFixture(fixtures.TempDir()) - self.addCleanup(cfg.CONF.reset) - cfg.CONF.set_override('cachedir', cache_dir.path) - ec2_path = os.path.join(cache_dir.path, 'ec2.json') - with open(ec2_path, 'w') as f: - json.dump(META_DATA, f) - - collect_ec2 = ec2.Collector(requests_impl=FakeFailRequests) - self.assertRaises(exc.Ec2MetadataAlreadyCollected, collect_ec2.collect)