Change in vdsm[master]: vdsm: Try to reconnect on vmchannel after errors

asegurap at redhat.com asegurap at redhat.com
Fri Apr 12 16:45:36 UTC 2013


Antoni Segura Puimedon has posted comments on this change.

Change subject: vdsm: Try to reconnect on vmchannel after errors
......................................................................


Patch Set 13: I would prefer that you didn't submit this

(5 inline comments)

Some readability improvements.

....................................................
File vdsm/guestIF.py
Line 328:             while not self._stopped:
Line 329:                 data = self._sock.recv(2 ** 16)
Line 330:                 # The connection is broken when recv returns no data
Line 331:                 # therefore we're going to set ourself to stopped state
Line 332:                 if len(data) == 0:
I think this would be more pythonic (and cheaper) if it were:

if data:
    self._handleData(data)
else:
    self._stopped = True
    result = False
Line 333:                     self._stopped = True
Line 334:                     result = False
Line 335:                 else:
Line 336:                     self._handleData(data)


....................................................
File vdsm/vmChannels.py
Line 26: from storage.misc import NoIntrPoll
Line 27: 
Line 28: # How many times a reconnect should be performed before a cooldown will be
Line 29: # applied
Line 30: COOLDOWN_RECONNECT_TRESHOLD = 5
Typo? Shouldn't it be THRESHOLD?
Line 31: 
Line 32: 
Line 33: class Listener(threading.Thread):
Line 34:     """


Line 130:         """
Line 131:         now = time.time()
Line 132:         for (fileno, obj) in self._unconnected.items():
Line 133:             self.log.debug("Trying to connect fileno %d.", fileno)
Line 134:             if obj.get('cooldown', False):
If cooldown is not an object get will give None, which already has a False truthiness value. So no need to put False as param.
Line 135:                 if (now - obj['cooldown_time']) >= self._timeout:
Line 136:                     obj['cooldown'] = False
Line 137:                     self.log.log(logging.TRACE, "Reconnect attempt fileno "
Line 138:                                  "%d", fileno)


Line 131:         now = time.time()
Line 132:         for (fileno, obj) in self._unconnected.items():
Line 133:             self.log.debug("Trying to connect fileno %d.", fileno)
Line 134:             if obj.get('cooldown', False):
Line 135:                 if (now - obj['cooldown_time']) >= self._timeout:
If I'm not mistaken, the parenthesis is not strictly necessary, although it might help readability in this case.
Line 136:                     obj['cooldown'] = False
Line 137:                     self.log.log(logging.TRACE, "Reconnect attempt fileno "
Line 138:                                  "%d", fileno)
Line 139:                 else:


Line 150:                 del self._unconnected[fileno]
Line 151:                 self._channels[fileno] = obj
Line 152:                 obj['read_time'] = time.time()
Line 153:                 self._epoll.register(fileno, select.EPOLLIN)
Line 154:             elif success is False:
I think that this whole code addition (lines 148-160) would be clearer if we would get read of the None value of success and this "if success: blockA else: blockB" were placed inside an "else" to the except in line 145.
Line 155:                 obj['reconnects'] = obj.get('reconnects', 0) + 1
Line 156:                 if obj['reconnects'] >= COOLDOWN_RECONNECT_TRESHOLD:
Line 157:                     obj['cooldown_time'] = time.time()
Line 158:                     obj['cooldown'] = True


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8b9b9418e39558d45c97e9545bc9ecc4935f004e
Gerrit-PatchSet: 13
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Gal Hammer <ghammer at redhat.com>
Gerrit-Reviewer: Igor Lvovsky <ilvovsky at redhat.com>
Gerrit-Reviewer: Jason Dillaman <jdillama at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: Peter V. Saveliev <peet at redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list