diff --git a/hooks/ceph.py b/hooks/ceph.py index 22e6c9af..09f70960 100644 --- a/hooks/ceph.py +++ b/hooks/ceph.py @@ -362,8 +362,12 @@ def replace_osd(dead_osd_number, # Drop this osd out of the cluster. This will begin a # rebalance operation status_set('maintenance', 'Removing osd {}'.format(dead_osd_number)) - subprocess.check_output(['ceph', 'osd', 'out', - 'osd.{}'.format(dead_osd_number)]) + subprocess.check_output([ + 'ceph', + '--id', + 'osd-upgrade', + 'osd', 'out', + 'osd.{}'.format(dead_osd_number)]) # Kill the osd process if it's not already dead if systemd(): @@ -378,13 +382,25 @@ def replace_osd(dead_osd_number, mount_point, os.strerror(ret))) # Clean up the old mount point shutil.rmtree(mount_point) - subprocess.check_output(['ceph', 'osd', 'crush', 'remove', - 'osd.{}'.format(dead_osd_number)]) + subprocess.check_output([ + 'ceph', + '--id', + 'osd-upgrade', + 'osd', 'crush', 'remove', + 'osd.{}'.format(dead_osd_number)]) # Revoke the OSDs access keys - subprocess.check_output(['ceph', 'auth', 'del', - 'osd.{}'.format(dead_osd_number)]) - subprocess.check_output(['ceph', 'osd', 'rm', - 'osd.{}'.format(dead_osd_number)]) + subprocess.check_output([ + 'ceph', + '--id', + 'osd-upgrade', + 'auth', 'del', + 'osd.{}'.format(dead_osd_number)]) + subprocess.check_output([ + 'ceph', + '--id', + 'osd-upgrade', + 'osd', 'rm', + 'osd.{}'.format(dead_osd_number)]) status_set('maintenance', 'Setting up replacement osd {}'.format( new_osd_device)) osdize(new_osd_device, diff --git a/unit_tests/test_replace_osd.py b/unit_tests/test_replace_osd.py index dd3e9c11..ce919382 100644 --- a/unit_tests/test_replace_osd.py +++ b/unit_tests/test_replace_osd.py @@ -79,13 +79,16 @@ class ReplaceOsdTestCase(test_utils.CharmTestCase): @patch('ceph.osdize') @patch('ceph.shutil') @patch('ceph.systemd') + @patch('ceph.ceph_user') def test_replace_osd(self, + ceph_user, systemd, shutil, osdize, umount, subprocess, mounts): + ceph_user.return_value = "ceph" mounts.return_value = [['/var/lib/ceph/osd/ceph-a', '/dev/sda']] subprocess.check_output.return_value = True self.status_set.return_value = None @@ -102,11 +105,15 @@ class ReplaceOsdTestCase(test_utils.CharmTestCase): ignore_errors=False) subprocess.check_output.assert_has_calls( [ - call(['ceph', 'osd', 'out', 'osd.0']), + call(['ceph', '--id', 'osd-upgrade', + 'osd', 'out', 'osd.0']), call(['stop', 'ceph-osd', 'id=0']), - call(['ceph', 'osd', 'crush', 'remove', 'osd.0']), - call(['ceph', 'auth', 'del', 'osd.0']), - call(['ceph', 'osd', 'rm', 'osd.0']) + call(['ceph', '--id', + 'osd-upgrade', 'osd', 'crush', 'remove', 'osd.0']), + call(['ceph', '--id', + 'osd-upgrade', 'auth', 'del', 'osd.0']), + call(['ceph', '--id', + 'osd-upgrade', 'osd', 'rm', 'osd.0']) ] )