<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13804] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13804">13804</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-07-30 11:50:40 -0700 (Wed, 30 Jul 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Skip filesystem home migrations if record is missing from directory; remove quit-after-upgrade-step</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertapcaldavpy">CalendarServer/trunk/calendarserver/tap/caldav.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertaptesttest_caldavpy">CalendarServer/trunk/calendarserver/tap/test/test_caldav.py</a></li>
<li><a href="#CalendarServertrunkcontribodtesttest_livepy">CalendarServer/trunk/contrib/od/test/test_live.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgrademigratepy">CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreupgradetesttest_migratepy">CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertapcaldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tap/caldav.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tap/caldav.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -720,42 +720,6 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx">
</span><del>-
-class QuitAfterUpgradeStep(object):
-
- def __init__(self, triggerFile, reactor=None):
- self.triggerFile = triggerFile
- if reactor is None:
- from twisted.internet import reactor
- self.reactor = reactor
-
-
- def removeTriggerFile(self):
- try:
- remove(self.triggerFile)
- except OSError:
- pass
-
-
- def stepWithResult(self, result):
- if exists(self.triggerFile):
- self.removeTriggerFile()
- self.reactor.stop()
- raise PostUpgradeStopRequested()
- else:
- return succeed(result)
-
-
- def stepWithFailure(self, failure):
- if exists(self.triggerFile):
- self.removeTriggerFile()
- self.reactor.stop()
- raise PostUpgradeStopRequested()
- else:
- return failure
-
-
-
</del><span class="cx"> class CalDAVServiceMaker (object):
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="lines">@@ -1583,15 +1547,7 @@
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # Conditionally stop after upgrade at this point
</del><span class="cx"> pps.addStep(
</span><del>- QuitAfterUpgradeStep(
- config.StopAfterUpgradeTriggerFile or
- config.UpgradeHomePrefix
- )
- )
-
- pps.addStep(
</del><span class="cx"> PostDBImportStep(
</span><span class="cx"> store, config, getattr(self, "doPostImport", True)
</span><span class="cx"> )
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertaptesttest_caldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tap/test/test_caldav.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tap/test/test_caldav.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/calendarserver/tap/test/test_caldav.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> CalDAVOptions, CalDAVServiceMaker, CalDAVService, GroupOwnedUNIXServer,
</span><span class="cx"> DelayedStartupProcessMonitor, DelayedStartupLineLogger, TwistdSlaveProcess,
</span><span class="cx"> _CONTROL_SERVICE_NAME, getSystemIDs, PreProcessingService,
</span><del>- QuitAfterUpgradeStep, DataStoreMonitor
</del><ins>+ DataStoreMonitor
</ins><span class="cx"> )
</span><span class="cx"> from calendarserver.provision.root import RootResource
</span><span class="cx"> from twext.enterprise.jobqueue import PeerConnectionPool, LocalQueuer
</span><span class="lines">@@ -1505,31 +1505,6 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><del>- def test_quitAfterUpgradeStep(self):
- triggerFileName = "stop_after_upgrade"
- triggerFile = FilePath(triggerFileName)
- self.pps.addStep(
- StepOne(self._record, False)
- ).addStep(
- StepTwo(self._record, False)
- ).addStep(
- QuitAfterUpgradeStep(triggerFile.path, reactor=self.clock)
- ).addStep(
- StepFour(self._record, True)
- )
- triggerFile.setContent("")
- self.pps.startService()
- self.assertEquals(
- self.history,
- [
- 'one success', 'two success', 'four failure',
- ('serviceCreator', None, 'storageService')
- ]
- )
- self.assertFalse(triggerFile.exists())
-
-
-
</del><span class="cx"> class StubStorageService(object):
</span><span class="cx">
</span><span class="cx"> def __init__(self):
</span></span></pre></div>
<a id="CalendarServertrunkcontribodtesttest_livepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/od/test/test_live.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/contrib/od/test/test_live.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/contrib/od/test/test_live.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -40,7 +40,6 @@
</span><span class="cx"> from twext.who.expression import (
</span><span class="cx"> CompoundExpression, Operand, MatchExpression, MatchType, MatchFlags
</span><span class="cx"> )
</span><del>- from twext.who.idirectory import QueryNotSupportedError
</del><span class="cx"> from txdav.who.directory import CalendarDirectoryServiceMixin
</span><span class="cx"> from txdav.who.opendirectory import DirectoryService as OpenDirectoryService
</span><span class="cx">
</span><span class="lines">@@ -274,115 +273,6 @@
</span><span class="cx">
</span><span class="cx"> @onlyIfPopulated
</span><span class="cx"> @inlineCallbacks
</span><del>- def test_compoundWithEmbeddedSingleRecordType(self):
- expression = CompoundExpression(
- [
- CompoundExpression(
- [
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"be",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"be",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"test",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"test",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- ),
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.user,
- ),
- ],
- Operand.AND
- )
- try:
- yield self.service.recordsFromExpression(expression)
- except QueryNotSupportedError:
- pass
- else:
- self.fail("This should have raised")
-
-
- @onlyIfPopulated
- @inlineCallbacks
- def test_compoundWithEmbeddedMultipleRecordTypes(self):
- expression = CompoundExpression(
- [
- CompoundExpression(
- [
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"be",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"be",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.fullNames, u"test",
- matchType=MatchType.contains
- ),
- MatchExpression(
- self.service.fieldName.emailAddresses, u"test",
- matchType=MatchType.startsWith
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- ),
- CompoundExpression(
- [
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.user,
- ),
- MatchExpression(
- self.service.fieldName.recordType, self.service.recordType.group,
- ),
- ],
- Operand.OR
- ),
- ],
- Operand.AND
- )
-
- try:
- yield self.service.recordsFromExpression(expression)
- except QueryNotSupportedError:
- pass
- else:
- self.fail("This should have raised")
-
-
- @onlyIfPopulated
- @inlineCallbacks
</del><span class="cx"> def test_recordsMatchingTokens(self):
</span><span class="cx"> self.calService = CalOpenDirectoryService()
</span><span class="cx"> records = yield self.calService.recordsMatchingTokens([u"be", u"test"])
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -310,8 +310,6 @@
</span><span class="cx"> "FailIfUpgradeNeeded": True, # Set to True to prevent the server or utility
</span><span class="cx"> # tools from running if the database needs a schema
</span><span class="cx"> # upgrade.
</span><del>- "StopAfterUpgradeTriggerFile": "stop_after_upgrade", # if this file exists in ConfigRoot, stop
- # the service after finishing upgrade phase
</del><span class="cx">
</span><span class="cx"> "UpgradeHomePrefix": "", # When upgrading, only upgrade homes where the owner UID starts with
</span><span class="cx"> # with the specified prefix. The upgrade will only be partial and only
</span><span class="lines">@@ -1249,7 +1247,6 @@
</span><span class="cx"> ("DataRoot", "DatabaseRoot"),
</span><span class="cx"> ("DataRoot", "AttachmentsRoot"),
</span><span class="cx"> ("DataRoot", ("TimezoneService", "BasePath",)),
</span><del>- ("ConfigRoot", "StopAfterUpgradeTriggerFile"),
</del><span class="cx"> ("ConfigRoot", ("Scheduling", "iSchedule", "DNSDebug",)),
</span><span class="cx"> ("ConfigRoot", ("Scheduling", "iSchedule", "DKIM", "PrivateKeyFile",)),
</span><span class="cx"> ("ConfigRoot", ("Scheduling", "iSchedule", "DKIM", "PublicKeyFile",)),
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgrademigratepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_4_to_5 import doUpgrade as doCalendarUpgrade_4_to_5
</span><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrades.addressbook_upgrade_from_1_to_2 import doUpgrade as doAddressbookUpgrade_1_to_2
</span><span class="cx">
</span><ins>+from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -326,7 +327,12 @@
</span><span class="cx"> returnValue(None)
</span><span class="cx"> try:
</span><span class="cx"> if sqlHome is None:
</span><del>- sqlHome = yield homeGetter(uid, create=True)
</del><ins>+ try:
+ sqlHome = yield homeGetter(uid, create=True)
+ except DirectoryRecordNotFoundError:
+ # The directory record does not exist; skip this home
+ self.log.warn("Skipping migration of {uid} because it's missing from the directory service", uid=uid)
+ returnValue(None)
</ins><span class="cx"> yield migrateFunc(fileHome, sqlHome, merge=self.merge)
</span><span class="cx"> except:
</span><span class="cx"> f = Failure()
</span><span class="lines">@@ -362,11 +368,6 @@
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="cx">
</span><del>- for homeType in TOPPATHS:
- homesPath = self.fileStore._path.child(homeType)
- if homesPath.isdir():
- homesPath.remove()
-
</del><span class="cx"> # Set attachment directory ownership. FIXME: is this still necessary
</span><span class="cx"> # since attachments started living outside the database directory
</span><span class="cx"> # created by initdb? default permissions might be correct now.
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreupgradetesttest_migratepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py (13803 => 13804)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py        2014-07-29 18:22:00 UTC (rev 13803)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/test/test_migrate.py        2014-07-30 18:50:40 UTC (rev 13804)
</span><span class="lines">@@ -320,7 +320,36 @@
</span><span class="cx"> self.assertEquals(object.md5(), md5)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @withSpecialValue(
+ "extraRequirements",
+ {
+ "nonexistent": {
+ "calendar_1": {
+ }
+ }
+ }
+ )
</ins><span class="cx"> @inlineCallbacks
</span><ins>+ def test_upgradeCalendarHomesMissingDirectoryRecord(self):
+ """
+ Test an upgrade where a directory record is missing for a home;
+ the original home directory will remain on disk.
+ """
+ yield self.upgrader.stepWithResult(None)
+ txn = self.sqlStore.newTransaction()
+ self.addCleanup(txn.commit)
+ for uid in CommonTests.requirements:
+ if CommonTests.requirements[uid] is not None:
+ self.assertNotIdentical(
+ None, (yield txn.calendarHomeWithUID(uid))
+ )
+ self.assertIdentical(None, (yield txn.calendarHomeWithUID(u"nonexistent")))
+ # Skipped calendar homes are not deleted
+ self.assertTrue(self.filesPath.child("calendars").child(
+ "__uids__").child("no").child("ne").child("nonexistent").exists())
+
+
+ @inlineCallbacks
</ins><span class="cx"> def test_upgradeExistingHome(self):
</span><span class="cx"> """
</span><span class="cx"> L{UpgradeToDatabaseService.startService} will skip migrating existing
</span></span></pre>
</div>
</div>
</body>
</html>