From: Sage Weil Date: Mon, 22 Mar 2021 22:05:16 +0000 (-0400) Subject: cephadm: only bootstrap using image that matches cephadm version X-Git-Tag: v17.1.0~2502^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40322%2Fhead;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 --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index b5b65c1bad0..b568abb71c1 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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',