Series Upgrade

Implement the series-upgrade feature allowing to move between Ubuntu
series.

Change-Id: I174c30e0de2c9753742262a31b73651b7a4ed3da
This commit is contained in:
David Ames 2018-09-20 11:51:09 +00:00
parent a0a82b50f4
commit a5ab695962
5 changed files with 38 additions and 40 deletions

View File

@ -30,7 +30,7 @@ from charmhelpers.core.hookenv import (
from ceph.utils import get_local_osd_ids
from ceph_hooks import assess_status
from utils import (
from charmhelpers.contrib.openstack.utils import (
set_unit_paused,
clear_unit_paused,
)

View File

@ -73,7 +73,6 @@ from utils import (
get_networks,
assert_charm_supports_ipv6,
render_template,
is_unit_paused_set,
get_public_addr,
get_cluster_addr,
get_blacklist,
@ -94,6 +93,15 @@ from charmhelpers.contrib.storage.linux.utils import (
from charmhelpers.contrib.charmsupport import nrpe
from charmhelpers.contrib.hardening.harden import harden
from charmhelpers.contrib.openstack.utils import (
clear_unit_paused,
clear_unit_upgrading,
is_unit_paused_set,
is_unit_upgrading_set,
set_unit_paused,
set_unit_upgrading,
)
from charmhelpers.core.unitdata import kv
import charmhelpers.contrib.openstack.vaultlocker as vaultlocker
@ -655,6 +663,11 @@ def assess_status():
"""Assess status of current unit"""
# check to see if the unit is paused.
application_version_set(get_upstream_version(VERSION_PACKAGE))
if is_unit_upgrading_set():
status_set("blocked",
"Ready for do-release-upgrade and reboot. "
"Set complete when finished.")
return
if is_unit_paused_set():
status_set('maintenance',
"Paused. Use 'resume' action to resume normal service.")
@ -699,6 +712,27 @@ def update_status():
log('Updating status.')
@hooks.hook('pre-series-upgrade')
def pre_series_upgrade():
log("Running prepare series upgrade hook", "INFO")
# NOTE: The Ceph packages handle the series upgrade gracefully.
# In order to indicate the step of the series upgrade process for
# administrators and automated scripts, the charm sets the paused and
# upgrading states.
set_unit_paused()
set_unit_upgrading()
@hooks.hook('post-series-upgrade')
def post_series_upgrade():
log("Running complete series upgrade hook", "INFO")
# In order to indicate the step of the series upgrade process for
# administrators and automated scripts, the charm clears the paused and
# upgrading states.
clear_unit_paused()
clear_unit_upgrading()
if __name__ == '__main__':
try:
hooks.execute(sys.argv)

1
hooks/post-series-upgrade Symbolic link
View File

@ -0,0 +1 @@
ceph_hooks.py

1
hooks/pre-series-upgrade Symbolic link
View File

@ -0,0 +1 @@
ceph_hooks.py

View File

@ -176,44 +176,6 @@ def assert_charm_supports_ipv6():
"versions less than Trusty 14.04")
# copied charmhelpers.contrib.openstack.utils so that the charm does need the
# entire set of dependencies that that module actually also has to bring in
# from charmhelpers.
def set_unit_paused():
"""Set the unit to a paused state in the local kv() store.
This does NOT actually pause the unit
"""
with unitdata.HookData()() as t:
kv = t[0]
kv.set('unit-paused', True)
def clear_unit_paused():
"""Clear the unit from a paused state in the local kv() store
This does NOT actually restart any services - it only clears the
local state.
"""
with unitdata.HookData()() as t:
kv = t[0]
kv.set('unit-paused', False)
def is_unit_paused_set():
"""Return the state of the kv().get('unit-paused').
This does NOT verify that the unit really is paused.
To help with units that don't have HookData() (testing)
if it excepts, return False
"""
try:
with unitdata.HookData()() as t:
kv = t[0]
# transform something truth-y into a Boolean.
return not(not(kv.get('unit-paused')))
except:
return False
def get_blacklist():
"""Get blacklist stored in the local kv() store"""
db = unitdata.kv()