When trying to delete a Data Source which is used in a Job Execution, Savanna fails with a following error:
2013-10-04 16:31:51.326 776 ERROR savanna.utils.api [-] Traceback (most recent call last):
File "/Users/nikitakonovalov/work/savanna/savanna/utils/api.py", line 86, in handler
return func(**kwargs)
File "/Users/nikitakonovalov/work/savanna/savanna/service/validation.py", line 79, in handler
return func(*args, **kwargs)
File "/Users/nikitakonovalov/work/savanna/savanna/api/v11.py", line 108, in data_source_delete
api.delete_data_source(data_source_id)
File "/Users/nikitakonovalov/work/savanna/savanna/service/edp/api.py", line 73, in delete_data_source
conductor.data_source_destroy(context.ctx(), id)
File "/Users/nikitakonovalov/work/savanna/savanna/conductor/api.py", line 218, in data_source_destroy
self._manager.data_source_destroy(context, _get_id(data_source))
File "/Users/nikitakonovalov/work/savanna/savanna/conductor/manager.py", line 268, in data_source_destroy
File "/Users/nikitakonovalov/work/savanna/savanna/db/api.py", line 258, in data_source_destroy
IMPL.data_source_destroy(context, data_source)
File "/Users/nikitakonovalov/work/savanna/savanna/db/sqlalchemy/api.py", line 437, in data_source_destroy
def data_source_create(context, values):
File "/Users/nikitakonovalov/work/savanna/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 456, in __exit__
self.commit()
File "/Users/nikitakonovalov/work/savanna/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 368, in commit
self._prepare_impl()
File "/Users/nikitakonovalov/work/savanna/.tox/venv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 347, in _prepare_impl
self.session.flush()
File "/Users/nikitakonovalov/work/savanna/savanna/openstack/common/db/sqlalchemy/session.py", line 549, in _wrap
raise exception.DBError(e)
DBError: (IntegrityError) foreign key constraint failed u'DELETE FROM data_sources WHERE data_sources.id = ?' (u'fcaa0096-7189-4cd8-a119-787cdd102a0f',)
127.0.0.1 - - [04/Oct/2013 16:31:51] "DELETE /v1.1/1b438315ab794322be5dd598d070a860/data-sources/fcaa0096-7189-4cd8-a119-787cdd102a0f HTTP/1.1" 500 228 0.016939
{UPDATED}
The same bug appears when deleting Jobs which are used by job executions
I think the best we can probably do here is trap the DBError: IntegrityErrors and raise SavannaExceptions instead.