Get server fault if snapshot fails
When we get a 404 from Glance because a server snapshot
is not found while we're waiting for it to be ACTIVE, it
means Nova deleted the failed snapshot from Glance because
something failed in nova-compute during the snapshot
operation.
Rather than just dump a 404 in the test console output on this
type of failure, this change gets the server which should have
a fault recorded and uses that to raise a more useful error
message for the test output.
Change-Id: I8ee2e18925e7f4f09d10d857fb25f3d9b8e8bd42
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index e6c065f..c3c5460 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -304,8 +304,26 @@
cls.images.append(image_id)
if 'wait_until' in kwargs:
- waiters.wait_for_image_status(cls.compute_images_client,
- image_id, kwargs['wait_until'])
+ try:
+ waiters.wait_for_image_status(cls.compute_images_client,
+ image_id, kwargs['wait_until'])
+ except lib_exc.NotFound:
+ if kwargs['wait_until'].upper() == 'ACTIVE':
+ # If the image is not found after create_image returned
+ # that means the snapshot failed in nova-compute and nova
+ # deleted the image. There should be a compute fault
+ # recorded with the server in that case, so get the server
+ # and dump some details.
+ server = (
+ cls.servers_client.show_server(server_id)['server'])
+ if 'fault' in server:
+ raise exceptions.SnapshotNotFoundException(
+ server['fault'], image_id=image_id)
+ else:
+ raise exceptions.SnapshotNotFoundException(
+ image_id=image_id)
+ else:
+ raise
image = cls.compute_images_client.show_image(image_id)['image']
return image