Log shade inner exceptions
With the dependent change, shade now stores inner exceptions if they occur. Wrap our use of shade with a context manager that logs the inner exceptions in nodepool's own logging context. Change-Id: I6be2422aa0352ee9f0ff7429ee6e66384c2b5d57 Depends-On: I33269743a8f62b863569130aba3cc9b5a8539aa0
This commit is contained in:
parent
eed395d637
commit
afdd58c10a
|
@ -19,6 +19,7 @@
|
|||
import json
|
||||
import logging
|
||||
import paramiko
|
||||
from contextlib import contextmanager
|
||||
|
||||
import threading
|
||||
import time
|
||||
|
@ -125,6 +126,15 @@ def make_image_dict(image):
|
|||
return d
|
||||
|
||||
|
||||
@contextmanager
|
||||
def shade_inner_exceptions():
|
||||
try:
|
||||
yield
|
||||
except shade.OpenStackCloudException as e:
|
||||
e.log_error()
|
||||
raise
|
||||
|
||||
|
||||
class NotFound(Exception):
|
||||
pass
|
||||
|
||||
|
@ -574,6 +584,7 @@ class ProviderManager(TaskManager):
|
|||
# block for our v1 clouds anyway, so we might as well
|
||||
# have the interface be the same and treat faking-out
|
||||
# a shade-level fake-async interface later
|
||||
with shade_inner_exceptions():
|
||||
image = self._client.create_image(
|
||||
name=image_name,
|
||||
filename='%s.%s' % (filename, disk_format),
|
||||
|
|
|
@ -12,12 +12,16 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import fixtures
|
||||
import shade
|
||||
import testtools
|
||||
import yaml
|
||||
|
||||
from nodepool import tests
|
||||
from nodepool.provider_manager import shade_inner_exceptions
|
||||
|
||||
|
||||
class TestShadeIntegration(tests.IntegrationTestCase):
|
||||
|
@ -86,3 +90,13 @@ class TestShadeIntegration(tests.IntegrationTestCase):
|
|||
pool.updateConfig()
|
||||
provider_manager = pool.config.provider_managers['fake-provider']
|
||||
self.assertEqual(provider_manager._client.auth, auth_data)
|
||||
|
||||
def test_exceptions(self):
|
||||
log = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
||||
with testtools.ExpectedException(shade.OpenStackCloudException):
|
||||
with shade_inner_exceptions():
|
||||
try:
|
||||
raise Exception("inner test")
|
||||
except:
|
||||
raise shade.OpenStackCloudException("outer test")
|
||||
self.assertTrue('Exception("inner test")' in log.output)
|
||||
|
|
Loading…
Reference in New Issue