Handle missing local collector directory
We currently explode if local collector is enabled with the data directory missing. Changing this to a warning allows us to have this turned on by default without greatly inconveniencing users. Change-Id: I36364ba1a0706a5a2c820eadd526f2ba424ac665
This commit is contained in:
parent
0f83ecbc2f
commit
d05f57b092
@ -59,6 +59,11 @@ class Collector(object):
|
||||
raise exc.LocalMetadataNotAvailable
|
||||
final_content = []
|
||||
for local_path in cfg.CONF.local.path:
|
||||
try:
|
||||
os.stat(local_path)
|
||||
except OSError:
|
||||
logger.warning("%s not found. Skipping", local_path)
|
||||
continue
|
||||
if _dest_looks_insecure(local_path):
|
||||
raise exc.LocalMetadataNotAvailable
|
||||
for data_file in os.listdir(local_path):
|
||||
|
@ -140,3 +140,11 @@ class TestLocal(testtools.TestCase):
|
||||
badjson.write('{')
|
||||
self.assertRaises(exc.LocalMetadataNotAvailable, self._call_collect)
|
||||
self.assertIn('is not valid JSON', self.log.output)
|
||||
|
||||
def test_collect_local_path_nonexist(self):
|
||||
cfg.CONF.set_override(name='path',
|
||||
override=['/this/doesnt/exist'],
|
||||
group='local')
|
||||
local_md = self._call_collect()
|
||||
self.assertThat(local_md, matchers.IsInstance(list))
|
||||
self.assertEqual(0, len(local_md))
|
||||
|
Loading…
Reference in New Issue
Block a user