Eduardo has uploaded a new change for review.
Change subject: Related to BZ#854151 - Fix disconnect iscsi connections.
......................................................................
Related to BZ#854151 - Fix disconnect iscsi connections.
Change-Id: Ic390cf1a63594a87ee03c010df31f68a432ebff4
Bug-Id:
https://bugzilla.redhat.com/show_bug.cgi?id=854151
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/storageServer.py
2 files changed, 26 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/8305/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 269b8eb..963a019 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,48 @@
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 != None and self._target.tpgt != target.tpgt:
+ elif self._target.tpgt != None and self._target.tpgt != target.tpgt:
return False
- if self._target.iqn != target.iqn:
+ elif self._target.iqn != target.iqn:
return False
- if self._iface.name != iface.name:
+ elif self._iface.name != iface.name:
return False
- if self._cred != cred:
+ elif 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 +368,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/8305
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic390cf1a63594a87ee03c010df31f68a432ebff4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>