4 commits - kolabd/__init__.py kolabd/process.py pykolab/auth pykolab/imap
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Fri Nov 30 13:06:28 CET 2012
kolabd/__init__.py | 19 +++++++++++++++++--
kolabd/process.py | 10 +++++++---
pykolab/auth/ldap/__init__.py | 29 ++++++++++++++++-------------
pykolab/imap/__init__.py | 10 +++++++++-
4 files changed, 49 insertions(+), 19 deletions(-)
New commits:
commit 7cc23ab6a66a7471fc44a09a47b6d143da4e3d00
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Nov 30 12:03:11 2012 +0000
Reconnect if setting quota fails
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 68f0c78..67e04c4 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -598,7 +598,15 @@ class IMAP(object):
log.debug(_("Value for user is not a dictionary"), level=8)
def set_quota(self, folder, quota):
- self.imap._setquota(folder, quota)
+ i = 0
+ while i < 10:
+ try:
+ self.imap._setquota(folder, quota)
+ i = 10
+ except:
+ self.disconnect()
+ self.connect()
+ i += 1
def set_user_folder_quota(self, users=[], primary_domain=None, secondary_domain=[], folders=[]):
"""
commit e5575b6924a029d894ab6349783fbdb359fadf24
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Nov 30 12:01:17 2012 +0000
Use cache, not conf.changelog
Use a ReconnectLDAPObject rather than a SimpleLDAPObject
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 4275d51..84af8ef 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -219,7 +219,13 @@ class LDAP(pykolab.base.Base):
if conf.debuglevel > 8:
trace_level = 1
- self.ldap = ldap.initialize(uri, trace_level=trace_level)
+ self.ldap = ldap.ldapobject.ReconnectLDAPObject(
+ uri,
+ trace_level=trace_level,
+ retry_max=200,
+ retry_delay=3.0
+ )
+
self.ldap.protocol_version = 3
self.ldap.supported_controls = []
@@ -1230,17 +1236,14 @@ class LDAP(pykolab.base.Base):
pass
def _change_modify_user(self, entry, change):
- for entry_key in conf.changelog.keys():
- log.debug(
- _("Current changelog entry %s with %s") % (
- entry_key,
- conf.changelog[entry_key]
- ),
- level=8
- )
+ result_attribute = conf.get('cyrus-sasl','result_attribute')
+
+ _entry = cache.get_entry(self.domain, entry)
- if conf.changelog.has_key(entry['id']):
- old_canon_attr = conf.changelog[entry['id']]
+ log.debug("Entry.__dict__: %r" % (_entry.__dict__))
+
+ if _entry.__dict__.has_key('result_attribute') and not _entry.result_attribute == '':
+ old_canon_attr = _entry.result_attribute
entry_changes = self.recipient_policy(entry)
@@ -1249,7 +1252,6 @@ class LDAP(pykolab.base.Base):
level=8
)
- result_attribute = conf.get('cyrus-sasl','result_attribute')
if entry_changes.has_key(result_attribute):
if not entry_changes[result_attribute] == old_canon_attr:
self.imap.user_mailbox_rename(
@@ -1257,7 +1259,8 @@ class LDAP(pykolab.base.Base):
entry_changes[result_attribute]
)
- conf.changelog[entry['id']] = entry_changes[result_attribute]
+ entry[result_attribute] = entry_changes[result_attribute]
+ cache.get_entry(self.domain, entry)
self.user_quota(entry, "user%s%s" % (self.imap.separator,entry[result_attribute]))
commit e4ed71b5fd2e504e88c69beab4d4a5e93c97813a
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Nov 30 12:00:04 2012 +0000
try/except synchronizing and gracefully exit if something goes wrong. The master kolabd process will restart synchronization
diff --git a/kolabd/process.py b/kolabd/process.py
index 9fe525d..ddaac63 100644
--- a/kolabd/process.py
+++ b/kolabd/process.py
@@ -37,6 +37,10 @@ class KolabdProcess(multiprocessing.Process):
)
def synchronize(self, domain):
- auth = Auth(domain)
- auth.connect(domain)
- auth.synchronize()
+ try:
+ auth = Auth(domain)
+ auth.connect(domain)
+ auth.synchronize()
+ except:
+ log.error(_("Error in process %r, terminating") % (self.name))
+ return
\ No newline at end of file
commit 3739ce13564137491d92b195c781c15b2f9b60b9
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Nov 30 11:59:30 2012 +0000
Check if a domain name space synchronization process is still alive
try/except removing our PID file
diff --git a/kolabd/__init__.py b/kolabd/__init__.py
index 230088c..b345b8d 100644
--- a/kolabd/__init__.py
+++ b/kolabd/__init__.py
@@ -243,7 +243,11 @@ class KolabDaemon(object):
for domain in all_domains:
if domain in domain_auth.keys() and domain in primary_domains:
- continue
+ if not domain_auth[domain].is_alive():
+ domain_auth[domain].terminate()
+ added_domains.append(domain)
+ else:
+ continue
elif domain in domain_auth.keys():
removed_domains.append(domain)
else:
@@ -268,8 +272,19 @@ class KolabDaemon(object):
pass
def remove_pid(self, *args, **kw):
+ """
+ Remove our PID file.
+
+ Note that multiple processes can attempt to do this very same thing
+ at the same time, and therefore we need to test if the PID file
+ exists, and only try/except removing it.
+ """
if os.access(conf.pidfile, os.R_OK):
- os.remove(conf.pidfile)
+ try:
+ os.remove(conf.pidfile)
+ except:
+ pass
+
raise SystemExit
def set_signal_handlers(self):
More information about the commits
mailing list