]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: enable --runtime ceph-osd systemd units 12147/head
authorLoic Dachary <ldachary@redhat.com>
Wed, 30 Nov 2016 23:28:32 +0000 (00:28 +0100)
committerLoic Dachary <ldachary@redhat.com>
Mon, 5 Dec 2016 08:51:05 +0000 (09:51 +0100)
If ceph-osd@.service is enabled for a given device (say /dev/sdb1 for
osd.3) the ceph-osd@3.service will race with ceph-disk@dev-sdb1.service
at boot time.

Enabling ceph-osd@3.service is not necessary at boot time because

   ceph-disk@dev-sdb1.service

calls

   ceph-disk activate /dev/sdb1

which calls

   systemctl start ceph-osd@3

The systemctl enable/disable ceph-osd@.service called by ceph-disk
activate is changed to add the --runtime option so that ceph-osd units
are lost after a reboot. They are recreated when ceph-disk activate is
called at boot time so that:

   systemctl stop ceph

knows which ceph-osd@.service to stop when a script or sysadmin wants
to stop all ceph services.

Before enabling ceph-osd@.service (that happens at every boot time),
make sure the permanent enablement in /etc/systemd is removed so that
only the one added by systemctl enable --runtime in /run/systemd
remains. This is useful to upgrade an existing cluster without creating
a situation that is even worse than before because ceph-disk@.service
races against two ceph-osd@.service (one in /etc/systemd and one in
/run/systemd).

Fixes: http://tracker.ceph.com/issues/17889
Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 539385b143feee3905dceaf7a8faaced42f2d3c6)

src/ceph-disk/ceph_disk/main.py

index 768972b43e290aea2062ee36ff052e6dd1d7e32d..3dcd49e9bd4685de5f1814f08c18e6471294e970 100755 (executable)
@@ -2883,10 +2883,19 @@ def start_daemon(
                 ],
             )
         elif os.path.exists(os.path.join(path, 'systemd')):
+            # ensure there is no duplicate ceph-osd@.service
+            command_check_call(
+                [
+                    'systemctl',
+                    'disable',
+                    'ceph-osd@{osd_id}'.format(osd_id=osd_id),
+                ],
+            )
             command_check_call(
                 [
                     'systemctl',
                     'enable',
+                    '--runtime',
                     'ceph-osd@{osd_id}'.format(osd_id=osd_id),
                 ],
             )
@@ -2944,6 +2953,7 @@ def stop_daemon(
                 [
                     'systemctl',
                     'disable',
+                    '--runtime',
                     'ceph-osd@{osd_id}'.format(osd_id=osd_id),
                 ],
             )