Event status set to ERROR when it fails
When a resource action fails during the execution of an event, the event status and the reservation status are now set to ERROR. Change-Id: I37a7757c5ee8a12665a41ffc3c8194d921f196e4 Closes-Bug: #1333345
This commit is contained in:
parent
acb155cbcc
commit
cfbe4419b9
@ -423,6 +423,7 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
"""Commits basic lease actions such as starting and ending."""
|
"""Commits basic lease actions such as starting and ending."""
|
||||||
lease = self.get_lease(lease_id)
|
lease = self.get_lease(lease_id)
|
||||||
|
|
||||||
|
event_status = 'DONE'
|
||||||
for reservation in lease['reservations']:
|
for reservation in lease['reservations']:
|
||||||
resource_type = reservation['resource_type']
|
resource_type = reservation['resource_type']
|
||||||
try:
|
try:
|
||||||
@ -436,12 +437,15 @@ class ManagerService(service_utils.RPCServer):
|
|||||||
'action': action_time,
|
'action': action_time,
|
||||||
'lease': lease_id,
|
'lease': lease_id,
|
||||||
})
|
})
|
||||||
|
event_status = 'ERROR'
|
||||||
if reservation_status is not None:
|
|
||||||
db_api.reservation_update(reservation['id'],
|
db_api.reservation_update(reservation['id'],
|
||||||
{'status': reservation_status})
|
{'status': 'error'})
|
||||||
|
else:
|
||||||
|
if reservation_status is not None:
|
||||||
|
db_api.reservation_update(reservation['id'],
|
||||||
|
{'status': reservation_status})
|
||||||
|
|
||||||
db_api.event_update(event_id, {'status': 'DONE'})
|
db_api.event_update(event_id, {'status': event_status})
|
||||||
|
|
||||||
def _send_notification(self, lease, ctx, events=[]):
|
def _send_notification(self, lease, ctx, events=[]):
|
||||||
payload = notification_api.format_lease_payload(lease)
|
payload = notification_api.format_lease_payload(lease)
|
||||||
|
@ -1103,9 +1103,29 @@ class ServiceTestCase(tests.TestCase):
|
|||||||
|
|
||||||
self.patch(self.manager, 'get_lease').return_value = self.lease
|
self.patch(self.manager, 'get_lease').return_value = self.lease
|
||||||
|
|
||||||
|
self.manager._basic_action(self.lease_id, '1', 'on_end',
|
||||||
|
reservation_status='done')
|
||||||
|
|
||||||
|
self.reservation_update.assert_called_once_with(
|
||||||
|
'111', {'status': 'error'})
|
||||||
|
self.event_update.assert_called_once_with('1', {'status': 'ERROR'})
|
||||||
|
|
||||||
|
def test_basic_action_raise_exception_no_reservation_status(self):
|
||||||
|
def raiseClimateException(resource_id):
|
||||||
|
raise exceptions.ClimateException(resource_id)
|
||||||
|
|
||||||
|
self.manager.resource_actions = (
|
||||||
|
{'virtual:instance':
|
||||||
|
{'on_start': self.fake_plugin.on_start,
|
||||||
|
'on_end': raiseClimateException}})
|
||||||
|
|
||||||
|
self.patch(self.manager, 'get_lease').return_value = self.lease
|
||||||
|
|
||||||
self.manager._basic_action(self.lease_id, '1', 'on_end')
|
self.manager._basic_action(self.lease_id, '1', 'on_end')
|
||||||
|
|
||||||
self.event_update.assert_called_once_with('1', {'status': 'DONE'})
|
self.reservation_update.assert_called_once_with(
|
||||||
|
'111', {'status': 'error'})
|
||||||
|
self.event_update.assert_called_once_with('1', {'status': 'ERROR'})
|
||||||
|
|
||||||
def test_getattr_with_correct_plugin_and_method(self):
|
def test_getattr_with_correct_plugin_and_method(self):
|
||||||
self.fake_list_computehosts = (
|
self.fake_list_computehosts = (
|
||||||
|
Loading…
Reference in New Issue
Block a user