Page MenuHomePhorge

wallace fails to run expunge old events job
Closed, ResolvedPublic

Description

Wallace fails to parse events in the resource if the even is reoccurring and has such reoccurring rule:

<rrule>
  <recur>
    <freq>WEEKLY</freq>
    <until>
      <date>2016-12-31</date>
    </until>
    <interval>2</interval>
    <byday>WE</byday>
  </recur>
</rrule>

The error then is:

ERROR Expunge resource calendar for cn=Meeting-room,ou=Resources,dc=domain,dc=tld (shared/Resources/Meeting-room@domain.tld) failed: TypeError("can't compare datetime.datetime to datetime.date",)

The problem here is that in this case the last_occurrence (dt_end) is of time 'date', code tries to compare dt_end to expire_date, which is datetime.
I've noticed that other reoccurring events have last_occurrence set to <date-time>, but some have just <date> in kolab xml.
The fix could be to convert dt_end to type of date and convert expire_date to type of date and compare date objects. This is an example of the fix in file wallace/module_resources.py, method

 --- module_resources.py.orig    2016-07-08 15:05:54.887180000 +0200
+++ module_resources.py 2016-07-08 15:04:54.383180001 +0200
@@ -492,7 +492,10 @@ def expunge_resource_calendar(mailbox):
                     # skip if recurring forever
                     continue
 
-            if dt_end and dt_end < expire_date:
+            if isinstance(dt_end, datetime.datetime):
+               dt_end = dt_end.date()
+            
+            if dt_end and dt_end < expire_date.date():
                 age = now - dt_end
                 log.debug(_("Flag event %s from message %s/%s as deleted (age = %d days)") % (event.uid, mailbox, num, age.days), level=8)
                 imap.imap.m.store(num, '+FLAGS', '\\Deleted')

This would mean that checking of expired events will be based on day granularity.

Details

Ticket Type
Task

Event Timeline

A better diff for fixing the problem.

@@ -492,8 +497,11 @@ def expunge_resource_calendar(mailbox):
                     # skip if recurring forever
                     continue
 
-            if dt_end and dt_end < expire_date:
-                age = now - dt_end
+            if isinstance(dt_end, datetime.datetime):
+               dt_end = dt_end.date()
+            
+            if dt_end and dt_end < expire_date.date():
+                age = now.date() - dt_end
                 log.debug(_("Flag event %s from message %s/%s as deleted (age = %d days)") % (event.uid, mailbox, num, age.days), level=8)
                 imap.imap.m.store(num, '+FLAGS', '\\Deleted')
machniak subscribed.

This is a duplicate of T1847.