[EDP] No validation when deleting Data Source

Bug #1235229 reported by Nikita Konovalov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sahara
Fix Released
High
Trevor McKay

Bug Description

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

Changed in savanna:
milestone: none → 0.3
Changed in savanna:
importance: Undecided → High
assignee: nobody → Alexander Ignatov (aignatov)
description: updated
Changed in savanna:
status: New → Triaged
Revision history for this message
Trevor McKay (tmckay) wrote :

I think the best we can probably do here is trap the DBError: IntegrityErrors and raise SavannaExceptions instead.

Revision history for this message
Trevor McKay (tmckay) wrote :

I've put up a CR for this https://review.openstack.org/#/c/51279/

Changed in savanna:
assignee: Alexander Ignatov (aignatov) → Trevor McKay (tmckay)
Trevor McKay (tmckay)
Changed in savanna:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to savanna (master)

Reviewed: https://review.openstack.org/51279
Committed: http://github.com/openstack/savanna/commit/8289d6d144114924a57651d29384ebcc9eabed6f
Submitter: Jenkins
Branch: master

commit 8289d6d144114924a57651d29384ebcc9eabed6f
Author: Trevor McKay <email address hidden>
Date: Fri Oct 11 15:30:45 2013 -0400

    Replace DBError with DeletionFailed for DataSource and Job

    Foreign key constraints on DataSource and Job objects by JobExecutions
    cause DBError exceptions if those objects are deleted while they are
    referenced by a JobExecution. Replace the DBerror with a SavannaException
    so that the REST api reports the error nicely.

    Change-Id: I756f561b019895c8c2c39f17bd3a05da31ad6440
    Closes-Bug: #1235229

Changed in savanna:
status: In Progress → Fix Committed
Changed in savanna:
milestone: 0.3 → 0.3-rc3
Changed in savanna:
status: Fix Committed → Fix Released
Changed in savanna:
milestone: 0.3-rc3 → 0.3
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.