Merge lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift-stable into lp:~openstack-charmers/charm-helpers/stable-1604

Proposed by Adam Collard
Status: Merged
Merged at revision: 369
Proposed branch: lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift-stable
Merge into: lp:~openstack-charmers/charm-helpers/stable-1604
Diff against target: 58 lines (+13/-5)
2 files modified
charmhelpers/contrib/openstack/utils.py (+7/-5)
tests/contrib/openstack/test_openstack_utils.py (+6/-0)
To merge this branch: bzr merge lp:~adam-collard/charm-helpers/openstack-upgrade-available-swift-stable
Reviewer Review Type Date Requested Status
Liam Young Approve
Review via email: mp+270028@code.launchpad.net

Description of the change

Backport r436 to stable.

See https://code.launchpad.net/~adam-collard/charm-helpers/openstack-upgrade-available-swift/+merge/269481 for trunk MP.

"Special case swift packages for version comparison purposes in openstack_upgrade_available.

Without this change, the swift charms will think that OpenStack upgrades are constantly available because the code ended up comparing numbers from two different version schemes and it turns out that '2014.1' > '1.13.1'"

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/utils.py'
2--- charmhelpers/contrib/openstack/utils.py 2015-08-10 16:39:41 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2015-09-03 10:16:26 +0000
4@@ -1,5 +1,3 @@
5-#!/usr/bin/python
6-
7 # Copyright 2014-2015 Canonical Limited.
8 #
9 # This file is part of charm-helpers.
10@@ -167,9 +165,9 @@
11 error_out(e)
12
13
14-def get_os_version_codename(codename):
15+def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES):
16 '''Determine OpenStack version number from codename.'''
17- for k, v in six.iteritems(OPENSTACK_CODENAMES):
18+ for k, v in six.iteritems(version_map):
19 if v == codename:
20 return k
21 e = 'Could not derive OpenStack version for '\
22@@ -392,7 +390,11 @@
23 import apt_pkg as apt
24 src = config('openstack-origin')
25 cur_vers = get_os_version_package(package)
26- available_vers = get_os_version_install_source(src)
27+ if "swift" in package:
28+ codename = get_os_codename_install_source(src)
29+ available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
30+ else:
31+ available_vers = get_os_version_install_source(src)
32 apt.init()
33 return apt.version_compare(available_vers, cur_vers) == 1
34
35
36=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
37--- tests/contrib/openstack/test_openstack_utils.py 2015-08-10 16:39:41 +0000
38+++ tests/contrib/openstack/test_openstack_utils.py 2015-09-03 10:16:26 +0000
39@@ -504,6 +504,8 @@
40 # milestone to major release detection
41 vers_pkg.return_value = '2013.2~b1'
42 self.assertTrue(openstack.openstack_upgrade_available('nova-common'))
43+ vers_pkg.return_value = '1.9.0'
44+ self.assertTrue(openstack.openstack_upgrade_available('swift-proxy'))
45
46 @patch.object(openstack, 'lsb_release')
47 @patch.object(openstack, 'get_os_version_package')
48@@ -517,6 +519,10 @@
49 # milestone to majro release detection
50 vers_pkg.return_value = '2013.1~b1'
51 self.assertFalse(openstack.openstack_upgrade_available('nova-common'))
52+ # ugly duckling testing
53+ config.return_value = 'cloud:precise-havana'
54+ vers_pkg.return_value = '1.10.0'
55+ self.assertFalse(openstack.openstack_upgrade_available('swift-proxy'))
56
57 @patch.object(openstack, 'is_block_device')
58 @patch.object(openstack, 'error_out')

Subscribers

People subscribed via source and target branches