]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Fix sshpool.remove code
authorSurya Ghatty <ghatty@us.ibm.com>
Fri, 26 Feb 2016 19:49:24 +0000 (19:49 +0000)
committerSurya Ghatty <ghatty@us.ibm.com>
Tue, 1 Mar 2016 03:20:04 +0000 (03:20 +0000)
commitb4f63203ffa32e6ce2f678cdf6287621eeff2c59
tree8d0d72fd20960b9722bcec2ca710f42bbcd3356a
parent71388796d3280a3800b6c034d5d415ed7ca647f5
Fix sshpool.remove code

Currently, sshpool.remove function under cinder/ssh_utils.py
is broken. The function tries to locate the passed in
sshclient object inside sshpool.free_items.

However, since the sshclient object is set to “None” at the
beginning, it never finds the object and ends up decrementing
 the current size, without actually removing the object.

Made the following changes to fix:
1. Removed reset to ‘None’ so that the attempt to locate object
goes through.
2. Fixed the code to use free_items.remove(ssh) to remove the ssh
object identified instead of free_items.pop(ssh)
3. Also updated the code to decrement current size only if a match
is found in free_items.
4. Added test case to test remove() of an ssh client that is in the
free_items
5. Added test case to test that remove code does not inadvertently
remove an object from the pool if no match is found.

Change-Id: I4871f4faeb1fc790325f274ab21dc42a8d71fb26
Closes-Bug: #1463557
cinder/ssh_utils.py
cinder/tests/unit/test_ssh_utils.py