]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: allow pulling from insecure registries
authorJoao Eduardo Luis <joao@suse.com>
Mon, 11 Oct 2021 17:20:47 +0000 (17:20 +0000)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:02:20 +0000 (10:02 +0100)
Signed-off-by: Joao Eduardo Luis <joao@suse.com>
(cherry picked from commit 0a86107dccfdffa7476c61312f0c3b5aae7da7b7)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/serve.py

index e265249a881256c2d59bb7ea4f432f516ef53c98..49417c4a0da57f6c9d4e209bc97e0958472ac7c1 100755 (executable)
@@ -3438,12 +3438,12 @@ def command_version(ctx):
 def command_pull(ctx):
     # type: (CephadmContext) -> int
 
-    _pull_image(ctx, ctx.image)
+    _pull_image(ctx, ctx.image, ctx.insecure)
     return command_inspect_image(ctx)
 
 
-def _pull_image(ctx, image):
-    # type: (CephadmContext, str) -> None
+def _pull_image(ctx, image, insecure=False):
+    # type: (CephadmContext, str, bool) -> None
     logger.info('Pulling container image %s...' % image)
 
     ignorelist = [
@@ -3453,8 +3453,12 @@ def _pull_image(ctx, image):
     ]
 
     cmd = [ctx.container_engine.path, 'pull', image]
-    if isinstance(ctx.container_engine, Podman) and os.path.exists('/etc/ceph/podman-auth.json'):
-        cmd.append('--authfile=/etc/ceph/podman-auth.json')
+    if isinstance(ctx.container_engine, Podman):
+        if insecure:
+            cmd.append('--tls-verify=false')
+
+        if os.path.exists('/etc/ceph/podman-auth.json'):
+            cmd.append('--authfile=/etc/ceph/podman-auth.json')
     cmd_str = ' '.join(cmd)
 
     for sleep_secs in [1, 4, 25]:
@@ -7831,6 +7835,11 @@ def _get_parser():
     parser_pull = subparsers.add_parser(
         'pull', help='pull latest image version')
     parser_pull.set_defaults(func=command_pull)
+    parser_pull.add_argument(
+        '--insecure',
+        action='store_true',
+        help=argparse.SUPPRESS,
+    )
 
     parser_inspect_image = subparsers.add_parser(
         'inspect-image', help='inspect local container image')
index c4c902a68b5df66d1f0e7b2e17592e942fb631a2..9f09349cf5043d4e5347d16a515beac029b33db7 100644 (file)
@@ -1635,6 +1635,7 @@ class TestPull:
     def test_error(self, get_image_info_from_inspect, call, sleep):
         ctx = cd.CephadmContext()
         ctx.container_engine = mock_podman()
+        ctx.insecure = False
 
         call.return_value = ('', '', 0)
         retval = cd.command_pull(ctx)
index 6a99cc40a38c168c159a41f880fb615483e0751e..403155efdf6f4a46dc7c65628bfdf672cf5642ed 100644 (file)
@@ -309,6 +309,12 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             default=None,
             desc='Custom repository password'
         ),
+        Option(
+            'registry_insecure',
+            type='bool',
+            default=False,
+            desc='Registry is to be considered insecure (no TLS available). Only for development purposes.'
+        ),
         Option(
             'use_repo_digest',
             type='bool',
@@ -390,6 +396,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             self.registry_url: Optional[str] = None
             self.registry_username: Optional[str] = None
             self.registry_password: Optional[str] = None
+            self.registry_insecure: bool = False
             self.use_repo_digest = True
             self.default_registry = ''
             self.autotune_memory_target_ratio = 0.0
index 34936c9c8a5c94afab43b0de348b9d2297646b14..186bd4dd7a14c20b53454300220c2c9ca2e5974b 100644 (file)
@@ -1240,7 +1240,11 @@ class CephadmServe:
             self._registry_login(host, self.mgr.registry_url,
                                  self.mgr.registry_username, self.mgr.registry_password)
 
-        j = self._run_cephadm_json(host, '', 'pull', [], image=image_name, no_fsid=True)
+        pullargs: List[str] = []
+        if self.mgr.registry_insecure:
+            pullargs.append("--insecure")
+
+        j = self._run_cephadm_json(host, '', 'pull', pullargs, image=image_name, no_fsid=True)
 
         r = ContainerInspectInfo(
             j['image_id'],