]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix eqlx endless loop when server closes the connection
authorDunrong Huang <riegamaths@gmail.com>
Wed, 14 Jan 2015 05:56:43 +0000 (13:56 +0800)
committerEric Harney <eharney@redhat.com>
Thu, 15 Jan 2015 20:10:59 +0000 (15:10 -0500)
The eqlx driver would identify one CLI command completion by looking
for the system name prompt in the output ("ARRAY_NAME>"). But some
cases where there is no "ARRAY_NAME>" in the output. The eqlx server
closes the ssh connection immediately after sends such message, which
lead to a infinite loop in _get_output() and 100% CPU utilization.

What the patch does is to check the return of chan.recv(), if the
length of returned string is zero, which means server has closed the
connection, the loop will be exited.

Closes-Bug: #1410627

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Change-Id: I600c38d98f0f808c98df010a89ac58ca8e43f1a3

cinder/volume/drivers/eqlx.py

index 6462219018ac44cfa5aaa48823b54888b1c40f49..7739b5111a1ba74cb07f53089e47fe602f5903a8 100644 (file)
@@ -136,7 +136,16 @@ class DellEQLSanISCSIDriver(SanISCSIDriver):
         out = ''
         ending = '%s> ' % self.configuration.eqlx_group_name
         while out.find(ending) == -1:
-            out += chan.recv(102400)
+            ret = chan.recv(102400)
+            if len(ret) == 0:
+                # According to paramiko.channel.Channel documentation, which
+                # says "If a string of length zero is returned, the channel
+                # stream has closed". So we can confirm that the EQL server
+                # has closed the connection.
+                msg = _("The EQL array has closed the connection.")
+                LOG.error(msg)
+                raise processutils.ProcessExecutionError(description=msg)
+            out += ret
 
         LOG.debug("CLI output\n%s", out)
         return out.splitlines()