Fix OSD replacement

Use the osd-upgrade key when replacing OSD's as this key
has the correct cephx permissions to perform the operation.

Closes-Bug: 1602826

Depends-On: I6af43b61149c6eeeeb5c77950701194beda2da71
Change-Id: I32d2f1a4036e09d5d1fd13009c95ab1514e7304c
This commit is contained in:
Chris Holcombe 2016-07-14 14:07:01 -07:00 committed by James Page
parent 107291ea84
commit 25a988b9c4
2 changed files with 35 additions and 12 deletions

View File

@ -362,8 +362,12 @@ def replace_osd(dead_osd_number,
# Drop this osd out of the cluster. This will begin a # Drop this osd out of the cluster. This will begin a
# rebalance operation # rebalance operation
status_set('maintenance', 'Removing osd {}'.format(dead_osd_number)) status_set('maintenance', 'Removing osd {}'.format(dead_osd_number))
subprocess.check_output(['ceph', 'osd', 'out', subprocess.check_output([
'osd.{}'.format(dead_osd_number)]) 'ceph',
'--id',
'osd-upgrade',
'osd', 'out',
'osd.{}'.format(dead_osd_number)])
# Kill the osd process if it's not already dead # Kill the osd process if it's not already dead
if systemd(): if systemd():
@ -378,13 +382,25 @@ def replace_osd(dead_osd_number,
mount_point, os.strerror(ret))) mount_point, os.strerror(ret)))
# Clean up the old mount point # Clean up the old mount point
shutil.rmtree(mount_point) shutil.rmtree(mount_point)
subprocess.check_output(['ceph', 'osd', 'crush', 'remove', subprocess.check_output([
'osd.{}'.format(dead_osd_number)]) 'ceph',
'--id',
'osd-upgrade',
'osd', 'crush', 'remove',
'osd.{}'.format(dead_osd_number)])
# Revoke the OSDs access keys # Revoke the OSDs access keys
subprocess.check_output(['ceph', 'auth', 'del', subprocess.check_output([
'osd.{}'.format(dead_osd_number)]) 'ceph',
subprocess.check_output(['ceph', 'osd', 'rm', '--id',
'osd.{}'.format(dead_osd_number)]) '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( status_set('maintenance', 'Setting up replacement osd {}'.format(
new_osd_device)) new_osd_device))
osdize(new_osd_device, osdize(new_osd_device,

View File

@ -79,13 +79,16 @@ class ReplaceOsdTestCase(test_utils.CharmTestCase):
@patch('ceph.osdize') @patch('ceph.osdize')
@patch('ceph.shutil') @patch('ceph.shutil')
@patch('ceph.systemd') @patch('ceph.systemd')
@patch('ceph.ceph_user')
def test_replace_osd(self, def test_replace_osd(self,
ceph_user,
systemd, systemd,
shutil, shutil,
osdize, osdize,
umount, umount,
subprocess, subprocess,
mounts): mounts):
ceph_user.return_value = "ceph"
mounts.return_value = [['/var/lib/ceph/osd/ceph-a', '/dev/sda']] mounts.return_value = [['/var/lib/ceph/osd/ceph-a', '/dev/sda']]
subprocess.check_output.return_value = True subprocess.check_output.return_value = True
self.status_set.return_value = None self.status_set.return_value = None
@ -102,11 +105,15 @@ class ReplaceOsdTestCase(test_utils.CharmTestCase):
ignore_errors=False) ignore_errors=False)
subprocess.check_output.assert_has_calls( 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(['stop', 'ceph-osd', 'id=0']),
call(['ceph', 'osd', 'crush', 'remove', 'osd.0']), call(['ceph', '--id',
call(['ceph', 'auth', 'del', 'osd.0']), 'osd-upgrade', 'osd', 'crush', 'remove', 'osd.0']),
call(['ceph', 'osd', 'rm', 'osd.0']) call(['ceph', '--id',
'osd-upgrade', 'auth', 'del', 'osd.0']),
call(['ceph', '--id',
'osd-upgrade', 'osd', 'rm', 'osd.0'])
] ]
) )