Attempt to delete archive policy used by archive-policy-rule returns 500 error

Bug #1569781 reported by Yurii Prokulevych
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gnocchi
Fix Released
High
Mehdi Abaakouk
2.1
In Progress
Undecided
Julien Danjou

Bug Description

During attempt to delete archive-policy used by archive-policy-rule got 500 error response:

gnocchi archive-policy delete gabbilive
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
 (HTTP 500)

Excerpt from gnocchi/api.log:
2016-04-13 05:16:30.110 7997 DEBUG oslo_policy.policy [-] Reloaded policy file: /etc/gnocchi/policy.json _load_policy_file /usr/lib/python2.7/site-packages/oslo_policy/policy.py:441 [16/1909]
2016-04-13 05:16:30.142 7997 INFO werkzeug [-] 192.168.1.13 - - [13/Apr/2016 05:16:30] "DELETE /v1/archive_policy/gabbilive HTTP/1.1" 500 -
2016-04-13 05:16:30.165 7997 ERROR werkzeug [-] Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/gnocchi/rest/app.py", line 161, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.7/site-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/keystonemiddleware/auth_token/__init__.py", line 455, in __call__
    response = req.get_response(self._app)
  File "/usr/lib/python2.7/site-packages/webob/request.py", line 1317, in send
    application, catch_exc_info=False)
  File "/usr/lib/python2.7/site-packages/webob/request.py", line 1281, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/python2.7/site-packages/webob/exc.py", line 1117, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python2.7/site-packages/gnocchi/rest/app.py", line 77, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pecan/middleware/recursive.py", line 56, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 829, in __call__
    return super(Pecan, self).__call__(environ, start_response)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 678, in __call__
    self.invoke_controller(controller, args, kwargs, state)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 572, in invoke_controller
    result = controller(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/gnocchi/rest/__init__.py", line 284, in delete
    pecan.request.indexer.delete_archive_policy File "/usr/lib/python2.7/site-packages/gnocchi/indexer/sqlalchemy.py", line 130, in delete_archive_policy
    ArchivePolicy.name == name).delete() == 0:
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2828, in delete
    delete_op.exec_()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1106, in exec_
    self._do_exec()
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1284, in _do_exec
    mapper=self.mapper)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1023, in execute
    bind, close_with_result=True).execute(clause, params or {})
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1337, in _handle_dbapi_exception
    util.raise_from_cause(newraise, exc_info)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
DBReferenceError: (_mysql_exceptions.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`gnocchi`.`archive_policy_rule`, CONSTRAINT `fk_archive_policy_rule_archive_poli
cy_name_archive_policy_name` FOREIGN KEY (`archive_policy_name`) REFERENCES `archive_policy` (`name`))') [SQL: u'DELETE FROM archive_policy WHERE archive_policy.name = %s'] [parameters: ('gabbilive',)]
(self.archive_policy)

Packages:
python-gnocchiclient-2.0.0-1.el7ost.noarch
openstack-gnocchi-carbonara-1.3.4-1.el7ost.noarch
openstack-gnocchi-statsd-1.3.4-1.el7ost.noarch
python-gnocchi-1.3.4-1.el7ost.noarch
openstack-gnocchi-api-1.3.4-1.el7ost.noarch
openstack-gnocchi-indexer-sqlalchemy-1.3.4-1.el7ost.noarch
openstack-gnocchi-metricd-1.3.4-1.el7ost.noarch
openstack-gnocchi-common-1.3.4-1.el7ost.noarch

---
Regards,
Yurii

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to gnocchi (master)

Fix proposed to branch: master
Review: https://review.openstack.org/305070

Changed in gnocchi:
assignee: nobody → Mehdi Abaakouk (sileht)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to gnocchi (master)

Reviewed: https://review.openstack.org/305070
Committed: https://git.openstack.org/cgit/openstack/gnocchi/commit/?id=c23835f5370c3da26c910f162507b7822b5bf8fb
Submitter: Jenkins
Branch: master

commit c23835f5370c3da26c910f162507b7822b5bf8fb
Author: Mehdi Abaakouk <email address hidden>
Date: Wed Apr 13 20:43:03 2016 +0200

    Don't delete archive policy used by ap rule

    Closes-bug: #1569781
    Change-Id: Id407eb4c9ef9fe6c1f18e832d0a314ba2448ffbb

Changed in gnocchi:
status: In Progress → Fix Committed
Julien Danjou (jdanjou)
Changed in gnocchi:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to gnocchi (stable/2.1)

Fix proposed to branch: stable/2.1
Review: https://review.openstack.org/322782

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on gnocchi (stable/2.1)

Change abandoned by Julien Danjou (<email address hidden>) on branch: stable/2.1
Review: https://review.openstack.org/322782
Reason: Unable to fix because MySQL sucks and we need the patch that renames the FK to shorter names.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/gnocchi 2.2.0

This issue was fixed in the openstack/gnocchi 2.2.0 release.

Julien Danjou (jdanjou)
Changed in gnocchi:
status: Fix Committed → Fix Released
milestone: none → 2.2.0
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.