]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: only bootstrap using image that matches cephadm version 40322/head
authorSage Weil <sage@newdream.net>
Mon, 22 Mar 2021 22:05:16 +0000 (18:05 -0400)
committerSage Weil <sage@newdream.net>
Mon, 22 Mar 2021 22:05:16 +0000 (18:05 -0400)
Only allow bootstrap to deploy if the cephadm version matches the
ceph version in the container.  Allow the master branch version of cephadm
to deploy the latest stable version as well (at least for now).

Provide a flag to force bootstrap to continue despite the check.

Move the _pull_image call up into bootstrap so that it is easier to see
when it happens.

Fixes: https://tracker.ceph.com/issues/49884
Signed-off-by: Sage Weil <sage@newdream.net>
src/cephadm/cephadm

index b5b65c1bad06cedd4c421acec975cd285751d66d..b568abb71c14a24e209e3b9320e5eb009e00840d 100755 (executable)
@@ -47,6 +47,7 @@ from urllib.request import urlopen
 # Default container images -----------------------------------------------------
 DEFAULT_IMAGE = 'quay.ceph.io/ceph-ci/ceph:master'
 DEFAULT_IMAGE_IS_MASTER = True
+DEFAULT_IMAGE_RELEASE = 'quincy'
 DEFAULT_PROMETHEUS_IMAGE = 'docker.io/prom/prometheus:v2.18.1'
 DEFAULT_NODE_EXPORTER_IMAGE = 'docker.io/prom/node-exporter:v0.18.1'
 DEFAULT_GRAFANA_IMAGE = 'docker.io/ceph/ceph-grafana:6.7.4'
@@ -3757,9 +3758,6 @@ def prepare_bootstrap_config(
     if ctx.registry_json or ctx.registry_url:
         command_registry_login(ctx)
 
-    if not ctx.skip_pull:
-        _pull_image(ctx, image)
-
     return config
 
 
@@ -3869,6 +3867,20 @@ def command_bootstrap(ctx):
 
     config = prepare_bootstrap_config(ctx, fsid, addr_arg, ctx.image)
 
+    if not ctx.skip_pull:
+        _pull_image(ctx, ctx.image)
+
+    image_ver = CephContainer(ctx, ctx.image, 'ceph', ['--version']).run().strip()
+    logger.info(f'Ceph version: {image_ver}')
+    image_release = image_ver.split()[4]
+    if (
+        not ctx.allow_mismatched_release
+        and image_release not in [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE]
+    ):
+        raise Error(
+            f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE}; please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)'
+        )
+
     logger.info('Extracting ceph user uid/gid from container image...')
     (uid, gid) = extract_uid_gid(ctx)
 
@@ -7564,6 +7576,10 @@ def _get_parser():
         '--allow-fqdn-hostname',
         action='store_true',
         help='allow hostname that is fully-qualified (contains ".")')
+    parser_bootstrap.add_argument(
+        '--allow-mismatched-release',
+        action='store_true',
+        help="allow bootstrap of ceph that doesn't match this version of cephadm")
     parser_bootstrap.add_argument(
         '--skip-prepare-host',
         action='store_true',