From 9f33b8135e8a650948156a63793815f766bf5034 Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 10 Oct 2018 09:20:14 -0700 Subject: [PATCH] Series Upgrade Implement the series-upgrade feature allowing to move between Ubuntu series. Change-Id: Ib5f234c219437c14b54ebe248c9598492542fd23 --- hooks/post-series-upgrade | 1 + hooks/pre-series-upgrade | 1 + hooks/swift_storage_hooks.py | 31 +++++++++++++++++++++++++++++++ tests/basic_deployment.py | 23 +++++++++++++++++++---- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 120000 hooks/post-series-upgrade create mode 120000 hooks/pre-series-upgrade diff --git a/hooks/post-series-upgrade b/hooks/post-series-upgrade new file mode 120000 index 0000000..c5c04a7 --- /dev/null +++ b/hooks/post-series-upgrade @@ -0,0 +1 @@ +swift_storage_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 0000000..c5c04a7 --- /dev/null +++ b/hooks/pre-series-upgrade @@ -0,0 +1 @@ +swift_storage_hooks.py \ No newline at end of file diff --git a/hooks/swift_storage_hooks.py b/hooks/swift_storage_hooks.py index 953ca00..a37a18c 100755 --- a/hooks/swift_storage_hooks.py +++ b/hooks/swift_storage_hooks.py @@ -71,6 +71,8 @@ from charmhelpers.core.host import ( rsync, write_file, umount, + service_start, + service_stop, ) from charmhelpers.core.sysctl import create as create_sysctl @@ -82,6 +84,11 @@ from charmhelpers.contrib.openstack.utils import ( openstack_upgrade_available, set_os_workload_status, os_application_version_set, + clear_unit_paused, + clear_unit_upgrading, + is_unit_paused_set, + set_unit_paused, + set_unit_upgrading, ) from charmhelpers.contrib.network.ip import ( get_relation_ip, @@ -369,6 +376,30 @@ def update_status(): log('Updating status.') +@hooks.hook('pre-series-upgrade') +def pre_series_upgrade(): + log("Running prepare series upgrade hook", "INFO") + if not is_unit_paused_set(): + for service in SWIFT_SVCS: + stopped = service_stop(service) + if not stopped: + raise Exception("{} didn't stop cleanly.".format(service)) + set_unit_paused() + set_unit_upgrading() + + +@hooks.hook('post-series-upgrade') +def post_series_upgrade(): + log("Running complete series upgrade hook", "INFO") + clear_unit_paused() + clear_unit_upgrading() + if not is_unit_paused_set(): + for service in SWIFT_SVCS: + started = service_start(service) + if not started: + raise Exception("{} didn't start cleanly.".format(service)) + + def main(): try: hooks.execute(sys.argv) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 3b52635..a92f5aa 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -130,8 +130,18 @@ class SwiftStorageBasicDeployment(OpenStackAmuletDeployment): self._get_openstack_release()) ) + force_v1_client = False + if self._get_openstack_release() == self.trusty_icehouse: + # Updating image properties (such as arch or hypervisor) using the + # v2 api in icehouse results in: + # https://bugs.launchpad.net/python-glanceclient/+bug/1371559 + u.log.debug('Forcing glance to use v1 api') + force_v1_client = True + # Authenticate admin with glance endpoint - self.glance = u.authenticate_glance_admin(self.keystone) + self.glance = u.authenticate_glance_admin( + self.keystone, + force_v1_client=force_v1_client) keystone_ip = self.keystone_sentry.info['public-address'] keystone_relation = self.keystone_sentry.relation( @@ -452,12 +462,17 @@ class SwiftStorageBasicDeployment(OpenStackAmuletDeployment): headers, objects = self.swift.get_container(container_name) - if len(objects) != 2: + if float(self.glance.version) < 2.0: + object_count = 1 + else: + object_count = 2 + + if len(objects) != object_count: msg = "Expected 2 swift object, found {}".format(len(objects)) amulet.raise_status(amulet.FAIL, msg=msg) - swift_object_size = objects[1].get('bytes') - swift_object_md5 = objects[1].get('hash') + swift_object_size = objects[object_count - 1].get('bytes') + swift_object_md5 = objects[object_count - 1].get('hash') if img_size != swift_object_size: msg = "Glance image size {} != swift object size {}".format(