Fix directory ownership as part of upgrade and restart OSD's
This change ensures that when ceph is upgraded from an older version that uses root to a newer version that uses ceph as the process owner that all directories are chowned. As the ceph charm can also host OSD processes, ensure that any ceph-osd daemons are stopped and started during the upgrade process. Change-Id: Ief3fd6352b440b7740965746cd0d1d846c647f84 Closes-Bug: 1600338
This commit is contained in:
parent
5bfbd7417a
commit
001d890d42
|
@ -54,7 +54,8 @@ from charmhelpers.core.host import (
|
|||
write_file,
|
||||
rsync,
|
||||
cmp_pkgrevno,
|
||||
service_stop, service_start
|
||||
service_stop, service_start,
|
||||
chownr,
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
|
@ -260,15 +261,28 @@ def upgrade_monitor():
|
|||
if ceph.systemd():
|
||||
for mon_id in ceph.get_local_mon_ids():
|
||||
service_stop('ceph-mon@{}'.format(mon_id))
|
||||
for osd_id in ceph.get_local_osd_ids():
|
||||
service_stop('ceph-osd@{}'.format(osd_id))
|
||||
else:
|
||||
service_stop('ceph-mon-all')
|
||||
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 mon_id in ceph.get_local_mon_ids():
|
||||
service_start('ceph-mon@{}'.format(mon_id))
|
||||
for osd_id in ceph.get_local_osd_ids():
|
||||
service_start('ceph-osd@{}'.format(osd_id))
|
||||
else:
|
||||
service_start('ceph-mon-all')
|
||||
status_set("active", "")
|
||||
service_start('ceph-osd-all')
|
||||
|
||||
except subprocess.CalledProcessError as err:
|
||||
log("Stopping ceph and upgrading packages failed "
|
||||
"with message: {}".format(err.message))
|
||||
|
|
|
@ -38,6 +38,7 @@ TO_PATCH = [
|
|||
'service_stop',
|
||||
'service_start',
|
||||
'host',
|
||||
'chownr',
|
||||
]
|
||||
|
||||
|
||||
|
@ -90,14 +91,25 @@ class UpgradeRollingTestCase(test_utils.CharmTestCase):
|
|||
def test_upgrade_monitor(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_monitor()
|
||||
self.service_stop.assert_called_with('ceph-mon-all')
|
||||
self.service_start.assert_called_with('ceph-mon-all')
|
||||
self.service_stop.assert_has_calls([
|
||||
call('ceph-mon-all'),
|
||||
call('ceph-osd-all'),
|
||||
])
|
||||
self.service_start.assert_has_calls([
|
||||
call('ceph-mon-all'),
|
||||
call('ceph-osd-all'),
|
||||
])
|
||||
self.status_set.assert_has_calls([
|
||||
call('maintenance', 'Upgrading monitor'),
|
||||
call('active', '')
|
||||
])
|
||||
self.chownr.assert_has_calls(
|
||||
[
|
||||
call(group='ceph', owner='ceph', path='/var/lib/ceph')
|
||||
]
|
||||
)
|
||||
|
||||
@patch('ceph_hooks.lock_and_roll')
|
||||
@patch('ceph_hooks.wait_on_previous_node')
|
||||
|
|
Loading…
Reference in New Issue