]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Handle eqlx SSH connection close on abort.
authorSean McGinnis <sean_mcginnis@dell.com>
Fri, 26 Sep 2014 20:21:35 +0000 (15:21 -0500)
committerSean McGinnis <sean_mcginnis@dell.com>
Thu, 2 Oct 2014 15:35:34 +0000 (10:35 -0500)
EqualLogic array CLI operation timeout causes the
SSH thread to be aborted. This would cause SSH
sessions to be orphaned and hit a max connection
limit on the array. This fix catches these aborts
and makes sure the connection is closed.

Change-Id: I9392fd5dd79eb44f252bf50217f17cc473e6f2f0
Closes-Bug: 1374613

cinder/volume/drivers/eqlx.py

index ab54ca15620e1ac7e332f0f44ebd64da1854b6f2..a4a778c6790e0a7a6401e3cf72d2e60f050ebf42 100644 (file)
@@ -151,29 +151,36 @@ class DellEQLSanISCSIDriver(SanISCSIDriver):
     def _ssh_execute(self, ssh, command, *arg, **kwargs):
         transport = ssh.get_transport()
         chan = transport.open_session()
-        chan.invoke_shell()
+        completed = False
 
-        LOG.debug("Reading CLI MOTD")
-        self._get_output(chan)
-
-        cmd = 'stty columns 255'
-        LOG.debug("Setting CLI terminal width: '%s'.", cmd)
-        chan.send(cmd + '\r')
-        out = self._get_output(chan)
-
-        LOG.debug("Sending CLI command: '%s'.", command)
-        chan.send(command + '\r')
-        out = self._get_output(chan)
-
-        chan.close()
-
-        if any(line.startswith(('% Error', 'Error:')) for line in out):
-            desc = _("Error executing EQL command")
-            cmdout = '\n'.join(out)
-            LOG.error(cmdout)
-            raise processutils.ProcessExecutionError(
-                stdout=cmdout, cmd=command, description=desc)
-        return out
+        try:
+            chan.invoke_shell()
+
+            LOG.debug("Reading CLI MOTD")
+            self._get_output(chan)
+
+            cmd = 'stty columns 255'
+            LOG.debug("Setting CLI terminal width: '%s'", cmd)
+            chan.send(cmd + '\r')
+            out = self._get_output(chan)
+
+            LOG.debug("Sending CLI command: '%s'", command)
+            chan.send(command + '\r')
+            out = self._get_output(chan)
+
+            completed = True
+
+            if any(ln.startswith(('% Error', 'Error:')) for ln in out):
+                desc = _("Error executing EQL command")
+                cmdout = '\n'.join(out)
+                LOG.error(cmdout)
+                raise processutils.ProcessExecutionError(
+                    stdout=cmdout, cmd=command, description=desc)
+            return out
+        finally:
+            if not completed:
+                LOG.debug("Timed out executing command: '%s'", command)
+            chan.close()
 
     def _run_ssh(self, cmd_list, attempts=1):
         utils.check_ssh_injection(cmd_list)
@@ -295,11 +302,11 @@ class DellEQLSanISCSIDriver(SanISCSIDriver):
         and returns the correct connection id.
         """
         lines = [line for line in out if line != '']
-        #Every record has 2 lines
+        # Every record has 2 lines
         for i in xrange(0, len(lines), 2):
             try:
                 int(lines[i][0])
-                #sanity check
+                # sanity check
                 if len(lines[i + 1].split()) == 1:
                     check = lines[i].split()[1] + lines[i + 1].strip()
                     if connector['initiator'] == check: