ST crashing in add_rules for network policy

Bug #1560199 reported by amit surana
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juniper Openstack
Status tracked in Trunk
R3.0
Fix Committed
High
Praneet Bachheti
Trunk
Fix Committed
High
Praneet Bachheti

Bug Description

3.0 2726

convert list to set before attempting union. traceback:

<type 'exceptions.TypeError'>
Python 2.7.6: /usr/bin/python
Mon Mar 21 13:31:47 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/bin/contrail-schema in <module>()
    6
    7 if __name__ == '__main__':
    8 sys.exit(
    9 load_entry_point('schema-transformer==0.1dev', 'console_scripts', 'contrail-schema')()
   10 )
load_entry_point = <function load_entry_point>

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in server_main()
  829 def server_main():
  830 cgitb.enable(format='text')
  831 main()
  832 # end server_main
  833
global main = <function main>

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in main(args_str='--conf_file /etc/contrail/contrail-schema.conf -... --conf_file /etc/contrail/contrail-database.conf')
  823 _zookeeper_client.master_election(zk_path_pfx + "/schema-transformer",
  824 os.getpid(), run_schema_transformer,
  825 args)
  826 # end main
  827
args = Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181')

 /usr/lib/python2.7/dist-packages/cfgm_common/zkclient.py in master_election(self=<cfgm_common.zkclient.ZookeeperClient object>, path='/schema-transformer', identifier=23586, func=<function run_schema_transformer>, *args=(Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'),), **kwargs={})
  333 def master_election(self, path, identifier, func, *args, **kwargs):
  334 self._election = self._zk_client.Election(path, identifier)
  335 self._election.run(func, *args, **kwargs)
  336 # end master_election
  337
self = <cfgm_common.zkclient.ZookeeperClient object>
self._election = <kazoo.recipe.election.Election object>
self._election.run = <bound method Election.run of <kazoo.recipe.election.Election object>>
func = <function run_schema_transformer>
args = (Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'),)
kwargs = {}

 /usr/lib/python2.7/dist-packages/kazoo/recipe/election.py in run(self=<kazoo.recipe.election.Election object>, func=<function run_schema_transformer>, *args=(Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'),), **kwargs={})
   46 try:
   47 with self.lock:
   48 func(*args, **kwargs)
   49
   50 except CancelledError:
func = <function run_schema_transformer>
args = (Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'),)
kwargs = {}

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in run_schema_transformer(args=Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'))
  804
  805 global transformer
  806 transformer = SchemaTransformer(args)
  807 gevent.joinall(transformer._vnc_kombu.greenlets())
  808 # end run_schema_transformer
global transformer = None
global SchemaTransformer = <class 'schema_transformer.to_bgp.SchemaTransformer'>
args = Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181')

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in __init__(self=<schema_transformer.to_bgp.SchemaTransformer object>, args=Namespace(admin_password='contrail123', admin_te...:2181,192.168.1.239:2181', zk_server_port='2181'))
  211 DBBaseST._vnc_lib = _vnc_lib
  212 ServiceChain.init()
  213 self.reinit()
  214 # create cpu_info object to send periodic updates
  215 sysinfo_req = False
self = <schema_transformer.to_bgp.SchemaTransformer object>
self.reinit = <bound method SchemaTransformer.reinit of <schema_transformer.to_bgp.SchemaTransformer object>>

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in reinit(self=<schema_transformer.to_bgp.SchemaTransformer object>)
  429 RoutingInstanceST.locate(si_ri_name, si_ri_obj)
  430
  431 NetworkPolicyST.reinit()
  432 gevent.sleep(0.001)
  433 VirtualMachineInterfaceST.reinit()
global NetworkPolicyST = <class 'schema_transformer.config_db.NetworkPolicyST'>
NetworkPolicyST.reinit = <bound method __metaclass__.reinit of <class 'schema_transformer.config_db.NetworkPolicyST'>>

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in reinit(cls=<class 'schema_transformer.config_db.NetworkPolicyST'>)
   97 def reinit(cls):
   98 for obj in cls.list_vnc_obj():
   99 cls.locate(obj.get_fq_name_str(), obj)
  100 # reinit
  101
cls = <class 'schema_transformer.config_db.NetworkPolicyST'>
cls.locate = <bound method __metaclass__.locate of <class 'schema_transformer.config_db.NetworkPolicyST'>>
obj = <vnc_api.gen.resource_client.NetworkPolicy object>
obj.get_fq_name_str = <bound method NetworkPolicy.get_fq_name_str of <vnc_api.gen.resource_client.NetworkPolicy object>>

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in locate(cls=<class 'schema_transformer.config_db.NetworkPolicyST'>, key=u'default-domain:Vineet_Projects:pt_policy', *args=(<vnc_api.gen.resource_client.NetworkPolicy object>,))
  102 @classmethod
  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
obj undefined
builtinsuper = <type 'super'>
global DBBaseST = <class 'schema_transformer.config_db.DBBaseST'>
cls = <class 'schema_transformer.config_db.NetworkPolicyST'>
).locate = <bound method __metaclass__.locate of <class 'schema_transformer.config_db.NetworkPolicyST'>>
key = u'default-domain:Vineet_Projects:pt_policy'
args = (<vnc_api.gen.resource_client.NetworkPolicy object>,)

 /usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py in locate(cls=<class 'schema_transformer.config_db.NetworkPolicyST'>, key=u'default-domain:Vineet_Projects:pt_policy', *args=(<vnc_api.gen.resource_client.NetworkPolicy object>,))
   62 if key not in cls._dict:
   63 try:
   64 obj = cls(key, *args)
   65 cls._dict[key] = obj
   66 return obj
obj undefined
cls = <class 'schema_transformer.config_db.NetworkPolicyST'>
key = u'default-domain:Vineet_Projects:pt_policy'
args = (<vnc_api.gen.resource_client.NetworkPolicy object>,)

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in __init__(self=<schema_transformer.config_db.NetworkPolicyST object>, name=u'default-domain:Vineet_Projects:pt_policy', obj=<vnc_api.gen.resource_client.NetworkPolicy object>)
 1439 self.referred_policies = set()
 1440 # policies referring to this policy as src or dst
 1441 self.update(obj)
 1442 for vn_ref in self.obj.get_virtual_network_back_refs() or []:
 1443 vn_name = ':'.join(vn_ref['to'])
self = <schema_transformer.config_db.NetworkPolicyST object>
self.update = <bound method NetworkPolicyST.update of <schema_transformer.config_db.NetworkPolicyST object>>
obj = <vnc_api.gen.resource_client.NetworkPolicy object>

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in update(self=<schema_transformer.config_db.NetworkPolicyST object>, obj=<vnc_api.gen.resource_client.NetworkPolicy object>)
 1473 def update(self, obj=None):
 1474 self.obj = obj or self.read_vnc_obj(fq_name=self.name)
 1475 self.add_rules(self.obj.get_network_policy_entries())
 1476 # end update
 1477
self = <schema_transformer.config_db.NetworkPolicyST object>
self.add_rules = <bound method NetworkPolicyST.add_rules of <schema_transformer.config_db.NetworkPolicyST object>>
self.obj = <vnc_api.gen.resource_client.NetworkPolicy object>
self.obj.get_network_policy_entries = <bound method NetworkPolicy.get_network_policy_e...nc_api.gen.resource_client.NetworkPolicy object>>

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in add_rules(self=<schema_transformer.config_db.NetworkPolicyST object>, entries=<vnc_api.gen.resource_xsd.PolicyEntriesType object>)
 1490 si_set.add(prule.action_list.mirror_to.analyzer_name)
 1491 if prule.action_list.apply_service:
 1492 si_set = si_set.union(prule.action_list.apply_service)
 1493 for addr in prule.src_addresses + prule.dst_addresses:
 1494 if addr.network_policy:
si_set = set([])
si_set.union = <built-in method union of set object>
prule = <vnc_api.gen.resource_xsd.PolicyRuleType object>
prule.action_list = <vnc_api.gen.resource_xsd.ActionListType object>
prule.action_list.apply_service = [[u'default-domain:admin:pt_instance']]
<type 'exceptions.TypeError'>: unhashable type: 'list'
    __class__ = <type 'exceptions.TypeError'>
    __delattr__ = <method-wrapper '__delattr__' of exceptions.TypeError object>
    __dict__ = {}
    __doc__ = 'Inappropriate argument type.'
    __format__ = <built-in method __format__ of exceptions.TypeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of exceptions.TypeError object>
    __getitem__ = <method-wrapper '__getitem__' of exceptions.TypeError object>
    __getslice__ = <method-wrapper '__getslice__' of exceptions.TypeError object>
    __hash__ = <method-wrapper '__hash__' of exceptions.TypeError object>
    __init__ = <method-wrapper '__init__' of exceptions.TypeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of exceptions.TypeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of exceptions.TypeError object>
    __repr__ = <method-wrapper '__repr__' of exceptions.TypeError object>
    __setattr__ = <method-wrapper '__setattr__' of exceptions.TypeError object>
    __setstate__ = <built-in method __setstate__ of exceptions.TypeError object>
    __sizeof__ = <built-in method __sizeof__ of exceptions.TypeError object>
    __str__ = <method-wrapper '__str__' of exceptions.TypeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __unicode__ = <built-in method __unicode__ of exceptions.TypeError object>
    args = ("unhashable type: 'list'",)
    message = "unhashable type: 'list'"

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

Traceback (most recent call last):
  File "/usr/bin/contrail-schema", line 9, in <module>
    load_entry_point('schema-transformer==0.1dev', 'console_scripts', 'contrail-schema')()
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 831, in server_main
    main()
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 825, in main
    args)
  File "/usr/lib/python2.7/dist-packages/cfgm_common/zkclient.py", line 335, in master_election
    self._election.run(func, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/kazoo/recipe/election.py", line 48, in run
    func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 806, in run_schema_transformer
    transformer = SchemaTransformer(args)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 213, in __init__
    self.reinit()
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 431, in reinit
    NetworkPolicyST.reinit()
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 99, in reinit
    cls.locate(obj.get_fq_name_str(), obj)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 104, in locate
    obj = super(DBBaseST, cls).locate(key, *args)
  File "/usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py", line 64, in locate
    obj = cls(key, *args)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 1441, in __init__
    self.update(obj)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 1475, in update
    self.add_rules(self.obj.get_network_policy_entries())
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 1492, in add_rules
    si_set = si_set.union(prule.action_list.apply_service)
TypeError: unhashable type: 'list'

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

Review in progress for https://review.opencontrail.org/18584
Submitter: Sachin Bansal (<email address hidden>)

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

Review in progress for https://review.opencontrail.org/18585
Submitter: Sachin Bansal (<email address hidden>)

amit surana (asurana-t)
description: updated
description: updated
Revision history for this message
Sachin Bansal (sbansal) wrote :

apply_service was configured incorrectly as list of lists:
prule.action_list.apply_service = [[u'default-domain:admin:pt_instance']]

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

Heat is creating policies with incorrectly formatted action list.

Revision history for this message
Praneet Bachheti (praneetb) wrote :

The template being used by heat was wrong.
We have updated the example template in the contrail-heat repo

https://review.opencontrail.org/#/c/18577/

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.