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,
cmp_pkgrevno,
service_stop,
service_start
)
service_start,
chownr)
from charmhelpers.fetch import (
add_source,
apt_install,
@ -258,6 +258,11 @@ def upgrade_osd():
else:
service_stop('ceph-osd-all')
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():
for osd_id in ceph.get_local_osd_ids():
service_start('ceph-osd@{}'.format(osd_id))

View File

@ -35,6 +35,7 @@ TO_PATCH = [
'service_stop',
'socket',
'status_set',
'chownr',
]
@ -87,6 +88,7 @@ class UpgradeRollingTestCase(test_utils.CharmTestCase):
def test_upgrade_osd(self):
self.config.side_effect = config_side_effect
self.ceph.get_version.return_value = "0.80"
self.ceph.ceph_user.return_value = "ceph"
self.ceph.systemd.return_value = False
ceph_hooks.upgrade_osd()
self.service_stop.assert_called_with('ceph-osd-all')
@ -94,6 +96,11 @@ class UpgradeRollingTestCase(test_utils.CharmTestCase):
self.status_set.assert_has_calls([
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.get_upgrade_position')