Eduardo has uploaded a new change for review.

Change subject: BZ#854151 - Fix disconnect iscsi connections.
......................................................................

BZ#854151 - Fix disconnect iscsi connections.

Change-Id: I82f8680a3297da2ab8b766bfb7df9bde1cd20533
Signed-off-by: Eduardo <[email protected]>
---
M vdsm/storage/hsm.py
M vdsm/storage/storageServer.py
2 files changed, 25 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/8275/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index a89274a..330b7c0 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2032,10 +2032,11 @@
             conObj = storageServer.ConnectionFactory.createConnection(conInfo)
             try:
                 conObj.disconnect()
-                status = 0
             except Exception as err:
                 self.log.error("Could not disconnect from storageServer", 
exc_info=True)
                 status, _ = self._translateConnectionError(err)
+            else:
+                status = 0
 
             res.append({'id': conDef["id"], 'status': status})
 
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index a7dda01..f9e094a 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -282,6 +282,7 @@
         return hash(type(self)) ^ hash(self._mountCon)
 
 class IscsiConnection(object):
+    log = logging.getLogger("StorageServer.IscsiConnection")
     @property
     def target(self):
         return self._target
@@ -314,43 +315,45 @@
             host = self._target.portal.hostname
             try:
                 ip = socket.gethostbyname(host)
+            except socket.gaierror:
+                return False
+            else:
                 if ip != portal.hostname:
                     return False
 
-            except socket.gaierror:
-                return False
-
-        if self._target.portal.port != portal.port:
+        elif self._target.portal.port != portal.port:
             return False
 
-        if self._target.tpgt != target.tpgt:
+        elif self._target.iqn != target.iqn:
             return False
 
-        if self._target.iqn != target.iqn:
+        elif self._iface.name != iface.name:
             return False
 
-        if self._iface.name != iface.name:
+        elif self._cred != cred:
             return False
 
-        if self._cred != cred:
-            return False
-
-        return True
+        else:
+            return True
 
     def getSessionInfo(self):
         sessions = iscsi.iterateIscsiSessions()
         try:
             info = iscsi.getSessionInfo(self._lastSessionId)
-            sessions = chain(info, sessions)
         except Exception:
-            pass
+            self.log.warning("Can't get session info, self._lastSessionId %s", 
self._lastSessionId)
+        else:
+            sessions = chain(info, sessions)
 
-        for session in iscsi.iterateIscsiSessions():
+        self.log.debug("self._target: %s", self._target)
+        for session in sessions:
+            self.log.debug("session %s", session)
             if self.isSession(session):
                 self._lastSessionId = session.id
+                self.log.debug("self._lastSessionId: %s", self._lastSessionId)
                 return session
-
-        raise OSError(errno.ENOENT, "Session not found")
+        else:
+            raise OSError(errno.ENOENT, "Session not found in sessions: %s", 
sessions)
 
     def isConnected(self):
         try:
@@ -362,13 +365,17 @@
             raise
 
     def disconnect(self):
+        self.log.debug("Iscsi disconnect called.")
         try:
             sid = self.getSessionInfo().id
         except OSError, e:
             if e.errno == errno.ENOENT:
+                self.log.warning("Can't get iscsi session id, ENOENT: %s", 
e.errno)
                 return
+            self.log.warning("Cant get iscsi session id, errno: %s", e.errno)
             raise
 
+        self.log.debug("Disconnecting iscsi session id: %s", sid)
         iscsi.disconnectiScsiSession(sid)
 
     def __eq__(self, other):


--
To view, visit http://gerrit.ovirt.org/8275
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I82f8680a3297da2ab8b766bfb7df9bde1cd20533
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to