create a rule on non-exist policy get Element already exists (HTTP 409)

Bug #1446438 reported by Zhenzan Zhou
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
congress
Fix Released
Undecided
Zhenzan Zhou

Bug Description

zhenzan@zhenzan-openstack:~/workspace/congress$ ocp rule create testaba 'p(x):-q(x)'
ERROR: openstack Element already exists (HTTP 409) (Request-ID: req-3e62ae99-d6ca-4ce3-a1a0-58ba7aef73c4)
zhenzan@zhenzan-openstack:~/workspace/congress$ ocp rule list testaba
zhenzan@zhenzan-openstack:~/workspace/congress$

2015-04-21 10:22:38.560 DEBUG congress.api.application [req-30884fb4-a1b1-4eb6-aeeb-20039ec1f817 admin 9622c906ef6d44adb670abe78eab2b1f] Handling request 'POST /v1/policies/testaba/rules' with CollectionHandler(/v1/policies/(?P<policy_id>[^/]+)/rules$) from (pid=19457) __call__ /home/zhenzan/workspace/congress/congress/api/application.py:45
2015-04-21 10:22:38.562 ERROR congress.api.webservice [req-30884fb4-a1b1-4eb6-aeeb-20039ec1f817 admin 9622c906ef6d44adb670abe78eab2b1f] Error occurred
2015-04-21 10:22:38.562 TRACE congress.api.webservice Traceback (most recent call last):
2015-04-21 10:22:38.562 TRACE congress.api.webservice File "/home/zhenzan/workspace/congress/congress/api/webservice.py", line 392, in create_member
2015-04-21 10:22:38.562 TRACE congress.api.webservice item, request.params, id_, context=context)
2015-04-21 10:22:38.562 TRACE congress.api.webservice File "/home/zhenzan/workspace/congress/congress/api/rule_model.py", line 128, in add_item
2015-04-21 10:22:38.562 TRACE congress.api.webservice changes = self.change_rule(rule, context)
2015-04-21 10:22:38.562 TRACE congress.api.webservice File "/home/zhenzan/workspace/congress/congress/api/rule_model.py", line 186, in change_rule
2015-04-21 10:22:38.562 TRACE congress.api.webservice raise KeyError("Policy with ID '%s' does not exist", policy_name)
2015-04-21 10:22:38.562 TRACE congress.api.webservice KeyError: ("Policy with ID '%s' does not exist", 'testaba')
2015-04-21 10:22:38.562 TRACE congress.api.webservice
2015-04-21 10:22:38.563 INFO eventlet.wsgi.server [req-30884fb4-a1b1-4eb6-aeeb-20039ec1f817 admin 9622c906ef6d44adb670abe78eab2b1f] 10.239.47.22 - - [21/Apr/2015 10:22:38] "POST /v1/policies/testaba/rules HTTP/1.1" 409 307 0.056563

rule_model.py:add_item() always thinks KeyErrors as "ID already exists".

Changed in congress:
assignee: nobody → Zhenzan Zhou (zhenzan-zhou)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to congress (master)

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

Changed in congress:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to congress (master)

Reviewed: https://review.openstack.org/176573
Committed: https://git.openstack.org/cgit/openstack/congress/commit/?id=7e2e0dd40337bb52e3eed8318b90060df0691445
Submitter: Jenkins
Branch: master

commit 7e2e0dd40337bb52e3eed8318b90060df0691445
Author: Zhenzan Zhou <email address hidden>
Date: Thu Apr 23 09:34:59 2015 +0800

    Respond correct error if policy not exist

    When creating a rule on non-exist policy, it responds Element already
    exists (HTTP 409). We should respond 404 with proper error message instead.

    Change-Id: I219bac909049631dd8e03f448aea8fc996b50d0d
    Closes-Bug: #1446438

Changed in congress:
status: In Progress → Fix Committed
Tim Hinrichs (thinrichs)
Changed in congress:
status: Fix Committed → Fix Released
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.