Merge pull request #45420 from mgfritch/cephadm-infer-image-pull

cephadm: infer the default container image during pull

Reviewed-by: Adam King <adking@redhat.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
Adam King 2022-03-22 08:51:57 -04:00 committed by GitHub
commit 9671f179be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View File

@ -4228,7 +4228,7 @@ def command_version(ctx):
##################################
@infer_image
@default_image
def command_pull(ctx):
# type: (CephadmContext) -> int
@ -8040,7 +8040,7 @@ def _get_parser():
parser_version.set_defaults(func=command_version)
parser_pull = subparsers.add_parser(
'pull', help='pull latest image version')
'pull', help='pull the default container image')
parser_pull.set_defaults(func=command_pull)
parser_pull.add_argument(
'--insecure',
@ -8097,7 +8097,7 @@ def _get_parser():
parser_adopt.add_argument(
'--skip-pull',
action='store_true',
help='do not pull the latest image before adopting')
help='do not pull the default image before adopting')
parser_adopt.add_argument(
'--force-start',
action='store_true',
@ -8386,7 +8386,7 @@ def _get_parser():
parser_bootstrap.add_argument(
'--skip-pull',
action='store_true',
help='do not pull the latest image before bootstrapping')
help='do not pull the default image before bootstrapping')
parser_bootstrap.add_argument(
'--skip-firewalld',
action='store_true',

View File

@ -1680,6 +1680,29 @@ class TestPull:
cd.command_pull(ctx)
assert err in str(e.value)
@mock.patch('cephadm.logger')
@mock.patch('cephadm.get_image_info_from_inspect', return_value={})
@mock.patch('cephadm.get_last_local_ceph_image', return_value='last_local_ceph_image')
def test_image(self, get_last_local_ceph_image, get_image_info_from_inspect, logger):
cmd = ['pull']
with with_cephadm_ctx(cmd) as ctx:
retval = cd.command_pull(ctx)
assert retval == 0
assert ctx.image == cd.DEFAULT_IMAGE
with mock.patch.dict(os.environ, {"CEPHADM_IMAGE": 'cephadm_image_environ'}):
cmd = ['pull']
with with_cephadm_ctx(cmd) as ctx:
retval = cd.command_pull(ctx)
assert retval == 0
assert ctx.image == 'cephadm_image_environ'
cmd = ['--image', 'cephadm_image_param', 'pull']
with with_cephadm_ctx(cmd) as ctx:
retval = cd.command_pull(ctx)
assert retval == 0
assert ctx.image == 'cephadm_image_param'
class TestApplySpec: