Schema fails to locate resource which does not exist

Bug #1567267 reported by Édouard Thuleau
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Juniper Openstack
Status tracked in Trunk
R3.0
Fix Committed
Undecided
Ranjeet R
Trunk
Fix Committed
Undecided
Unassigned
OpenContrail
Fix Committed
Undecided
Unassigned

Bug Description

<type 'exceptions.AttributeError'>
Python 2.7.6: /usr/bin/python
Thu Apr 7 09:01:39 2016

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in _vnc_subscribe_callback(self=<schema_transformer.to_bgp.SchemaTransformer object>, oper_info={u'imid': u'contrail:virtual-machine:4bd18739-b9b4-4492-afcf-f21ded2992e3', u'obj_dict': {u'display_name': u'4bd18739-b9b4-4492-afcf-f21ded2992e3', u'fq_name': [u'4bd18739-b9b4-4492-afcf-f21ded2992e3'], u'id_perms': {u'created': u'2016-04-07T03:31:06.032467', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-04-07T03:31:06.032467', u'permissions': {u'group': u'cloud-admin-group', u'group_access': 7, u'other_access': 7, u'owner': u'cloud-admin', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 1266861function calls leading up to the error, in the order they occurred.

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in _vnc_subscribe_callback(self=<schema_transformer.to_bgp.SchemaTransformer object>, oper_info={u'imid': u'contrail:instance-ip:9873d924-342e-4887-a761-ef0ffeda186b', u'obj_dict': {u'display_name': u'9873d924-342e-4887-a761-ef0ffeda186b', u'fq_name': [u'9873d924-342e-4887-a761-ef0ffeda186b'], u'id_perms': {u'created': u'2016-04-07T03:31:06.165456', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-04-07T03:31:06.165456', u'permissions': {u'group': u'cloud-admin-group', u'group_access': 7, u'other_access': 7, u'owner': u'cloud-admin', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 12061184129054152811L, u'uuid_mslong': 10985362665604270215L}}, u'instance_ip_address': u'22.1.1.3', u'instance_ip_family': u'v4', u'perms2': {u'global_access': 0, u'owner': u'ada85374009044c09e519c3aa82b6e30', u'owner_access': 7, u'share': []}, u'uuid': u'9873d924-342e-4887-a761-ef0ffeda186b', u'virtual_machine_interface_refs': [{u'to': [u'default-domain', u'ctest-AnalyticsTestSanity-75523953', u'd8c299e2-ae1f-42f3-810a-6511ac1b890e'], u'uuid': u'd8c299e2-ae1f-42f3-810a-6511ac1b890e'}], u'virtual_network_refs': [{u'to': [u'default-domain', u'ctest-AnalyticsTestSanity-75523953', u'vn22'], u'uuid': u'2db44dd6-f301-458b-afc5-99c77cfb5a9b'}]}, u'oper': u'CREATE', u'parent_imid': u'contrail:config-root:root', u'request-id': u'req-0bba2014-a499-4d36-85d5-27c37fb2085c', u'type': u'instance-ip', u'uuid': u'9873d924-342e-4887-a761-ef0ffeda186b'})
  245 operation=oper, uuid=obj_id)
  246 if oper == 'CREATE':
  247 obj = obj_class.locate(obj_fq_name)
  248 if obj is None:
  250 self.config_log('%s id %s fq_name %s not found' % (
obj undefined
obj_class = <class 'schema_transformer.config_db.InstanceIpST'>
obj_class.locate = <bound method __metaclass__.locate of <class 'schema_transformer.config_db.InstanceIpST'>>
obj_fq_name = u'9873d924-342e-4887-a761-ef0ffeda186b'

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in locate(cls=<class 'schema_transformer.config_db.InstanceIpST'>, key=u'9873d924-342e-4887-a761-ef0ffeda186b', *args=())
  103 def locate(cls, key, *args):
  104 obj = super(DBBaseST, cls).locate(key, *args)
  105 if obj.obj.uuid not in cls._uuid_fq_name_map:
  106 cls._uuid_fq_name_map[obj.obj.uuid] = key
  107 return obj
obj = None
obj.obj undefined
cls = <class 'schema_transformer.config_db.InstanceIpST'>
cls._uuid_fq_name_map = {u'00b6fcda-0ecf-49f8-8deb-4d72f9215f03': u'default-domain:ctest-TestPorts-49976049:00b6fcda-0ecf-49f8-8deb-4d72f9215f03', u'01585757-a59f-42bd-aaca-22341050613b': u'default-domain:ctest-AnalyticsTestSanityWithRe...ce-70403667:01585757-a59f-42bd-aaca-22341050613b', '020defd7-e58d-4739-8490-9d86120931c6': u'default-domain:ctest-TestBasicIPv6VMVN0-93128626:default', u'065c9201-5670-471a-9802-43829e787581': u'default-domain:ctest-CeilometerTest-39891020:default', u'071c69c0-3ebc-4adb-9eae-bec16b253812': u'default-domain:ctest-TestBasicPolicyConfig-34526889:071c69c0-3ebc-4adb-9eae-bec16b253812', u'07da96a2-6409-4bf9-b2ee-d315fb363db5': u'default-domain:ctest-AnalyticsTestSanity-92826701:default', u'07e1af6f-5756-4d7a-890e-5e11ef2f558d': u'default-domain:admin:net1:net1', u'08781e70-0109-4842-a66a-3af52cab9a92': u'default-domain:ctest-TestPorts-16266333:ctest-mgmt-vn-75174624:ctest-mgmt-vn-75174624', u'092266be-3a02-438e-9c66-e559714c06f9': u'target:64001:8000019', u'09fb0f1c-9a25-4e5e-a740-9549c35402d9': u'default-domain:ctest-TestPorts-16266333:ctest-right-vn-58323495', ...}
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'obj'
    __class__ = <type 'exceptions.AttributeError'>
    __delattr__ = <method-wrapper '__delattr__' of exceptions.AttributeError object>
    __dict__ = {}
    __doc__ = 'Attribute not found.'
    __format__ = <built-in method __format__ of exceptions.AttributeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of exceptions.AttributeError object>
    __getitem__ = <method-wrapper '__getitem__' of exceptions.AttributeError object>
    __getslice__ = <method-wrapper '__getslice__' of exceptions.AttributeError object>
    __hash__ = <method-wrapper '__hash__' of exceptions.AttributeError object>
    __init__ = <method-wrapper '__init__' of exceptions.AttributeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of exceptions.AttributeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of exceptions.AttributeError object>
    __repr__ = <method-wrapper '__repr__' of exceptions.AttributeError object>
    __setattr__ = <method-wrapper '__setattr__' of exceptions.AttributeError object>
    __setstate__ = <built-in method __setstate__ of exceptions.AttributeError object>
    __sizeof__ = <built-in method __sizeof__ of exceptions.AttributeError object>
    __str__ = <method-wrapper '__str__' of exceptions.AttributeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __unicode__ = <built-in method __unicode__ of exceptions.AttributeError object>
    args = ("'NoneType' object has no attribute 'obj'",)
    message = "'NoneType' object has no attribute 'obj'"

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 247, in _vnc_subscribe_callback
    obj = obj_class.locate(obj_fq_name)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 105, in locate
    if obj.obj.uuid not in cls._uuid_fq_name_map:
AttributeError: 'NoneType' object has no attribute 'obj'

Tags: config
Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] master

Review in progress for https://review.opencontrail.org/19139
Submitter: Édouard Thuleau (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/19139
Committed: http://github.org/Juniper/contrail-controller/commit/9269e9a67b2a23e874791ffbf5a857259ca22d9c
Submitter: Zuul
Branch: master

commit 9269e9a67b2a23e874791ffbf5a857259ca22d9c
Author: Édouard Thuleau <email address hidden>
Date: Thu Apr 7 10:14:55 2016 +0200

[schema] Return None if cannot locate resource

When the schema locates a resource from database, it stores the
id/fq_name mapping in memory but in case the resource does not
exist, it tries to get id from a None value that results to
'AttributeError' exception.

Closes-bug: #1567267

Change-Id: If9387252b9da9093a939651fed8f7a5cbb09be04

Sachin Bansal (sbansal)
Changed in opencontrail:
status: New → Fix Committed
Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] R3.0

Review in progress for https://review.opencontrail.org/20569
Submitter: Ranjeet R (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/20569
Committed: http://github.org/Juniper/contrail-controller/commit/0c4ef638f0c538164dd8fc2e5134087bd78779fc
Submitter: Zuul
Branch: R3.0

commit 0c4ef638f0c538164dd8fc2e5134087bd78779fc
Author: Ranjeet R <email address hidden>
Date: Tue May 24 10:45:01 2016 -0700

Fixes: [schema] Return None if cannot locate resource

When the schema locates a resource from database, it stores the
id/fq_name mapping in memory but in case the resource does not
exist, it tries to get id from a None value that results to
'AttributeError' exception.

Change-Id: I4aa5ceaf0aad01ee5f24d04223a78155418aa4ba
Closes-bug: 1567267

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.