r48418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48417‎ | r48418 | r48419 >
Date:16:16, 15 March 2009
Author:mark
Status:ok
Tags:
Comment:
Fix bug where reenabled servers would not be set back up and repooled after configuration merge
Modified paths:
  • /trunk/pybal/pybal/monitors/__init__.py (modified) (history)
  • /trunk/pybal/pybal/monitors/__skeleton__.py (added) (history)
  • /trunk/pybal/pybal/monitors/idleconnection.py (modified) (history)
  • /trunk/pybal/pybal/pybal.py (modified) (history)

Diff [purge]

Index: trunk/pybal/pybal/monitors/idleconnection.py
@@ -56,6 +56,8 @@
5757 # Immediately set status to down
5858 self._resultDown(reason.getErrorMessage())
5959
 60+ self.report("Connection failed.")
 61+
6062 # Slowly reconnect
6163 self.retry(connector)
6264
@@ -70,6 +72,8 @@
7173 # Connection lost in a non clean way. Immediately set status to down
7274 self._resultDown(reason.getErrorMessage())
7375
 76+ self.report("Connection lost.")
 77+
7478 # Slowly reconnect
7579 self.retry(connector)
7680
@@ -81,6 +85,8 @@
8286
8387 # Reset reconnection delay
8488 self.resetDelay()
 89+
 90+ self.report("Connection established.")
8591
8692 def buildProtocol(self, addr):
8793 """
Index: trunk/pybal/pybal/monitors/__init__.py
@@ -7,4 +7,4 @@
88 $Id$
99 """
1010
11 -__all__ = [ 'proxyfetch', 'idleconnection', 'runcommand' ]
\ No newline at end of file
 11+__all__ = [ 'proxyfetch', 'idleconnection', 'runcommand', 'vipping' ]
\ No newline at end of file
Index: trunk/pybal/pybal/monitors/__skeleton__.py
@@ -0,0 +1,38 @@
 2+"""
 3+__skeleton__.py
 4+Copyright (C) 2006-2008 by Mark Bergsma <mark@nedworks.org>
 5+
 6+Copy and modify this file to write a new PyBal monitor.
 7+It contains the minimum imports and base methods that need
 8+to be implemented.
 9+
 10+$Id$
 11+"""
 12+
 13+from pybal import monitor
 14+
 15+from twisted.internet import reactor
 16+
 17+class SkeletonMonitoringProtocol(monitor.MonitoringProtocol):
 18+ """
 19+ Description.
 20+ """
 21+
 22+ __name__ = 'Skeleton'
 23+
 24+ def __init__(self, coordinator, server, configuration):
 25+ """Constructor"""
 26+
 27+ # Call ancestor constructor
 28+ super(SkeletonMonitoringProtocol, self).__init__(coordinator, server, configuration)
 29+
 30+ # Install cleanup handler
 31+ reactor.addSystemEventTrigger('before', 'shutdown', self.stop)
 32+
 33+ def run(self):
 34+ """Start the monitoring"""
 35+ pass
 36+
 37+ def stop(self):
 38+ """Stop the monitoring"""
 39+ pass
Index: trunk/pybal/pybal/pybal.py
@@ -210,7 +210,18 @@
211211 # Hand over enabled servers to LVSService
212212 self.lvsservice.assignServers(
213213 set([server for server in self.servers.itervalues() if server.pooled]))
 214+
 215+ def refreshModifiedServers(self):
 216+ """
 217+ Calculates the status of every server that existed before the config change.
 218+ """
214219
 220+ for server in self.servers.itervalues():
 221+ if not server.modified: continue
 222+
 223+ server.up = server.calcStatus()
 224+ server.pooled = server.enabled and server.up
 225+
215226 def resultDown(self, monitor, reason=None):
216227 """
217228 Accepts a 'down' notification status result from a single monitoring instance
@@ -343,6 +354,9 @@
344355 server.destroy()
345356 del self.servers[host]
346357
 358+ # Calculate up status for previously existing, modified servers
 359+ self.refreshModifiedServers()
 360+
347361 # Assign the updated list of enabled servers to the LVSService instance
348362 self.assignServers()
349363

Status & tagging log