]> 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)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 7 Jan 2021 12:02:43 +0000 (13:02 +0100)
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>
(cherry picked from commit 27b5eada81189ad01b31ff34bf0e362353cfbd92)

src/cephadm/cephadm

index 1dd67a71acea04712dcb188346cabfa108242ea1..b1381126fb0b8594010e825d97b99644bea2d61b 100755 (executable)
@@ -2797,7 +2797,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()