vnfd-create returns 500 InternalServerError if VNF is already on-boarded

Bug #1734316 reported by Dinesh Bhor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tacker
Fix Released
Low
Dinesh Bhor

Bug Description

If one VNF is already on-boarded to tacker and if you try to on-board it again tacker gives 500 InternalServerError.

Reproduction commands:

$ tacker vnfd-create --vnfd-file tosca-vnfd-hello-world.yaml VNFD1
vnfd already exist with given ['tenant_id', 'name', 'deleted_at']

Response of a CURL command of the same API:
HTTP/1.1 100 Continue

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 138
X-Openstack-Request-Id: req-2847e2c7-d23a-4323-b367-cbb1bdcfba2a
Date: Tue, 21 Nov 2017 13:45:38 GMT

{"TackerError": {"message": "vnfd already exist with given ['tenant_id', 'name', 'deleted_at']", "type": "DuplicateEntity", "detail": ""}}

tacker service logs:

Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.805 INFO tosca.model [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] nfv
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.806 INFO tosca.model [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] tosca_simple_profile_for_nfv_1_0_0.py
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.837 INFO tosca.model [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] The pre-parsed input successfully passed validation.
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.838 DEBUG tacker.common.log [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] toscaparser.tosca_template.ToscaTemplate method get_mgmt_driver called with arguments () {} from (pid=4854) wrapper /opt/stack/tacker/tacker/common/log.py:34
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.838 DEBUG tacker.vnfm.plugin [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] vnfd {u'vnfd': {'template_source': 'onboarded', u'service_types': [{u'service_type': u'vnfd'}], 'description': 'Demo example', 'tenant_id': u'e24b2a0887ae4ea3aa035e534544c58d', 'mgmt_driver': 'noop', u'attributes': {u'vnfd': "description: Demo example\nmetadata: {template_name: sample-tosca-vnfd}\ntopology_template:\n node_templates:\n CP1:\n properties: {anti_spoofing_protection: false, management: true, order: 0}\n requirements:\n - virtualLink: {node: VL1}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n CP2:\n properties: {anti_spoofing_protection: false, order: 1}\n requirements:\n - virtualLink: {node: VL2}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n CP3:\n properties: {anti_spoofing_protection: false, order: 2}\n requirements:\n - virtualLink: {node: VL3}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n VDU1:\n capabilities:\n nfv_compute:\n properties: {disk_size: 1 GB, mem_size: 512 MB, num_cpus: 1}\n properties: {availability_zone: nova, config: 'param0: key1\n\n param1: key2\n\n ', image: cirros-0.3.5-x86_64-disk, mgmt_driver: noop}\n type: tosca.nodes.nfv.VDU.Tacker\n VL1:\n properties: {network_name: net_mgmt, vendor: Tacker}\n type: tosca.nodes.nfv.VL\n VL2:\n properties: {network_name: net0, vendor: Tacker}\n type: tosca.nodes.nfv.VL\n VL3:\n properties: {network_name: net1, vendor: Tacker}\n type: tosca.nodes.nfv.VL\ntosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0\n"}, u'name': u'VNFD1'}} from (pid=4854) _parse_template_input /opt/stack/tacker/tacker/vnfm/plugin.py:218
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.839 DEBUG tacker.db.vnfm.vnfm_db [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] vnfd {'template_source': 'onboarded', u'service_types': [{u'service_type': u'vnfd'}], 'description': 'Demo example', 'tenant_id': u'e24b2a0887ae4ea3aa035e534544c58d', 'mgmt_driver': 'noop', u'attributes': {u'vnfd': "description: Demo example\nmetadata: {template_name: sample-tosca-vnfd}\ntopology_template:\n node_templates:\n CP1:\n properties: {anti_spoofing_protection: false, management: true, order: 0}\n requirements:\n - virtualLink: {node: VL1}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n CP2:\n properties: {anti_spoofing_protection: false, order: 1}\n requirements:\n - virtualLink: {node: VL2}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n CP3:\n properties: {anti_spoofing_protection: false, order: 2}\n requirements:\n - virtualLink: {node: VL3}\n - virtualBinding: {node: VDU1}\n type: tosca.nodes.nfv.CP.Tacker\n VDU1:\n capabilities:\n nfv_compute:\n properties: {disk_size: 1 GB, mem_size: 512 MB, num_cpus: 1}\n properties: {availability_zone: nova, config: 'param0: key1\n\n param1: key2\n\n ', image: cirros-0.3.5-x86_64-disk, mgmt_driver: noop}\n type: tosca.nodes.nfv.VDU.Tacker\n VL1:\n properties: {network_name: net_mgmt, vendor: Tacker}\n type: tosca.nodes.nfv.VL\n VL2:\n properties: {network_name: net0, vendor: Tacker}\n type: tosca.nodes.nfv.VL\n VL3:\n properties: {network_name: net1, vendor: Tacker}\n type: tosca.nodes.nfv.VL\ntosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0\n"}, u'name': u'VNFD1'} from (pid=4854) create_vnfd /opt/stack/tacker/tacker/db/vnfm/vnfm_db.py:241
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 ERROR tacker.api.v1.resource [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] create failed: No details.: DuplicateEntity: vnfd already exist with given ['tenant_id', 'name', 'deleted_at']
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource Traceback (most recent call last):
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource File "/opt/stack/tacker/tacker/api/v1/resource.py", line 77, in resource
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource result = method(request=request, **args)
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource File "/opt/stack/tacker/tacker/api/v1/base.py", line 393, in create
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource obj = obj_creator(request.context, **kwargs)
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource File "/opt/stack/tacker/tacker/vnfm/plugin.py", line 184, in create_vnfd
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource context, vnfd)
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource File "/opt/stack/tacker/tacker/db/vnfm/vnfm_db.py", line 281, in create_vnfd
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource entry=e.columns)
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource DuplicateEntity: vnfd already exist with given ['tenant_id', 'name', 'deleted_at']
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.935 TRACE tacker.api.v1.resource
Nov 24 15:59:27 dbopenstack-VirtualBox tacker-server[4854]: 2017-11-24 15:59:27.965 INFO tacker.wsgi [req-fd0aadb0-825c-4962-9b18-7f2b4a808c76 admin admin] 10.232.48.201 - - [24/Nov/2017 15:59:27] "POST /v1.0/vnfds.json HTTP/1.1" 500 356 0.243155

Looks like the exception 'DuplicateEntity' is derived from 'TackerException' which has status code 500.
There is a logic in 'convert_exception_to_http_exc' method [1] which checks whether the exception is from the defined exceptions in base.py [2].
If not it gives 500. I think as DuplicateEntity is the case of HTTPConflict, it should give 409 and not 500.

[1] https://github.com/openstack/tacker/blob/master/tacker/api/api_common.py#L335
[2] https://github.com/openstack/tacker/blob/master/tacker/api/v1/base.py#L32-L39

Environment:

devstack:
commit 2c9343e5db44fa7a41ca6924737331dd9088ef8f
Merge: 464d6e0 e8db867
Author: Zuul <email address hidden>
Date: Fri Oct 27 08:28:49 2017 +0000

    Merge "Change ENABLE_KSM to $ENABLE_KSM"

tacker:
commit a3a1f313c87f754f682df0e978ff48176a018c89
Merge: 17bf3d4 5a888e1
Author: Zuul <email address hidden>
Date: Mon Nov 20 19:45:52 2017 +0000

    Merge "[Bug-Fix] Add support for multiple classifiers per chain"

Changed in tacker:
assignee: nobody → Dinesh Bhor (dinesh-bhor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tacker (master)

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

Changed in tacker:
status: New → In Progress
Changed in tacker:
milestone: none → queens-2
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tacker (master)

Reviewed: https://review.openstack.org/523367
Committed: https://git.openstack.org/cgit/openstack/tacker/commit/?id=3fbf7a9ae03e84b509a306d5132b966fe5f25ddb
Submitter: Zuul
Branch: master

commit 3fbf7a9ae03e84b509a306d5132b966fe5f25ddb
Author: Dinesh Bhor <email address hidden>
Date: Thu Nov 23 18:22:14 2017 +0530

    Fix 500 when creating already on-boarded VNF

    If you on-board a VNF to tacker and try to on-board it again tacker
    gives 500 InternalServerError. The response message user get is
    correct but the response code returned is incorrect which is 500.

    message returned:
    "vnfd already exist with given ['tenant_id', 'name', 'deleted_at']"

    The type of a TackerError returned is 'DuplicateEntity' which has
    500 response code as it is derived from 'TackerException'.

    This patch changes the response code from 500 to 409 as this case
    is of HTTPConflict.

    This affects to below mentioned API's:
    * POST /v1.0/vnfds
    * POST /v1.0/vnfs
    * POST /v1.0/vims
    * POST /v1.0/nsds
    * POST /v1.0/nss

    NOTE:
    There are no existing unit test cases written for such API's.

    Closes-Bug: #1734316
    Change-Id: I7f63ab5f9612c2f32f0f11397ad0d6e3cee2f8d6

Changed in tacker:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tacker 0.9.0

This issue was fixed in the openstack/tacker 0.9.0 release.

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.