[CalendarServer-changes] [7822] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jul 22 13:41:05 PDT 2011
Revision: 7822
http://trac.macosforge.org/projects/calendarserver/changeset/7822
Author: sagen at apple.com
Date: 2011-07-22 13:41:04 -0700 (Fri, 22 Jul 2011)
Log Message:
-----------
Enables memcached use within master process, gets rid of addSystemEventTrigger for loading proxy info from XML, and adds LDAP auth retries with a 503 if all retries fail.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/conf/caldavd-test.plist
CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
CalendarServer/trunk/twistedcaldav/stdconfig.py
CalendarServer/trunk/twistedcaldav/upgrade.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2011-07-21 23:30:44 UTC (rev 7821)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2011-07-22 20:41:04 UTC (rev 7822)
@@ -37,11 +37,9 @@
from twisted.python.log import FileLogObserver, ILogObserver
from twisted.python.logfile import LogFile
from twisted.python.usage import Options, UsageError
-from twisted.python.reflect import namedClass
from twisted.plugin import IPlugin
from twisted.internet.defer import gatherResults, Deferred
from twisted.internet import reactor as _reactor
-from twisted.internet.reactor import addSystemEventTrigger
from twisted.internet.process import ProcessExitedAlready
from twisted.internet.protocol import Protocol, Factory
from twisted.internet.protocol import ProcessProtocol
@@ -64,8 +62,6 @@
from twistedcaldav.config import ConfigurationError
from twistedcaldav.config import config
-from twistedcaldav.directory import calendaruserproxy
-from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
from twistedcaldav.localization import processLocalizationFiles
from twistedcaldav.mail import IMIPReplyInboxResource
from twistedcaldav import memcachepool
@@ -569,27 +565,9 @@
if config.ProcessType in ('Combined', 'Single'):
- # Memcached is not needed for the "master" process
- if config.ProcessType in ('Combined',):
- config.Memcached.Pools.Default.ClientEnabled = False
-
- # Note: if the master process ever needs access to memcached
- # we'll either have to start memcached prior to the
- # updateProxyDB call below, or disable memcached
- # client config only while updateProxyDB is running.
-
# Process localization string files
processLocalizationFiles(config.Localization)
- # Make sure proxies get initialized
- if config.ProxyLoadFromFile:
- def _doProxyUpdate():
- proxydbClass = namedClass(config.ProxyDBService.type)
- calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
- loader = XMLCalendarUserProxyLoader(config.ProxyLoadFromFile)
- return loader.updateProxyDB()
- addSystemEventTrigger("after", "startup", _doProxyUpdate)
-
try:
service = serviceMethod(options)
except ConfigurationError, e:
Modified: CalendarServer/trunk/conf/caldavd-test.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-test.plist 2011-07-21 23:30:44 UTC (rev 7821)
+++ CalendarServer/trunk/conf/caldavd-test.plist 2011-07-22 20:41:04 UTC (rev 7822)
@@ -919,7 +919,7 @@
<key>EnableUpdater</key>
<true/>
<key>MemcachedPool</key>
- <string>ProxyDB</string>
+ <string>Default</string>
<key>UpdateSeconds</key>
<integer>300</integer>
<key>ExpireSeconds</key>
Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-07-21 23:30:44 UTC (rev 7821)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-07-22 20:41:04 UTC (rev 7822)
@@ -55,6 +55,8 @@
from twistedcaldav.directory.directory import DirectoryConfigurationError
from twistedcaldav.directory.augment import AugmentRecord
from twisted.internet.defer import succeed
+from twext.web2.http import HTTPError, StatusResponse
+from twext.web2 import responsecode
class LdapDirectoryService(CachingDirectoryService):
"""
@@ -322,17 +324,36 @@
Perform simple bind auth, raising ldap.INVALID_CREDENTIALS if
bad password
"""
- if self.authLDAP is None:
- self.log_debug("Creating authentication connection to LDAP")
- self.authLDAP = self.createLDAPConnection()
- self.log_debug("Authenticating %s" % (dn,))
- try:
- self.authLDAP.simple_bind_s(dn, password)
- except ldap.SERVER_DOWN:
- self.log_debug("Lost connection to LDAP server. Retrying.")
- self.authLDAP = self.createLDAPConnection()
- self.authLDAP.simple_bind_s(dn, password)
+ TRIES = 3
+ for i in xrange(TRIES):
+ self.log_debug("Authenticating %s" % (dn,))
+
+ if self.authLDAP is None:
+ self.log_debug("Creating authentication connection to LDAP")
+ self.authLDAP = self.createLDAPConnection()
+
+ try:
+ self.authLDAP.simple_bind_s(dn, password)
+ # Getting here means success, so break the retry loop
+ break
+
+ except ldap.INVALID_CREDENTIALS:
+ raise
+
+ except ldap.SERVER_DOWN:
+ self.log_error("Lost connection to LDAP server.")
+ self.authLDAP = None
+ # Fall through and retry if TRIES has been reached
+
+ except Exception, e:
+ self.log_error("LDAP authentication failed with %s." % (e,))
+ raise
+
+ else:
+ self.log_error("Giving up on LDAP authentication after %d tries. Responding with 503." % (TRIES,))
+ raise HTTPError(StatusResponse(responsecode.SERVICE_UNAVAILABLE, "LDAP server unavailable"))
+
self.log_debug("Authentication succeeded for %s" % (dn,))
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-07-21 23:30:44 UTC (rev 7821)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2011-07-22 20:41:04 UTC (rev 7822)
@@ -745,7 +745,7 @@
"GroupCaching" : {
"Enabled": True,
- "MemcachedPool" : "ProxyDB",
+ "MemcachedPool" : "Default",
"UpdateSeconds" : 300,
"ExpireSeconds" : 3600,
"EnableUpdater" : True,
Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py 2011-07-21 23:30:44 UTC (rev 7821)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py 2011-07-22 20:41:04 UTC (rev 7822)
@@ -32,6 +32,7 @@
from twistedcaldav.directory.calendaruserproxy import ProxySqliteDB
from twistedcaldav.directory.directory import DirectoryService, GroupMembershipCacheUpdater
from twistedcaldav.directory import calendaruserproxy
+from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
from twistedcaldav.directory.resourceinfo import ResourceInfoDatabase
from twistedcaldav.mail import MailGatewayTokensDatabase
from twistedcaldav.ical import Component
@@ -835,6 +836,14 @@
Start the service.
"""
+ # Load proxy assignments from XML if specified
+ if self.config.ProxyLoadFromFile:
+ proxydbClass = namedClass(self.config.ProxyDBService.type)
+ calendaruserproxy.ProxyDBService = proxydbClass(
+ **self.config.ProxyDBService.params)
+ loader = XMLCalendarUserProxyLoader(self.config.ProxyLoadFromFile)
+ yield loader.updateProxyDB()
+
# Populate the group membership cache
if (self.config.GroupCaching.Enabled and
self.config.GroupCaching.EnableUpdater):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110722/a6f69c91/attachment.html>
More information about the calendarserver-changes
mailing list