virtual_network_update fails after del_network_ipam

Bug #1381074 reported by Jacek Świderski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenContrail
Triaged
Undecided
Hampapur Ajay

Bug Description

If you try to update virtual network with information that network_ipam was deleted it will fail.

Reproduction :

vnc_lib - VncApi object
>>> vn_blue_obj = VirtualNetwork('vn-blue')
>>> _vnc_lib.virtual_network_create(vn_blue_obj)
u'97233eaf-94f2-4681-853e-2bb933837ee0'
>>> vn_obj = _vnc_lib.virtual_network_read(id="97233eaf-94f2-4681-853e-2bb933837ee0")
>>> vn_obj.add_network_ipam(NetworkIpam(),VnSubnetsType([IpamSubnetType(subnet = SubnetType('10.1.1.0', 24))]))
>>> _vnc_lib.virtual_network_update(vn_obj)
u'{"virtual-network": {"href": "http://127.0.0.1:8082/virtual-network/97233eaf-94f2-4681-853e-2bb933837ee0", "uuid": "97233eaf-94f2-4681-853e-2bb933837ee0"}}'
>>> vn_obj_upd = _vnc_lib.virtual_network_read(id="97233eaf-94f2-4681-853e-2bb933837ee0")
>>> vn_obj_upd.del_network_ipam(NetworkIpam())
>>> _vnc_lib.virtual_network_update(vn_obj_upd)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/vnc_api/gen/vnc_api_client_gen.py", line 4858, in virtual_network_update
    self.ref_update('virtual-network', obj.uuid, ref_name, ref[0], list(ref[1]), 'DELETE')
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 371, in ref_update
    raise he
cfgm_common.exceptions.HttpError: HTTP Status: 500 Content: Internal Server Error

full stacktrace from screen-apiSrv.log http://pastebin.com/thpx2Bn4

Tags: api config
Revision history for this message
Pedro Marques (5-roque) wrote :

AFAIK,
The problem here comes from the fact that the example in the docs is incorrect.

To create a subnet, we need to provide a specific IPAM.
Thie example:
   vn_obj.add_network_ipam(NetworkIpam(),VnSubnetsType([IpamSubnetType(subnet = SubnetType('10.1.1.0', 24))]))

is using a NetworkIpam() object that is transient. The code will work if the client looks for an existing Ipam object (such as the default-ipam). It is unclear to me whether this results in a transient Ipam() actually being created by the API server.

The delete with another transient object will fail.

This should be a documentation bug, AFAIK. Ajay, please confirm.

Changed in opencontrail:
assignee: nobody → Hampapur Ajay (hajay)
status: New → Opinion
status: Opinion → Triaged
Revision history for this message
Jacek Świderski (jacek-swiderski) wrote :

To follow up - I've tried it with default-network-ipam and the same thing happened :

>>> from vnc_api.vnc_api import *
>>> vnc = VncApi("admin",'contrail123',"admin","127.0.0.1","8082","/")
>>> vnc.network_ipams_list()
{u'network-ipams': [{u'href': u'http://127.0.0.1:8082/network-ipam/f9b58449-f9bc-4134-a2b1-a1a00582f404', u'fq_name': [u'default-domain', u'default-project', u'default-network-ipam'], u'uuid': u'f9b58449-f9bc-4134-a2b1-a1a00582f404'}]}
>>> ipam = vnc.network_ipam_read(id="f9b58449-f9bc-4134-a2b1-a1a00582f404")
>>> vn_blue_obj = VirtualNetwork('vn-blue')
>>> vnc.virtual_network_create(vn_blue_obj)
u'a2090cf8-a2a7-4e37-9084-485cb400287e'
>>> vn_obj = vnc.virtual_network_read(id='a2090cf8-a2a7-4e37-9084-485cb400287e')
>>> vn_obj.add_network_ipam(ipam,VnSubnetsType([IpamSubnetType(subnet = SubnetType('10.1.1.0', 24))]))
>>> vnc.virtual_network_update(vn_obj)
u'{"virtual-network": {"href": "http://127.0.0.1:8082/virtual-network/a2090cf8-a2a7-4e37-9084-485cb400287e", "uuid": "a2090cf8-a2a7-4e37-9084-485cb400287e"}}'
>>> vn_obj_upd = vnc.virtual_network_read(id='a2090cf8-a2a7-4e37-9084-485cb400287e')
>>> vn_obj_upd.del_network_ipam(ipam)
>>> vnc.virtual_network_update(vn_obj_upd)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/vnc_api/gen/vnc_api_client_gen.py", line 4858, in virtual_network_update
    self.ref_update('virtual-network', obj.uuid, ref_name, ref[0], list(ref[1]), 'DELETE')
  File "/usr/lib/python2.7/dist-packages/vnc_api/vnc_api.py", line 371, in ref_update
    raise he
cfgm_common.exceptions.HttpError: HTTP Status: 500 Content: Internal Server Error

Revision history for this message
Sachin Bansal (sbansal) wrote :

I tried exact same steps on 1.1 build 55 and I did not see the traceback. Which build did you use? Can you try it on latest?

My console output is below:
>>> from vnc_api import vnc_api
>>> _vnc_lib=vnc_api.VncApi()
>>> from vnc_api.vnc_api import *
>>> vn_blue_obj = VirtualNetwork('vn-blue')
>>> _vnc_lib.virtual_network_create(vn_blue_obj)
u'0fae40b0-de3b-491c-8068-83c61f5fc86d'
>>> vn_obj = _vnc_lib.virtual_network_read(id='0fae40b0-de3b-491c-8068-83c61f5fc86d')
>>> vn_obj.add_network_ipam(NetworkIpam(),VnSubnetsType([IpamSubnetType(subnet = SubnetType('10.1.1.0', 24))]))
>>> _vnc_lib.virtual_network_update(vn_obj)
u'{"virtual-network": {"href": "http://127.0.0.1:8082/virtual-network/0fae40b0-de3b-491c-8068-83c61f5fc86d", "uuid": "0fae40b0-de3b-491c-8068-83c61f5fc86d"}}'
>>> vn_obj_upd = _vnc_lib.virtual_network_read(id="0fae40b0-de3b-491c-8068-83c61f5fc86d")
>>> vn_obj_upd.network_ipam_refs
[{u'to': [u'default-domain', u'default-project', u'default-network-ipam'], u'href': u'http://127.0.0.1:8082/network-ipam/1f463ab6-8c56-4038-a858-b71af46215db', u'attr': <vnc_api.gen.resource_xsd.VnSubnetsType object at 0x2b67410>, u'uuid': u'1f463ab6-8c56-4038-a858-b71af46215db'}]
>>> vn_obj_upd.del_network_ipam(NetworkIpam())
>>> vn_obj_upd.network_ipam_refs
[]
>>> _vnc_lib.virtual_network_update(vn_obj_upd)
u'{"virtual-network": {"href": "http://127.0.0.1:8082/virtual-network/0fae40b0-de3b-491c-8068-83c61f5fc86d", "uuid": "0fae40b0-de3b-491c-8068-83c61f5fc86d"}}'
>>>

Revision history for this message
Jacek Świderski (jacek-swiderski) wrote :

I'm using Juniper/contrail-installer master branch with CONTRAIL_DEFAULT_INSTALL=True, I'm not sure which version is it - I'd appreciate if you pointed me how to easily check which version I'm currently using - and since it seems to be the case that I'm using older one (because it doesn't work for me) - how to use newer versions (1.1 build 55 suggests that it's existing build and not local sources build) ?

Revision history for this message
Pedro Marques (5-roque) wrote :

Sachin,
Your output has:
    vn_obj_upd.del_network_ipam(NetworkIpam())

AFAIK this should never do anything. This is a transient object that is being created that is not in the list.

Can you please try with the example given by Jacek ?

tags: added: api config
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.