]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use generic ceph-volume activate
authorSage Weil <sage@newdream.net>
Thu, 5 Aug 2021 17:32:00 +0000 (13:32 -0400)
committerSage Weil <sage@newdream.net>
Tue, 2 Nov 2021 15:20:35 +0000 (11:20 -0400)
This allows us to activate raw or LVM osds.  (In fact, LVM osds often
activate via the raw method because the LVs are already available.)

Signed-off-by: Sage Weil <sage@newdream.net>
src/cephadm/cephadm

index 87c69987f5e69a8a5ab9ba09a863a8cddbda21d4..063fc88418d0cdc78a51374fd72c5f48c5a06bee 100755 (executable)
@@ -2813,15 +2813,42 @@ def deploy_daemon_units(
                     p = os.path.join(data_dir, n)
                     f.write('[ ! -L {p} ] || chown {uid}:{gid} {p}\n'.format(p=p, uid=uid, gid=gid))
             else:
-                prestart = CephContainer(
+                # if ceph-volume does not support 'ceph-volume activate', we must
+                # do 'ceph-volume lvm activate'.
+                test_cv = CephContainer(
                     ctx,
                     image=ctx.image,
                     entrypoint='/usr/sbin/ceph-volume',
-                    args=[
+                    args=['activate', '--bad-option'],
+                    privileged=True,
+                    volume_mounts=get_container_mounts(ctx, fsid, daemon_type, daemon_id),
+                    bind_mounts=get_container_binds(ctx, fsid, daemon_type, daemon_id),
+                    cname='ceph-%s-%s.%s-activate-test' % (fsid, daemon_type, daemon_id),
+                )
+                out, err, ret = call(ctx, test_cv.run_cmd(), verbosity=CallVerbosity.SILENT)
+                #  bad: ceph-volume: error: unrecognized arguments: activate --bad-option
+                # good: ceph-volume: error: unrecognized arguments: --bad-option
+                if 'unrecognized arguments: activate' in err:
+                    # older ceph-volume without top-level activate or --no-tmpfs
+                    cmd = [
                         'lvm', 'activate',
                         str(daemon_id), osd_fsid,
-                        '--no-systemd'
-                    ],
+                        '--no-systemd',
+                    ]
+                else:
+                    cmd = [
+                        'activate',
+                        '--osd-id', str(daemon_id),
+                        '--osd-uuid', osd_fsid,
+                        '--no-systemd',
+                        '--no-tmpfs',
+                    ]
+
+                prestart = CephContainer(
+                    ctx,
+                    image=ctx.image,
+                    entrypoint='/usr/sbin/ceph-volume',
+                    args=cmd,
                     privileged=True,
                     volume_mounts=get_container_mounts(ctx, fsid, daemon_type, daemon_id),
                     bind_mounts=get_container_binds(ctx, fsid, daemon_type, daemon_id),