]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
HNAS driver: retry on Connection reset fix
authorAdriano Rosso <adriano.rosso@fit-tecnologia.org.br>
Thu, 4 Feb 2016 16:18:17 +0000 (14:18 -0200)
committerAdriano Rosso <adriano.rosso@fit-tecnologia.org.br>
Thu, 4 Feb 2016 17:54:44 +0000 (15:54 -0200)
When HNAS driver is not using the SSH option and there are lots of exports in
the backend, a exception of "Connection reset" is eventually raised in the
driver initialization.
This patch makes the HNAS driver retries when this exception is raised.

Change-Id: Ia6306d5d2d24556135505ddc33174f57c86d8555
Closes-Bug: 1541941

cinder/tests/unit/test_hitachi_hnas_backend.py
cinder/volume/drivers/hitachi/hnas_backend.py

index 64f2f672bf9c54a66227a977719becbe2c1d21df..fe2872653a9a96b2019db6d81cd4beb927d428d9 100644 (file)
@@ -240,6 +240,8 @@ File System : fs1                     \n\
 File System Mounted : YES             \n\
 Logical Unit Mounted: No"
 
+HNAS_RESULT27 = "Connection reset"
+
 
 HNAS_CMDS = {
     ('ssh', '0.0.0.0', 'supervisor', 'supervisor', 'evsfs', 'list'):
@@ -376,6 +378,14 @@ class HDSHNASBendTest(test.TestCase):
                           'ssh', '0.0.0.0', 'supervisor', 'supervisor',
                           'df', '-a')
 
+        m_utl.side_effect = putils.ProcessExecutionError(stdout='',
+                                                         stderr=HNAS_RESULT27,
+                                                         exit_code=255)
+        self.hnas_bend.drv_configs['ssh_enabled'] = 'False'
+        self.assertRaises(exception.HNASConnError, self.hnas_bend.run_cmd,
+                          'ssh', '0.0.0.0', 'supervisor', 'supervisor',
+                          'df', '-a')
+
         # Test exception throwing when using SSH
         m_ssh.side_effect = putils.ProcessExecutionError(stdout='',
                                                          stderr=HNAS_RESULT22,
index 61877aa2fd83560d1e456a590da72a930d8360ab..a72dff9418cd750976d6997a04cd2021a842d92e 100644 (file)
@@ -68,8 +68,12 @@ class HnasBackend(object):
                     LOG.debug("SSC connection error!")
                     msg = _("Failed to establish SSC connection.")
                     raise exception.HNASConnError(msg)
+                elif 'Connection reset' in e.stderr:
+                    LOG.debug("HNAS connection reset!")
+                    msg = _("HNAS has disconnected SSC")
+                    raise exception.HNASConnError(msg)
                 else:
-                    raise putils.ProcessExecutionError
+                    raise
 
         else:
             if self.drv_configs['cluster_admin_ip0'] is None: