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
# 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,

View File

@ -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'])
]
)