Merge "Fix directory ownership as part of upgrade"

This commit is contained in:
Jenkins 2016-07-22 15:34:23 +00:00 committed by Gerrit Code Review
commit 7becad3865
2 changed files with 14 additions and 2 deletions

View File

@ -44,8 +44,8 @@ from charmhelpers.core.host import (
mkdir, mkdir,
cmp_pkgrevno, cmp_pkgrevno,
service_stop, service_stop,
service_start service_start,
) chownr)
from charmhelpers.fetch import ( from charmhelpers.fetch import (
add_source, add_source,
apt_install, apt_install,
@ -258,6 +258,11 @@ def upgrade_osd():
else: else:
service_stop('ceph-osd-all') service_stop('ceph-osd-all')
apt_install(packages=ceph.PACKAGES, fatal=True) apt_install(packages=ceph.PACKAGES, fatal=True)
# Ensure the ownership of Ceph's directories is correct
chownr(path=os.path.join(os.sep, "var", "lib", "ceph"),
owner=ceph.ceph_user(),
group=ceph.ceph_user())
if ceph.systemd(): if ceph.systemd():
for osd_id in ceph.get_local_osd_ids(): for osd_id in ceph.get_local_osd_ids():
service_start('ceph-osd@{}'.format(osd_id)) service_start('ceph-osd@{}'.format(osd_id))

View File

@ -35,6 +35,7 @@ TO_PATCH = [
'service_stop', 'service_stop',
'socket', 'socket',
'status_set', 'status_set',
'chownr',
] ]
@ -87,6 +88,7 @@ class UpgradeRollingTestCase(test_utils.CharmTestCase):
def test_upgrade_osd(self): def test_upgrade_osd(self):
self.config.side_effect = config_side_effect self.config.side_effect = config_side_effect
self.ceph.get_version.return_value = "0.80" self.ceph.get_version.return_value = "0.80"
self.ceph.ceph_user.return_value = "ceph"
self.ceph.systemd.return_value = False self.ceph.systemd.return_value = False
ceph_hooks.upgrade_osd() ceph_hooks.upgrade_osd()
self.service_stop.assert_called_with('ceph-osd-all') self.service_stop.assert_called_with('ceph-osd-all')
@ -94,6 +96,11 @@ class UpgradeRollingTestCase(test_utils.CharmTestCase):
self.status_set.assert_has_calls([ self.status_set.assert_has_calls([
call('maintenance', 'Upgrading osd'), call('maintenance', 'Upgrading osd'),
]) ])
self.chownr.assert_has_calls(
[
call(group='ceph', owner='ceph', path='/var/lib/ceph')
]
)
@patch('ceph_hooks.lock_and_roll') @patch('ceph_hooks.lock_and_roll')
@patch('ceph_hooks.get_upgrade_position') @patch('ceph_hooks.get_upgrade_position')