]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: create default output dir during bootstrap
authorPaul Cuzner <pcuzner@redhat.com>
Sun, 13 Dec 2020 22:15:38 +0000 (11:15 +1300)
committerPaul Cuzner <pcuzner@redhat.com>
Sun, 13 Dec 2020 22:15:38 +0000 (11:15 +1300)
If the output dir doesn't exist the old behaviour was to
abort bootstrap. Since we're running with UID=0, this
patch will create the missing dirs for the user to keep the
bootstrap process going

Signed-off-by: Paul Cuzner <pcuzner@redhat.com>
src/cephadm/cephadm

index 2b18283dfefe4981498a81a47e03606c25849da9..24100f3dfdb1425111bd537187ea43807ee30258 100755 (executable)
@@ -2844,7 +2844,14 @@ def command_bootstrap():
                               '--allow-overwrite to overwrite' % f)
         dirname = os.path.dirname(f)
         if dirname and not os.path.exists(dirname):
-            raise Error('%s directory %s does not exist' % (f, dirname))
+            fname = os.path.basename(f)
+            logger.info(f"Creating directory {dirname} for {fname}")
+            try:
+                # use makedirs to create intermediate missing dirs
+                os.makedirs(dirname, 0o700)
+            except PermissionError:
+                raise Error(f"Unable to create {dirname} due to permissions failure. Retry with root, or sudo or preallocate the directory.")
+
 
     if not args.skip_prepare_host:
         command_prepare_host()