Generalize upgrade paths, use charms.ceph
Bring ceph charm inline with ceph-mon and ceph-osd charms, supporting all upgrades paths for trusty and xenial deployments. Change-Id: I8284e1f9b583b34cb68babec69407edc14c04930 Closes-Bug: 1662863
This commit is contained in:
parent
f936367cac
commit
596d8a9625
|
@ -2,6 +2,7 @@ bin
|
|||
.idea
|
||||
.coverage
|
||||
.testrepository
|
||||
.stestr
|
||||
.tox
|
||||
*.sw[nop]
|
||||
.idea
|
||||
|
|
|
@ -91,20 +91,6 @@ STATUS_FILE = '/var/lib/nagios/cat-ceph-status.txt'
|
|||
STATUS_CRONFILE = '/etc/cron.d/cat-ceph-health'
|
||||
STORAGE_MOUNT_PATH = '/var/lib/ceph'
|
||||
|
||||
# A dict of valid ceph upgrade paths. Mapping is old -> new
|
||||
upgrade_paths = {
|
||||
'cloud:trusty-juno': 'cloud:trusty-kilo',
|
||||
'cloud:trusty-kilo': 'cloud:trusty-liberty',
|
||||
'cloud:trusty-liberty': 'cloud:trusty-mitaka',
|
||||
}
|
||||
|
||||
|
||||
def pretty_print_upgrade_paths():
|
||||
lines = []
|
||||
for key, value in upgrade_paths.iteritems():
|
||||
lines.append("{} -> {}".format(key, value))
|
||||
return lines
|
||||
|
||||
|
||||
def check_for_upgrade():
|
||||
if not ceph.is_bootstrapped():
|
||||
|
@ -112,17 +98,15 @@ def check_for_upgrade():
|
|||
return
|
||||
|
||||
c = hookenv.config()
|
||||
old_version = c.previous('source')
|
||||
old_version = ceph.resolve_ceph_version(c.previous('source') or
|
||||
'distro')
|
||||
log('old_version: {}'.format(old_version))
|
||||
# Strip all whitespace
|
||||
new_version = hookenv.config('source')
|
||||
if new_version:
|
||||
# replace all whitespace
|
||||
new_version = new_version.replace(' ', '')
|
||||
new_version = ceph.resolve_ceph_version(hookenv.config('source'))
|
||||
log('new_version: {}'.format(new_version))
|
||||
|
||||
if old_version in upgrade_paths:
|
||||
if new_version == upgrade_paths[old_version]:
|
||||
if old_version in ceph.UPGRADE_PATHS:
|
||||
if new_version == ceph.UPGRADE_PATHS[old_version]:
|
||||
log("{} to {} is a valid upgrade path. Proceeding.".format(
|
||||
old_version, new_version))
|
||||
ceph.roll_monitor_cluster(new_version=new_version,
|
||||
|
@ -136,9 +120,11 @@ def check_for_upgrade():
|
|||
else:
|
||||
# Log a helpful error message
|
||||
log("Invalid upgrade path from {} to {}. "
|
||||
"Valid paths are: {}".format(old_version,
|
||||
new_version,
|
||||
pretty_print_upgrade_paths()))
|
||||
"Valid paths are: {}".format(
|
||||
old_version,
|
||||
new_version,
|
||||
ceph.pretty_print_upgrade_paths()
|
||||
))
|
||||
|
||||
|
||||
@hooks.hook('install.real')
|
||||
|
|
|
@ -18,6 +18,7 @@ def config_side_effect(*args):
|
|||
|
||||
class UpgradeRollingTestCase(unittest.TestCase):
|
||||
|
||||
@patch('ceph_hooks.ceph.resolve_ceph_version')
|
||||
@patch('ceph_hooks.ceph.is_bootstrapped')
|
||||
@patch('ceph_hooks.log')
|
||||
@patch('ceph_hooks.ceph.roll_monitor_cluster')
|
||||
|
@ -30,7 +31,9 @@ class UpgradeRollingTestCase(unittest.TestCase):
|
|||
wait_for_mons,
|
||||
roll_monitor_cluster,
|
||||
log,
|
||||
is_bootstrapped):
|
||||
is_bootstrapped,
|
||||
version):
|
||||
version.side_effect = ['firefly', 'hammer']
|
||||
is_bootstrapped.return_value = True
|
||||
previous_mock = MagicMock().return_value
|
||||
previous_mock.previous.return_value = "cloud:trusty-juno"
|
||||
|
@ -39,23 +42,23 @@ class UpgradeRollingTestCase(unittest.TestCase):
|
|||
check_for_upgrade()
|
||||
|
||||
wait_for_mons.assert_called_with(
|
||||
new_version='cloud:trusty-kilo',
|
||||
new_version='hammer',
|
||||
upgrade_key='admin'
|
||||
)
|
||||
roll_osd_cluster.assert_called_with(
|
||||
new_version='cloud:trusty-kilo',
|
||||
new_version='hammer',
|
||||
upgrade_key='admin'
|
||||
)
|
||||
|
||||
roll_monitor_cluster.assert_called_with(
|
||||
new_version='cloud:trusty-kilo',
|
||||
new_version='hammer',
|
||||
upgrade_key='admin'
|
||||
)
|
||||
log.assert_has_calls(
|
||||
[
|
||||
call('old_version: cloud:trusty-juno'),
|
||||
call('new_version: cloud:trusty-kilo'),
|
||||
call('cloud:trusty-juno to cloud:trusty-kilo is a valid '
|
||||
call('old_version: firefly'),
|
||||
call('new_version: hammer'),
|
||||
call('firefly to hammer is a valid '
|
||||
'upgrade path. Proceeding.')
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue