Comment 4 for bug 1463557

Revision history for this message
Surya Ghatty (ghatty) wrote :

Reply…

Patch Sets (5/5)

Download

"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 with
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(sh)
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.