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
=== modified file 'charmhelpers/contrib/openstack/utils.py'
--- charmhelpers/contrib/openstack/utils.py 2015-08-10 16:39:41 +0000
+++ charmhelpers/contrib/openstack/utils.py 2015-09-03 10:16:26 +0000
@@ -1,5 +1,3 @@
1#!/usr/bin/python
2
3# Copyright 2014-2015 Canonical Limited.1# Copyright 2014-2015 Canonical Limited.
4#2#
5# This file is part of charm-helpers.3# This file is part of charm-helpers.
@@ -167,9 +165,9 @@
167 error_out(e)165 error_out(e)
168166
169167
170def get_os_version_codename(codename):168def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES):
171 '''Determine OpenStack version number from codename.'''169 '''Determine OpenStack version number from codename.'''
172 for k, v in six.iteritems(OPENSTACK_CODENAMES):170 for k, v in six.iteritems(version_map):
173 if v == codename:171 if v == codename:
174 return k172 return k
175 e = 'Could not derive OpenStack version for '\173 e = 'Could not derive OpenStack version for '\
@@ -392,7 +390,11 @@
392 import apt_pkg as apt390 import apt_pkg as apt
393 src = config('openstack-origin')391 src = config('openstack-origin')
394 cur_vers = get_os_version_package(package)392 cur_vers = get_os_version_package(package)
395 available_vers = get_os_version_install_source(src)393 if "swift" in package:
394 codename = get_os_codename_install_source(src)
395 available_vers = get_os_version_codename(codename, SWIFT_CODENAMES)
396 else:
397 available_vers = get_os_version_install_source(src)
396 apt.init()398 apt.init()
397 return apt.version_compare(available_vers, cur_vers) == 1399 return apt.version_compare(available_vers, cur_vers) == 1
398400
399401
=== modified file 'tests/contrib/openstack/test_openstack_utils.py'
--- tests/contrib/openstack/test_openstack_utils.py 2015-08-10 16:39:41 +0000
+++ tests/contrib/openstack/test_openstack_utils.py 2015-09-03 10:16:26 +0000
@@ -504,6 +504,8 @@
504 # milestone to major release detection504 # milestone to major release detection
505 vers_pkg.return_value = '2013.2~b1'505 vers_pkg.return_value = '2013.2~b1'
506 self.assertTrue(openstack.openstack_upgrade_available('nova-common'))506 self.assertTrue(openstack.openstack_upgrade_available('nova-common'))
507 vers_pkg.return_value = '1.9.0'
508 self.assertTrue(openstack.openstack_upgrade_available('swift-proxy'))
507509
508 @patch.object(openstack, 'lsb_release')510 @patch.object(openstack, 'lsb_release')
509 @patch.object(openstack, 'get_os_version_package')511 @patch.object(openstack, 'get_os_version_package')
@@ -517,6 +519,10 @@
517 # milestone to majro release detection519 # milestone to majro release detection
518 vers_pkg.return_value = '2013.1~b1'520 vers_pkg.return_value = '2013.1~b1'
519 self.assertFalse(openstack.openstack_upgrade_available('nova-common'))521 self.assertFalse(openstack.openstack_upgrade_available('nova-common'))
522 # ugly duckling testing
523 config.return_value = 'cloud:precise-havana'
524 vers_pkg.return_value = '1.10.0'
525 self.assertFalse(openstack.openstack_upgrade_available('swift-proxy'))
520526
521 @patch.object(openstack, 'is_block_device')527 @patch.object(openstack, 'is_block_device')
522 @patch.object(openstack, 'error_out')528 @patch.object(openstack, 'error_out')

Subscribers

People subscribed via source and target branches