Post metering-label-rules API returns 500 when the body has wrong metering_label_id

Bug #1633006 reported by Hirofumi Ichihara
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
In Progress
Low
Hirofumi Ichihara

Bug Description

When we calls metering-label-rules POST API with wrong metering_label_id, we catch 500 from Neutron server.

$ curl -g -i -X POST http://127.0.0.1:9696/v2.0/metering/metering-label-rules.json -H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: $TOKEN" -d '{"metering_label_rule": {"remote_ip_prefix": "10.0.0.0/24", "direction": "ingress", "metering_label_id": "43e7dfd6-0deb-427b-9abc-5eaf5ada5040"}}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 150
X-Openstack-Request-Id: req-7242ca76-283a-4589-ae69-7214622b804b
Date: Thu, 13 Oct 2016 09:22:43 GMT

{"NeutronError": {"message": "Request Failed: internal server error while processing your request.", "type": "HTTPInternalServerError", "detail": ""}}

Error log:

2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1019, in _read_query_result
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource result.read()
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1302, in read
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource first_packet = self.connection._read_packet()
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 981, in _read_packet
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource packet.check_error()
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 393, in check_error
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource err.raise_mysql_exception(self._data)
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource raise errorclass(errno, errval)
2016-10-13 09:22:43.156 TRACE neutron.api.v2.resource DBReferenceError: (pymysql.err.IntegrityError) (1452, u'Cannot add or update a child row: a foreign key constraint fails (`neutron`.`meteringlabelrules`, CONSTRAINT `meteringlabelrules_ibfk_1` FOREIGN KEY (`metering_label_id`) REFERENCES `meteringlabels` (`id`) ON DELETE CASCADE)') [SQL: u'INSERT INTO meteringlabelrules (id, direction, remote_ip_prefix, metering_label_id, excluded) VALUES (%(id)s, %(direction)s, %(remote_ip_prefix)s, %(metering_label_id)s, %(excluded)s)'] [parameters: {'remote_ip_prefix': u'10.0.0.0/24', 'direction': u'ingress', 'metering_label_id': u'43e7dfd6-0deb-427b-9abc-5eaf5ada5040', 'id': 'ee5358b7-7326-42d2-be37-829b97f945af', 'excluded': 0}]

Tags: metering
Changed in neutron:
assignee: nobody → Hirofumi Ichihara (ichihara-hirofumi)
tags: added: metering
Changed in neutron:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (master)

Change abandoned by Hirofumi Ichihara (<email address hidden>) on branch: master
Review: https://review.openstack.org/385864
Reason: Duplicated https://review.openstack.org/#/c/359591/

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.