]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: update check-host() to return all problems
authorDaniel-Pivonka <dpivonka@redhat.com>
Wed, 18 Mar 2020 23:19:18 +0000 (19:19 -0400)
committerDaniel-Pivonka <dpivonka@redhat.com>
Fri, 20 Mar 2020 14:37:06 +0000 (10:37 -0400)
if checks fail, they show one at a time, forcing the admin to repeat
the command to get passed each check.

All checks should run and report once, so the admin can fix all issues
in one go, and not be forced to do repeated commands

Signed-off-by: Daniel-Pivonka <dpivonka@redhat.com>
src/cephadm/cephadm

index 1357f1e210a63f2034006979742795e18eea69d3..dffc02bd5729f56194df54c41805c0e3fc746b20 100755 (executable)
@@ -3162,28 +3162,43 @@ def check_time_sync(enabler=None):
 
 def command_check_host():
     # type: () -> None
-    # caller already checked for docker/podman
-    logger.info('podman|docker (%s) is present' % container_path)
-
+    errors = []
     commands = ['systemctl', 'lvcreate']
 
+    if args.docker:
+            container_path = find_program('docker')
+    else:
+        for i in CONTAINER_PREFERENCE:
+            try:
+                container_path = find_program(i)
+                break
+            except Exception as e:
+                logger.debug('Could not locate %s: %s' % (i, e))
+        if not container_path:
+            errors.append('Unable to locate any of %s' % CONTAINER_PREFERENCE)
+        else:
+            logger.info('podman|docker (%s) is present' % container_path)
+
     for command in commands:
         try:
             find_program(command)
             logger.info('%s is present' % command)
         except ValueError:
-            raise Error('%s binary does not appear to be installed' % command)
+            errors.append('%s binary does not appear to be installed' % command)
 
     # check for configured+running chronyd or ntp
     if not check_time_sync():
-        raise Error('No time synchronization is active')
+        errors.append('No time synchronization is active')
 
     if 'expect_hostname' in args and args.expect_hostname:
         if get_hostname() != args.expect_hostname:
-            raise Error('hostname "%s" does not match expected hostname "%s"' % (
+            errors.append('hostname "%s" does not match expected hostname "%s"' % (
                 get_hostname(), args.expect_hostname))
         logger.info('Hostname "%s" matches what is expected.',
                     args.expect_hostname)
+    
+    if errors:
+        raise Error('\n'.join(errors))
 
     logger.info('Host looks OK')
 
@@ -4085,18 +4100,19 @@ if __name__ == "__main__":
         sys.exit(1)
 
     # podman or docker?
-    if args.docker:
-        container_path = find_program('docker')
-    else:
-        for i in CONTAINER_PREFERENCE:
-            try:
-                container_path = find_program(i)
-                break
-            except Exception as e:
-                logger.debug('Could not locate %s: %s' % (i, e))
-        if not container_path and args.func != command_prepare_host:
-            sys.stderr.write('Unable to locate any of %s\n' % CONTAINER_PREFERENCE)
-            sys.exit(1)
+    if args.func != command_check_host:
+        if args.docker:
+            container_path = find_program('docker')
+        else:
+            for i in CONTAINER_PREFERENCE:
+                try:
+                    container_path = find_program(i)
+                    break
+                except Exception as e:
+                    logger.debug('Could not locate %s: %s' % (i, e))
+            if not container_path and args.func != command_prepare_host:
+                sys.stderr.write('Unable to locate any of %s\n' % CONTAINER_PREFERENCE)
+                sys.exit(1)
 
     if 'func' not in args:
         sys.stderr.write('No command specified; pass -h or --help for usage\n')