Include original ObjectsCopy/Attributes in exception_result
Before if an exception occured during dsl cleanup exception_result would use empty ObjectsCopy and empty Attributes for result. In case exception happened during env deletion this would cause env to be deleted by API, because it ignored isException and treated any result as valid. Now exception_result also includes original ObjectsCopy/Attributes in case they're empty in exception_result. Api not only checks count of 'error' statuses, in session, but also checks isException attribute of the result, and treats exception results as Errors, therefore marking deployment/deletion as failed. Logging of results in API is now aware, that objects can be empty during app deletion and no longer throws AttributeError because of that. Change-Id: Idec8191ee25d1cac606741673719bbb8a72709b0 Closes-Bug: #1456724
This commit is contained in:
parent
ff28f6922c
commit
1e62fafe82
@ -190,6 +190,13 @@ class TaskExecutor(object):
|
||||
if exception is not None:
|
||||
result['action'] = TaskExecutor.exception_result(
|
||||
exception, exception_traceback)
|
||||
# NOTE(kzaitsev): Exception here means that it happened during
|
||||
# cleanup. ObjectsCopy and Attributes would be empty if obj
|
||||
# is empty. This would cause failed env to be deleted.
|
||||
# Therefore restore these attrs from self._model
|
||||
for attr in ['ObjectsCopy', 'Attributes']:
|
||||
if not model.get(attr):
|
||||
model[attr] = self._model[attr]
|
||||
else:
|
||||
result['action']['result'] = serializer.serialize_object(
|
||||
action_result)
|
||||
|
@ -102,7 +102,7 @@ class ResultEndpoint(object):
|
||||
**{'environment_id': environment.id,
|
||||
'state': states.SessionState.DEPLOYING if not deleted
|
||||
else states.SessionState.DELETING}).first()
|
||||
if num_errors > 0:
|
||||
if num_errors > 0 or result['action'].get('isException'):
|
||||
conf_session.state = \
|
||||
states.SessionState.DELETE_FAILURE if deleted else \
|
||||
states.SessionState.DEPLOY_FAILURE
|
||||
@ -111,14 +111,15 @@ class ResultEndpoint(object):
|
||||
conf_session.save(unit)
|
||||
|
||||
# output application tracking information
|
||||
services = []
|
||||
objects = model['Objects']
|
||||
if objects:
|
||||
services = objects.get('services')
|
||||
message = _LI('EnvId: {0} TenantId: {1} Status: {2} Apps: {3}').format(
|
||||
environment.id,
|
||||
environment.tenant_id,
|
||||
_('Failed') if num_errors + num_warnings > 0 else _('Successful'),
|
||||
', '.join(map(
|
||||
lambda a: a['?']['type'],
|
||||
model['Objects']['services']
|
||||
))
|
||||
', '.join(map(lambda a: a['?']['type'], services))
|
||||
)
|
||||
LOG.info(message)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user