Before indexing reference, it should check whether the python list data type is empty in order to make the code more robust

Bug #1627565 reported by Janice-Chen
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
In Progress
Undecided
tianhui

Bug Description

I used the 'trove cluster-create' cli build a mongodb cluster named 'c1', then used 'trove cluster-instance c1' to see the cluster intances informations.i got the error below in the log file:

Error: "/usr/lib/python2.7/site-packages/trove/taskmanager/models.py", line 207, in get_ip\n return instance.get_visible_ip_addresses()[0]\n', 'IndexError: list index out of range\n']

Finally, i figure out that the error is caused by my improper network configuration, I got get_visible_ip_addresses() return None. and then triggered the error.

it's obviously the get_visible_ip_addresses() function will return 'None' or a IP list , so it should check the return value before indexing reference in in order to make the code more robust

Changed in trove:
assignee: nobody → Janice-Chen (784059080-c)
summary: - Python list type data before indexing reference should check whether the
- List is empty in order to make the code more robust
+ Before indexing reference, it should check whether the python list data
+ type is empty in order to make the code more robust
Revision history for this message
Javier Castillo (javcasalc) wrote :

With trove/ocata over ubuntu/xenial, this bug also arises when deploying mariadb/galera cluster:

2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server Traceback (most recent call last):
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 155, in _process_incoming
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 222, in dispatch
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 192, in _do_dispatch
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/osprofiler/profiler.py", line 153, in wrapper
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server return f(*args, **kwargs)
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/trove/taskmanager/manager.py", line 395, in create_cluster
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server cluster_tasks.create_cluster(context, cluster_id)
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py", line 141, in create_cluster
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server _create_cluster()
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/trove/common/strategies/cluster/experimental/galera_common/taskmanager.py", line 88, in _create_cluster
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server cluster_ips = [self.get_ip(instance) for instance in instances]
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/local/lib/python2.7/site-packages/trove/taskmanager/models.py", line 215, in get_ip
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server return instance.get_visible_ip_addresses()[0]
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server IndexError: list index out of range
2017-07-07 12:41:24.250 7 ERROR oslo_messaging.rpc.server

Amrith Kumar (amrith)
Changed in trove:
status: New → Invalid
Revision history for this message
tianhui (tianhui) wrote :
Download full text (3.8 KiB)

When I create a mongodb cluster, I appoint a network for the member instance, then it cuase the error:list index out of range
2017-09-11 14:14:14.840 7143 DEBUG trove.common.notification [-] Sending event: dbaas.cluster_create.error, {'client_ip': u'192.168.133.49', 'server_type': u'taskmanager', 'tenant_id': u'8129167d1c2e4647a6404ca3426c51f1', 'exception': ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/trove/taskmanager/manager.py", line 384, in create_cluster\n cluster_tasks.create_cluster(context, cluster_id)\n', ' File "/usr/lib/python2.7/site-packages/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py", line 119, in create_cluster\n _create_cluster()\n', ' File "/usr/lib/python2.7/site-packages/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py", line 102, in _create_cluster\n for instance in config_servers]\n', ' File "/usr/lib/python2.7/site-packages/trove/taskmanager/models.py", line 207, in get_ip\n return instance.get_visible_ip_addresses()[0]\n', 'IndexError: list index out of range\n'], 'server_ip': u'192.168.133.49:8779', 'request_id': u'req-5d7f9ca3-7498-4c98-bc81-8ba6ac6a0512', 'message': 'list index out of range'} _notify /usr/lib/python2.7/site-packages/trove/common/notification.py:391
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher [-] Exception during message handling: list index out of range
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher Traceback (most recent call last):
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 138, in _dispatch_and_reply
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher incoming.message))
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 185, in _dispatch
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher return self._do_dispatch(endpoint, method, ctxt, args)
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 127, in _do_dispatch
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher result = func(ctxt, **new_args)
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/osprofiler/profiler.py", line 117, in wrapper
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher return f(*args, **kwargs)
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/trove/taskmanager/manager.py", line 384, in create_cluster
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher cluster_tasks.create_cluster(context, cluster_id)
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/trove/common/strategies/cluster/experimental/mongodb/taskmanager.py", line 119, in create_cluster
2017-09-11 14:14:14.841 7143 ERROR oslo_messaging.rpc.dispatcher _create_cluster()
2017-09-11 14:14:14.841 ...

Read more...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

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

Changed in trove:
assignee: Janice-Chen (784059080-c) → tianhui (tianhui)
status: Invalid → In Progress
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.