[CalendarServer-changes] [14722] CalendarServer/trunk/calendarserver

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 29 10:25:01 PDT 2015


Revision: 14722
          http://trac.calendarserver.org//changeset/14722
Author:   sagen at apple.com
Date:     2015-04-29 10:25:01 -0700 (Wed, 29 Apr 2015)
Log Message:
-----------
Post an alert if our data volume is missing or is a 'phantom' volume

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/calendarserver/tools/util.py

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2015-04-29 15:19:55 UTC (rev 14721)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2015-04-29 17:25:01 UTC (rev 14722)
@@ -24,7 +24,7 @@
 
 import sys
 from collections import OrderedDict
-from os import getuid, getgid, umask, remove, environ, stat, chown
+from os import getuid, getgid, umask, remove, environ, stat, chown, W_OK
 from os.path import exists, basename
 import socket
 from stat import S_ISSOCK
@@ -1434,6 +1434,15 @@
         config.addPostUpdateHooks((agentPostUpdateHook,))
         config.reload()
 
+        # Verify that server root actually exists and is not phantom
+        from calendarserver.tools.util import checkDirectory
+        checkDirectory(
+            config.ServerRoot,
+            "Server root",
+            access=W_OK,
+            wait=True  # Wait in a loop until ServerRoot exists and is not phantom
+        )
+
         # These we need to set in order to open the store
         config.EnableCalDAV = config.EnableCardDAV = True
 

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2015-04-29 15:19:55 UTC (rev 14721)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2015-04-29 17:25:01 UTC (rev 14722)
@@ -25,6 +25,7 @@
     "getRootResource",
     "getSSLPassphrase",
     "MemoryLimitService",
+    "postAlert",
     "preFlightChecks",
 ]
 

Modified: CalendarServer/trunk/calendarserver/tools/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/util.py	2015-04-29 15:19:55 UTC (rev 14721)
+++ CalendarServer/trunk/calendarserver/tools/util.py	2015-04-29 17:25:01 UTC (rev 14722)
@@ -32,6 +32,8 @@
 from grp import getgrnam
 from uuid import UUID
 
+from calendarserver.tools import diagnose
+
 from twistedcaldav.config import config, ConfigurationError
 from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
 
@@ -140,12 +142,22 @@
     # Note: we have to use print here because the logging mechanism has not
     # been set up yet.
 
-    if not os.path.exists(dirpath):
+    if not os.path.exists(dirpath) or (diagnose.detectPhantomVolume(dirpath) == diagnose.EXIT_CODE_PHANTOM_DATA_VOLUME):
 
         if wait:
-            while not os.path.exists(dirpath):
-                print("Path does not exist: %s" % (dirpath,))
-                sleep(1)
+
+            # If we're being told to wait, post an alert that we can't continue
+            # until the volume is mounted
+            if not os.path.exists(dirpath) or (diagnose.detectPhantomVolume(dirpath) == diagnose.EXIT_CODE_PHANTOM_DATA_VOLUME):
+                from calendarserver.tap.util import postAlert
+                postAlert("MissingDataVolumeAlert", ["volumePath", dirpath])
+
+            while not os.path.exists(dirpath) or (diagnose.detectPhantomVolume(dirpath) == diagnose.EXIT_CODE_PHANTOM_DATA_VOLUME):
+                if not os.path.exists(dirpath):
+                    print("Path does not exist: %s" % (dirpath,))
+                else:
+                    print("Path is not a real volume: %s" % (dirpath,))
+                sleep(5)
         else:
             try:
                 mode, username, groupname = create
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150429/456af172/attachment.html>


More information about the calendarserver-changes mailing list