From d687fdd3a3716790e1a8203007447ccd9c36ca22 Mon Sep 17 00:00:00 2001 From: David Ames Date: Thu, 20 Sep 2018 12:00:03 +0000 Subject: [PATCH] Series Upgrade Implement the series-upgrade feature allowing to move between Ubuntu series. Change-Id: Ib0a599eeae75fd2e1948d4c86515da4b77340131 --- hooks/ceph_hooks.py | 33 +++++++++++++++++++++++++++++++++ hooks/post-series-upgrade | 1 + hooks/pre-series-upgrade | 1 + 3 files changed, 35 insertions(+) create mode 120000 hooks/post-series-upgrade create mode 120000 hooks/pre-series-upgrade diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index e192d846..6365ff78 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -61,6 +61,13 @@ from charmhelpers.fetch import ( ) from charmhelpers.payload.execd import execd_preinstall from charmhelpers.contrib.openstack.alternatives import install_alternative +from charmhelpers.contrib.openstack.utils import ( + clear_unit_paused, + clear_unit_upgrading, + is_unit_upgrading_set, + set_unit_paused, + set_unit_upgrading, +) from charmhelpers.contrib.network.ip import ( get_ipv6_addr, format_ipv6_addr, @@ -720,6 +727,11 @@ VERSION_PACKAGE = 'ceph-common' def assess_status(): '''Assess status of current unit''' 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 # Check that the no-bootstrap config option is set in conjunction with # having the bootstrap-source relation established @@ -760,6 +772,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) diff --git a/hooks/post-series-upgrade b/hooks/post-series-upgrade new file mode 120000 index 00000000..52d96630 --- /dev/null +++ b/hooks/post-series-upgrade @@ -0,0 +1 @@ +ceph_hooks.py \ No newline at end of file diff --git a/hooks/pre-series-upgrade b/hooks/pre-series-upgrade new file mode 120000 index 00000000..52d96630 --- /dev/null +++ b/hooks/pre-series-upgrade @@ -0,0 +1 @@ +ceph_hooks.py \ No newline at end of file