From: Sage Weil Date: Wed, 24 Mar 2021 03:00:46 +0000 (-0500) Subject: cephadm: only bootstrap using image that matches cephadm version X-Git-Tag: v16.2.0~24^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e920bef68db0bd35cb446af7979d0b8346eeccf4;p=ceph.git cephadm: only bootstrap using image that matches cephadm version 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 (cherry picked from commit 1b5a068ddfc84002cefb384ea01e97b5300408a1) # Conflicts: # src/cephadm/cephadm - default images are diff for pacific branch --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index beb9bf06d7b..238d4384ac2 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -47,6 +47,7 @@ from urllib.request import urlopen # Default container images ----------------------------------------------------- DEFAULT_IMAGE = 'docker.io/ceph/daemon-base:latest-pacific-devel' DEFAULT_IMAGE_IS_MASTER = False +DEFAULT_IMAGE_RELEASE = 'pacific' 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' @@ -3753,9 +3754,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 @@ -3865,6 +3863,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) @@ -7560,6 +7572,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',