]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: return nonzero exit code when applying spec fails in bootstrap 48102/head
authorAdam King <adking@redhat.com>
Wed, 17 Aug 2022 20:54:54 +0000 (16:54 -0400)
committerAdam King <adking@redhat.com>
Wed, 14 Sep 2022 19:59:46 +0000 (15:59 -0400)
This is mostly useful for testing automation, but right now if applying the
spec provided with --apply-spec fails, the return code remains zero. We don't
want to error out entirely in that case as we still want to print the remaining
output (e.g. the dashboard password). Continuing onward and then returning a
nonzero code could provide a balance where we still give all the output but
still have something to make it easier for those writing automation around bootstrap.

Fixes: https://tracker.ceph.com/issues/57173
Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit be17f1d4b30e19aa6039fa5d6a694129cb5f3583)

src/cephadm/cephadm

index 46c3d7fce5e8d65b726447ff9983e2d96835e40f..568425b35faec020ccc188082288c489b9ec751c 100755 (executable)
@@ -4651,6 +4651,8 @@ def _distribute_ssh_keys(ctx: CephadmContext, host_spec: Dict[str, str], bootstr
 def command_bootstrap(ctx):
     # type: (CephadmContext) -> int
 
+    ctx.error_code = 0
+
     if not ctx.output_config:
         ctx.output_config = os.path.join(ctx.output_dir, 'ceph.conf')
     if not ctx.output_keyring:
@@ -4880,6 +4882,7 @@ def command_bootstrap(ctx):
             out = cli(['orch', 'apply', '-i', '/tmp/spec.yml'], extra_mounts=mounts)
             logger.info(out)
         except Exception:
+            ctx.error_code = -errno.EINVAL
             logger.info('\nApplying %s to cluster failed!\n' % ctx.apply_spec)
 
     # enable autotune for osd_memory_target
@@ -4903,7 +4906,7 @@ def command_bootstrap(ctx):
                 'For more information see:\n\n'
                 '\thttps://docs.ceph.com/en/pacific/mgr/telemetry/\n')
     logger.info('Bootstrap complete.')
-    return 0
+    return ctx.error_code
 
 ##################################